kevinrutherford-reek 1.1.3.9 → 1.1.3.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/History.txt +2 -1
  2. data/License.txt +20 -0
  3. data/bin/reek +5 -5
  4. data/features/options.feature +1 -0
  5. data/features/reports.feature +40 -0
  6. data/features/stdin.feature +10 -1
  7. data/features/step_definitions/reek_steps.rb +2 -2
  8. data/features/support/env.rb +2 -2
  9. data/lib/reek/class_context.rb +2 -2
  10. data/lib/reek/code_parser.rb +4 -0
  11. data/lib/reek/core_extras.rb +50 -0
  12. data/lib/reek/object_source.rb +7 -18
  13. data/lib/reek/options.rb +13 -3
  14. data/lib/reek/report.rb +27 -28
  15. data/lib/reek/sexp_formatter.rb +2 -0
  16. data/lib/reek/smells/control_couple.rb +5 -0
  17. data/lib/reek/sniffer.rb +98 -3
  18. data/lib/reek/source.rb +9 -112
  19. data/lib/reek/spec.rb +29 -55
  20. data/lib/reek.rb +1 -1
  21. data/reek.gemspec +4 -4
  22. data/spec/reek/object_source_spec.rb +3 -3
  23. data/spec/reek/report_spec.rb +9 -5
  24. data/spec/reek/should_reek_of_spec.rb +105 -0
  25. data/spec/reek/should_reek_only_of_spec.rb +85 -0
  26. data/spec/reek/{spec_spec.rb → should_reek_spec.rb} +24 -3
  27. data/spec/reek/smells/duplication_spec.rb +1 -1
  28. data/spec/reek/smells/large_class_spec.rb +1 -0
  29. data/spec/reek/smells/long_method_spec.rb +4 -4
  30. data/spec/reek/smells/long_parameter_list_spec.rb +1 -1
  31. data/spec/reek/smells/smell_detector_spec.rb +1 -1
  32. data/spec/reek/smells/uncommunicative_name_spec.rb +2 -1
  33. data/spec/reek/sniffer_spec.rb +10 -0
  34. data/spec/samples/all_but_one_masked/clean_one.rb +6 -0
  35. data/spec/samples/all_but_one_masked/dirty.rb +7 -0
  36. data/spec/samples/all_but_one_masked/masked.reek +5 -0
  37. data/spec/samples/clean_due_to_masking/clean_one.rb +6 -0
  38. data/spec/samples/clean_due_to_masking/clean_three.rb +6 -0
  39. data/spec/samples/clean_due_to_masking/clean_two.rb +6 -0
  40. data/spec/samples/clean_due_to_masking/dirty_one.rb +7 -0
  41. data/spec/samples/clean_due_to_masking/dirty_two.rb +7 -0
  42. data/spec/samples/clean_due_to_masking/masked.reek +7 -0
  43. data/spec/samples/mixed_results/clean_one.rb +6 -0
  44. data/spec/samples/mixed_results/clean_three.rb +6 -0
  45. data/spec/samples/mixed_results/clean_two.rb +6 -0
  46. data/spec/samples/mixed_results/dirty_one.rb +7 -0
  47. data/spec/samples/mixed_results/dirty_two.rb +7 -0
  48. data/spec/slow/inline_spec.rb +6 -2
  49. data/spec/slow/optparse_spec.rb +6 -2
  50. data/spec/slow/redcloth_spec.rb +6 -2
  51. data/tasks/test.rake +2 -0
  52. metadata +23 -4
  53. data/spec/slow/source_list_spec.rb +0 -40
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
- require 'reek/code_parser'
3
+ require 'reek/object_source'
4
4
  require 'reek/smells/long_parameter_list'
5
5
  require 'reek/report'
6
6
 
@@ -43,7 +43,7 @@ describe SmellDetector, 'when masked' do
43
43
  end
44
44
 
45
45
  it 'reports smells as masked' do
46
- rpt = Report.new
46
+ rpt = Report.new(Sniffer.new)
47
47
  @detector.report_on(rpt)
48
48
  rpt.length.should == 0
