odor 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/bin/odor +13 -0
- data/lib/odor.rb +53 -0
- data/lib/odor/version.rb +3 -0
- data/odor.gemspec +23 -0
- data/spec/spec_helper.rb +6 -0
- metadata +66 -0
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/odor
ADDED
data/lib/odor.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require "odor/version"
|
2
|
+
|
3
|
+
module Odor
|
4
|
+
def self.run(*args)
|
5
|
+
%x[git status -s].split("\n").each do |line|
|
6
|
+
check_file(line.split.last)
|
7
|
+
end
|
8
|
+
|
9
|
+
puts "No smells found" unless @smell_detected
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.check_file(file_name)
|
13
|
+
issues(file_name).each do |hint|
|
14
|
+
line_changes(file_name).each do |num|
|
15
|
+
if hint.include?(num.to_s)
|
16
|
+
puts hint
|
17
|
+
@smell_detected = true
|
18
|
+
break
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.issues(file_name)
|
25
|
+
%x[rails_best_practices -f text #{file_name} --silent --without-color].split("\n")
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.file_diff(file_name)
|
29
|
+
changes = %x[git diff -U0 #{file_name}].split("\n")
|
30
|
+
changes.shift(4)
|
31
|
+
|
32
|
+
line_changes = []
|
33
|
+
changes.each { |c| line_changes << c if !c.nil? && c.start_with?('@') }
|
34
|
+
return line_changes
|
35
|
+
end
|
36
|
+
|
37
|
+
# TODO split into mutiple methods
|
38
|
+
def self.line_changes(file_name)
|
39
|
+
lines = []
|
40
|
+
|
41
|
+
file_diff(file_name).each do |s|
|
42
|
+
s = s.split
|
43
|
+
s.shift(2)
|
44
|
+
|
45
|
+
li = s.first[1, 12].split(',')
|
46
|
+
li.last.to_i.times do |i|
|
47
|
+
lines << li.first.to_i + i
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
return lines
|
52
|
+
end
|
53
|
+
end
|
data/lib/odor/version.rb
ADDED
data/odor.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "odor/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "odor"
|
7
|
+
s.version = Odor::VERSION
|
8
|
+
s.authors = ["Dave Elliott"]
|
9
|
+
s.email = ["ddazza@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/davidelliott/"
|
11
|
+
s.summary = %q{Lists smells in code changes}
|
12
|
+
s.description = %q{Outputs a list of bits of code which should be reviewed as they could potentialy lead to later problem from current code changes}
|
13
|
+
|
14
|
+
s.rubyforge_project = "odor"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# s.add_development_dependency "rspec", "~>2.8.0"
|
22
|
+
s.add_runtime_dependency "rails_best_practices", "~>1.9.0"
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: odor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dave Elliott
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails_best_practices
|
16
|
+
requirement: &18700240 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.9.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *18700240
|
25
|
+
description: Outputs a list of bits of code which should be reviewed as they could
|
26
|
+
potentialy lead to later problem from current code changes
|
27
|
+
email:
|
28
|
+
- ddazza@gmail.com
|
29
|
+
executables:
|
30
|
+
- odor
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- Rakefile
|
37
|
+
- bin/odor
|
38
|
+
- lib/odor.rb
|
39
|
+
- lib/odor/version.rb
|
40
|
+
- odor.gemspec
|
41
|
+
- spec/spec_helper.rb
|
42
|
+
homepage: https://github.com/davidelliott/
|
43
|
+
licenses: []
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project: odor
|
62
|
+
rubygems_version: 1.8.11
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: Lists smells in code changes
|
66
|
+
test_files: []
|