49
49
  rpt.num_masked_smells.should == 1
@@ -1,5 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
  require 'ostruct'
3
+ require 'reek/core_extras'
3
4
  require 'reek/method_context'
4
5
  require 'reek/smells/uncommunicative_name'
5
6
 
@@ -85,7 +86,7 @@ end
85
86
  describe UncommunicativeName, "several names" do
86
87
 
87
88
  it 'should report all bad names' do
88
- ruby = Source.from_s('class Oof; def y(x) @z = x end end')
89
+ ruby = 'class Oof; def y(x) @z = x end end'.sniff
89
90
  ruby.should reek_of(:UncommunicativeName, /'x'/)
90
91
  ruby.should reek_of(:UncommunicativeName, /'y'/)
91
92
  ruby.should reek_of(:UncommunicativeName, /'@z'/)
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ include Reek
4
+
5
+ describe Sniffer do
6
+ it 'detects smells in a file' do
7
+ dirty_file = Dir['spec/samples/two_smelly_files/*.rb'][0]
8
+ File.new(dirty_file).sniff.should be_smelly
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ class Clean
2
+ def assign
3
+ puts @sub.title
4
+ @sub.map {|para| para.name }
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ class Dirty
2
+ def a
3
+ puts @s.title
4
+ @s.map {|x| x.each {|key| key += 3}}
5
+ puts @s.title
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ ---
2
+ Duplication:
3
+ enabled: false
4
+ UncommunicativeName:
5
+ enabled: false
@@ -0,0 +1,6 @@
1
+ class Clean
2
+ def assign
3
+ puts @sub.title
4
+ @sub.map {|para| para.name }
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class Clean
2
+ def assign
3
+ puts @sub.title
4
+ @sub.map {|para| para.name }
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class Clean
2
+ def assign
3
+ puts @sub.title
4
+ @sub.map {|para| para.name }
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ class Dirty
2
+ def a
3
+ puts @s.title
4
+ @s.map {|x| x.each {|key| key += 3}}
5
+ puts @s.title
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class Dirty
2
+ def a
3
+ puts @s.title
4
+ @s.map {|x| x.each {|key| key += 3}}
5
+ puts @s.title
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ ---
2
+ Duplication:
3
+ enabled: false
4
+ NestedIterators:
5
+ enabled: false
6
+ UncommunicativeName:
7
+ enabled: false
@@ -0,0 +1,6 @@
1
+ class Clean
2
+ def assign
3
+ puts @sub.title
4
+ @sub.map {|para| para.name }
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class Clean
2
+ def assign
3
+ puts @sub.title
4
+ @sub.map {|para| para.name }
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class Clean
2
+ def assign
3
+ puts @sub.title
4
+ @sub.map {|para| para.name }
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ class Dirty
2
+ def a
3
+ puts @s.title
4
+ @s.map {|x| x.each {|key| key += 3}}
5
+ puts @s.title
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class Dirty
2
+ def a
3
+ puts @s.title
4
+ @s.map {|x| x.each {|key| key += 3}}
5
+ puts @s.title
6
+ end
7
+ end
@@ -1,8 +1,12 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper.rb'
2
2
 
3
+ require 'reek/report'
4
+
5
+ include Reek
6
+
3
7
  describe 'sample gem source code' do
4
8
  it "reports the correct smells in inline.rb" do
5
- ruby = File.new("#{SAMPLES_DIR}/inline.rb").to_source
9
+ ruby = File.new("#{SAMPLES_DIR}/inline.rb").sniff
6
10
  ruby.should reek_of(:ControlCouple, /Inline::C#parse_signature/, /raw/)
7
11
  ruby.should reek_of(:ControlCouple, /Module#inline/, /options/)
8
12
  ruby.should reek_of(:Duplication, /Inline::C#build/, /\(\$\?\ == 0\)/)
@@ -35,6 +39,6 @@ describe 'sample gem source code' do
35
39
  ruby.should reek_of(:UncommunicativeName, /Inline::C#module_name/, /'x'/)
36
40
  ruby.should reek_of(:UncommunicativeName, /Inline::C#parse_signature/, /'x'/)
37
41
  ruby.should reek_of(:UtilityFunction, /Inline::C#strip_comments/)
38
- ruby.report.should have_at_most(32).smells
42
+ Report.new(ruby).length.should == 32
39
43
  end
40
44
  end
@@ -1,8 +1,12 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper.rb'
2
2
 
3
+ require 'reek/report'
4
+
5
+ include Reek
6
+
3
7
  describe 'sample gem source code' do
4
8
  it "reports the correct smells in optparse.rb" do
5
- ruby = File.new("#{SAMPLES_DIR}/optparse.rb").to_source
9
+ ruby = File.new("#{SAMPLES_DIR}/optparse.rb").sniff
6
10
  ruby.should reek_of(:ControlCouple, /OptionParser#List#accept/, /pat/)
7
11
  ruby.should reek_of(:ControlCouple, /OptionParser#List#update/, /lopts/)
8
12
  ruby.should reek_of(:ControlCouple, /OptionParser#List#update/, /sopts/)
@@ -103,6 +107,6 @@ describe 'sample gem source code' do
103
107
  ruby.should reek_of(:UncommunicativeName, /OptionParser#summarize/, /'l'/)
104
108
  ruby.should reek_of(:UncommunicativeName, /OptionParser#ver/, /'v'/)
105
109
  ruby.should reek_of(:UncommunicativeName, /block/, /'q'/)
106
- ruby.report.should have_at_most(117).smells
110
+ Report.new(ruby).length.should == 117
107
111
  end
108
112
  end
@@ -1,8 +1,12 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper.rb'
2
2
 
3
+ require 'reek/report'
4
+
5
+ include Reek
6
+
3
7
  describe 'sample gem source code' do
4
8
  it "reports the correct smells in redcloth.rb" do
5
- ruby = File.new("#{SAMPLES_DIR}/redcloth.rb").to_source
9
+ ruby = File.new("#{SAMPLES_DIR}/redcloth.rb").sniff
6
10
  ruby.should reek_of(:ControlCouple, /RedCloth#blocks\/block/, /deep_code/)
7
11
  ruby.should reek_of(:ControlCouple, /RedCloth#check_refs/, /text/)
8
12
  ruby.should reek_of(:ControlCouple, /RedCloth#pba/, /text_in/)
@@ -96,6 +100,6 @@ describe 'sample gem source code' do
96
100
  ruby.should reek_of(:UtilityFunction, /RedCloth#incoming_entities/)
97
101
  ruby.should reek_of(:UtilityFunction, /RedCloth#no_textile/)
98
102
  ruby.should reek_of(:UtilityFunction, /RedCloth#v_align/)
99
- ruby.report.should have_at_most(93).smells
103
+ Report.new(ruby).length.should == 93
100
104
  end
101
105
  end
data/tasks/test.rake CHANGED
@@ -35,6 +35,8 @@ namespace 'test' do
35
35
  task 'all' => ['test:spec', 'test:slow', 'test:features']
36
36
  end
37
37
 
38
+ task 'clobber_rcov' => 'test:clobber_rcov'
39
+
38
40
  desc 'synonym for test:spec'
39
41
  task 'spec' => 'test:spec'
40
42
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kevinrutherford-reek
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3.9
4
+ version: 1.1.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Rutherford
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-06 00:00:00 -07:00
12
+ date: 2009-07-15 00:00:00 -07:00
13
13
  default_executable: reek
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -51,9 +51,11 @@ extensions: []
51
51
 
52
52
  extra_rdoc_files:
53
53
  - History.txt
54
+ - License.txt
54
55
  - README.txt
55
56
  files:
56
57
  - History.txt
58
+ - License.txt
57
59
  - README.txt
58
60
  - Rakefile
59
61
  - bin/reek
@@ -72,6 +74,7 @@ files:
72
74
  - lib/reek/code_context.rb
73
75
  - lib/reek/code_parser.rb
74
76
  - lib/reek/config_file.rb
77
+ - lib/reek/core_extras.rb
75
78
  - lib/reek/detector_stack.rb
76
79
  - lib/reek/exceptions.reek
77
80
  - lib/reek/if_context.rb
@@ -116,6 +119,9 @@ files:
116
119
  - spec/reek/object_source_spec.rb
117
120
  - spec/reek/options_spec.rb
118
121
  - spec/reek/report_spec.rb
122
+ - spec/reek/should_reek_of_spec.rb
123
+ - spec/reek/should_reek_only_of_spec.rb
124
+ - spec/reek/should_reek_spec.rb
119
125
  - spec/reek/singleton_method_context_spec.rb
120
126
  - spec/reek/smell_warning_spec.rb
121
127
  - spec/reek/smells/control_couple_spec.rb
@@ -128,7 +134,16 @@ files:
128
134
  - spec/reek/smells/smell_detector_spec.rb
129
135
  - spec/reek/smells/uncommunicative_name_spec.rb
130
136
  - spec/reek/smells/utility_function_spec.rb
131
- - spec/reek/spec_spec.rb
137
+ - spec/reek/sniffer_spec.rb
138
+ - spec/samples/all_but_one_masked/clean_one.rb
139
+ - spec/samples/all_but_one_masked/dirty.rb
140
+ - spec/samples/all_but_one_masked/masked.reek
141
+ - spec/samples/clean_due_to_masking/clean_one.rb
142
+ - spec/samples/clean_due_to_masking/clean_three.rb
143
+ - spec/samples/clean_due_to_masking/clean_two.rb
144
+ - spec/samples/clean_due_to_masking/dirty_one.rb
145
+ - spec/samples/clean_due_to_masking/dirty_two.rb
146
+ - spec/samples/clean_due_to_masking/masked.reek
132
147
  - spec/samples/corrupt_config_file/corrupt.reek
133
148
  - spec/samples/corrupt_config_file/dirty.rb
134
149
  - spec/samples/empty_config_file/dirty.rb
@@ -136,6 +151,11 @@ files:
136
151
  - spec/samples/inline.rb
137
152
  - spec/samples/masked/dirty.rb
138
153
  - spec/samples/masked/masked.reek
154
+ - spec/samples/mixed_results/clean_one.rb
155
+ - spec/samples/mixed_results/clean_three.rb
156
+ - spec/samples/mixed_results/clean_two.rb
157
+ - spec/samples/mixed_results/dirty_one.rb
158
+ - spec/samples/mixed_results/dirty_two.rb
139
159
  - spec/samples/optparse.rb
140
160
  - spec/samples/redcloth.rb
141
161
  - spec/samples/three_clean_files/clean_one.rb
@@ -147,7 +167,6 @@ files:
147
167
  - spec/slow/optparse_spec.rb
148
168
  - spec/slow/redcloth_spec.rb
149
169
  - spec/slow/reek_source_spec.rb
150
- - spec/slow/source_list_spec.rb
151
170
  - spec/spec.opts
152
171
  - spec/spec_helper.rb
153
172
  - tasks/reek.rake
@@ -1,40 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- require 'reek/source'
4
-
5
- include Reek
6
-
7
- describe SourceList, 'from_pathlist' do
8
-
9
- describe 'with no smells in any source' do
10
- before :each do
11
- @src = Dir['lib/reek/*.rb'].to_source
12
- end
13
-
14
- it 'reports no smells' do
15
- @src.report.length.should == 0
16
- end
17
-
18
- it 'is empty' do
19
- @src.report.should be_empty
20
- end
21
- end
22
-
23
- describe 'with smells in one source' do
24
- before :each do
25
- @src = Source.from_pathlist(["#{SAMPLES_DIR}/inline.rb", 'lib/reek.rb'])
26
- end
27
-
28
- it 'reports some smells in the samples' do
29
- @src.report.should have_at_least(30).smells
30
- end
31
-
32
- it 'is smelly' do
33
- @src.should be_smelly
34
- end
35
-
36
- it 'reports an UncommunicativeName' do
37
- @src.report.any? {|warning| warning.report =~ /Uncommunicative Name/}.should be_true
38
- end
39
- end
40
- end