reek 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +44 -4
- data/License.txt +20 -0
- data/README.rdoc +83 -0
- data/Rakefile +0 -1
- data/bin/reek +3 -11
- data/config/defaults.reek +20 -1
- data/features/masking_smells.feature +111 -0
- data/features/options.feature +49 -0
- data/features/reports.feature +90 -0
- data/features/samples.feature +284 -0
- data/features/stdin.feature +43 -0
- data/features/step_definitions/reek_steps.rb +35 -0
- data/features/support/env.rb +38 -0
- data/lib/reek.rb +1 -1
- data/lib/reek/adapters/application.rb +47 -0
- data/lib/reek/adapters/config_file.rb +31 -0
- data/lib/reek/adapters/core_extras.rb +72 -0
- data/lib/reek/{object_source.rb → adapters/object_source.rb} +15 -19
- data/lib/reek/{rake_task.rb → adapters/rake_task.rb} +2 -2
- data/lib/reek/adapters/report.rb +91 -0
- data/lib/reek/adapters/source.rb +53 -0
- data/lib/reek/{spec.rb → adapters/spec.rb} +45 -60
- data/lib/reek/block_context.rb +1 -1
- data/lib/reek/class_context.rb +26 -6
- data/lib/reek/code_context.rb +8 -0
- data/lib/reek/code_parser.rb +82 -39
- data/lib/reek/command_line.rb +85 -0
- data/lib/reek/configuration.rb +51 -0
- data/lib/reek/detector_stack.rb +39 -0
- data/lib/reek/exceptions.reek +8 -1
- data/lib/reek/method_context.rb +53 -11
- data/lib/reek/module_context.rb +1 -2
- data/lib/reek/name.rb +8 -2
- data/lib/reek/sexp_formatter.rb +2 -0
- data/lib/reek/smell_warning.rb +26 -8
- data/lib/reek/smells/control_couple.rb +8 -4
- data/lib/reek/smells/data_clump.rb +88 -0
- data/lib/reek/smells/duplication.rb +11 -9
- data/lib/reek/smells/feature_envy.rb +3 -4
- data/lib/reek/smells/large_class.rb +17 -17
- data/lib/reek/smells/long_method.rb +10 -8
- data/lib/reek/smells/long_parameter_list.rb +16 -10
- data/lib/reek/smells/long_yield_list.rb +1 -1
- data/lib/reek/smells/nested_iterators.rb +3 -3
- data/lib/reek/smells/simulated_polymorphism.rb +58 -0
- data/lib/reek/smells/smell_detector.rb +94 -27
- data/lib/reek/smells/uncommunicative_name.rb +23 -23
- data/lib/reek/smells/utility_function.rb +27 -11
- data/lib/reek/sniffer.rb +183 -0
- data/reek.gemspec +5 -5
- data/spec/quality/reek_source_spec.rb +15 -0
- data/spec/reek/adapters/report_spec.rb +49 -0
- data/spec/reek/adapters/should_reek_of_spec.rb +108 -0
- data/spec/reek/adapters/should_reek_only_of_spec.rb +87 -0
- data/spec/reek/adapters/should_reek_spec.rb +92 -0
- data/spec/reek/block_context_spec.rb +7 -1
- data/spec/reek/class_context_spec.rb +39 -16
- data/spec/reek/code_context_spec.rb +7 -7
- data/spec/reek/code_parser_spec.rb +6 -1
- data/spec/reek/config_spec.rb +3 -3
- data/spec/reek/configuration_spec.rb +12 -0
- data/spec/reek/method_context_spec.rb +2 -2
- data/spec/reek/name_spec.rb +24 -0
- data/spec/reek/object_source_spec.rb +23 -0
- data/spec/reek/singleton_method_context_spec.rb +2 -2
- data/spec/reek/smell_warning_spec.rb +53 -0
- data/spec/reek/smells/data_clump_spec.rb +87 -0
- data/spec/reek/smells/duplication_spec.rb +13 -17
- data/spec/reek/smells/feature_envy_spec.rb +23 -28
- data/spec/reek/smells/large_class_spec.rb +109 -34
- data/spec/reek/smells/long_method_spec.rb +140 -3
- data/spec/reek/smells/long_parameter_list_spec.rb +1 -2
- data/spec/reek/smells/simulated_polymorphism_spec.rb +50 -0
- data/spec/reek/smells/smell_detector_spec.rb +53 -0
- data/spec/reek/smells/uncommunicative_name_spec.rb +20 -7
- data/spec/reek/smells/utility_function_spec.rb +76 -67
- data/spec/reek/sniffer_spec.rb +10 -0
- data/spec/samples/all_but_one_masked/clean_one.rb +6 -0
- data/spec/samples/all_but_one_masked/dirty.rb +7 -0
- data/spec/samples/all_but_one_masked/masked.reek +5 -0
- data/spec/samples/clean_due_to_masking/clean_one.rb +6 -0
- data/spec/samples/clean_due_to_masking/clean_three.rb +6 -0
- data/spec/samples/clean_due_to_masking/clean_two.rb +6 -0
- data/spec/samples/clean_due_to_masking/dirty_one.rb +7 -0
- data/spec/samples/clean_due_to_masking/dirty_two.rb +7 -0
- data/spec/samples/clean_due_to_masking/masked.reek +7 -0
- data/spec/samples/corrupt_config_file/corrupt.reek +1 -0
- data/spec/samples/corrupt_config_file/dirty.rb +7 -0
- data/spec/samples/empty_config_file/dirty.rb +7 -0
- data/spec/samples/empty_config_file/empty.reek +0 -0
- data/spec/samples/exceptions.reek +4 -0
- data/spec/{slow/samples → samples}/inline.rb +0 -0
- data/spec/samples/masked/dirty.rb +7 -0
- data/spec/samples/masked/masked.reek +3 -0
- data/spec/samples/mixed_results/clean_one.rb +6 -0
- data/spec/samples/mixed_results/clean_three.rb +6 -0
- data/spec/samples/mixed_results/clean_two.rb +6 -0
- data/spec/samples/mixed_results/dirty_one.rb +7 -0
- data/spec/samples/mixed_results/dirty_two.rb +7 -0
- data/spec/samples/not_quite_masked/dirty.rb +8 -0
- data/spec/samples/not_quite_masked/masked.reek +5 -0
- data/spec/{slow/samples → samples}/optparse.rb +0 -0
- data/spec/samples/overrides/masked/dirty.rb +7 -0
- data/spec/samples/overrides/masked/lower.reek +5 -0
- data/spec/samples/overrides/upper.reek +5 -0
- data/spec/{slow/samples → samples}/redcloth.rb +0 -0
- data/spec/samples/three_clean_files/clean_one.rb +6 -0
- data/spec/samples/three_clean_files/clean_three.rb +6 -0
- data/spec/samples/three_clean_files/clean_two.rb +6 -0
- data/spec/samples/two_smelly_files/dirty_one.rb +7 -0
- data/spec/samples/two_smelly_files/dirty_two.rb +7 -0
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +4 -4
- data/tasks/reek.rake +8 -5
- data/tasks/test.rake +51 -0
- metadata +75 -25
- data/README.txt +0 -6
- data/lib/reek/options.rb +0 -92
- data/lib/reek/report.rb +0 -81
- data/lib/reek/smells/smells.rb +0 -81
- data/lib/reek/source.rb +0 -127
- data/spec/reek/options_spec.rb +0 -13
- data/spec/reek/report_spec.rb +0 -48
- data/spec/reek/smells/smell_spec.rb +0 -24
- data/spec/slow/inline_spec.rb +0 -43
- data/spec/slow/optparse_spec.rb +0 -108
- data/spec/slow/redcloth_spec.rb +0 -101
- data/spec/slow/reek_source_spec.rb +0 -20
- data/spec/slow/script_spec.rb +0 -55
- data/spec/slow/source_list_spec.rb +0 -40
- data/tasks/rspec.rake +0 -21
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
-
|
3
|
-
require 'reek/smells/smells'
|
4
|
-
|
5
|
-
include Reek
|
6
|
-
|
7
|
-
describe SmellWarning, ' in comparisons' do
|
8
|
-
before :each do
|
9
|
-
@first = SmellWarning.new(Smells::FeatureEnvy.new, "self", "self")
|
10
|
-
@second = SmellWarning.new(Smells::FeatureEnvy.new, "self", "self")
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should hash equal when the smell is the same' do
|
14
|
-
@first.hash.should == @second.hash
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should compare equal when the smell is the same' do
|
18
|
-
@first.should == @second
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should compare equal when using <=>' do
|
22
|
-
(@first <=> @second).should == 0
|
23
|
-
end
|
24
|
-
end
|
data/spec/slow/inline_spec.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
-
|
3
|
-
describe 'sample gem source code' do
|
4
|
-
it "reports the correct smells in inline.rb" do
|
5
|
-
ruby = File.new("#{SAMPLES_DIR}/inline.rb").to_source
|
6
|
-
ruby.should reek_of(:ControlCouple, /Inline::C#parse_signature/, /raw/)
|
7
|
-
ruby.should reek_of(:ControlCouple, /Module#inline/, /options/)
|
8
|
-
ruby.should reek_of(:Duplication, /Inline::C#build/, /\(\$\?\ == 0\)/)
|
9
|
-
ruby.should reek_of(:Duplication, /Inline::C#build/, /Inline.directory/)
|
10
|
-
ruby.should reek_of(:Duplication, /Inline::C#build/, /io.puts/)
|
11
|
-
ruby.should reek_of(:Duplication, /Inline::C#build/, /io.puts\("#endif"\)/)
|
12
|
-
ruby.should reek_of(:Duplication, /Inline::C#build/, /io.puts\("#ifdef __cplusplus"\)/)
|
13
|
-
ruby.should reek_of(:Duplication, /Inline::C#build/, /module_name/)
|
14
|
-
ruby.should reek_of(:Duplication, /Inline::C#build/, /warn\("Output:\\n\#\{result\}"\)/)
|
15
|
-
ruby.should reek_of(:Duplication, /Inline::C#crap_for_windoze/, /Config::CONFIG\["libdir"\]/)
|
16
|
-
ruby.should reek_of(:Duplication, /Inline::C#generate/, /result.sub!\(\/\\A\\n\/, ""\)/)
|
17
|
-
ruby.should reek_of(:Duplication, /Inline::C#generate/, /signature\["args"\]/)
|
18
|
-
ruby.should reek_of(:Duplication, /Inline::C#generate/, /signature\["args"\].map/)
|
19
|
-
ruby.should reek_of(:Duplication, /Inline::C#initialize/, /stack.empty?/)
|
20
|
-
ruby.should reek_of(:Duplication, /Inline::C#load/, /so_name/)
|
21
|
-
ruby.should reek_of(:Duplication, /Inline::self.rootdir/, /env.nil?/)
|
22
|
-
ruby.should reek_of(:Duplication, /Module#inline/, /Inline.const_get\(lang\)/)
|
23
|
-
ruby.should reek_of(:FeatureEnvy, /Inline::C#strip_comments/, /src/)
|
24
|
-
ruby.should reek_of(:LargeClass, /Inline::C/, /instance variables/)
|
25
|
-
ruby.should reek_of(:LongMethod, /File#self.write_with_backup/)
|
26
|
-
ruby.should reek_of(:LongMethod, /Inline::C#build/)
|
27
|
-
ruby.should reek_of(:LongMethod, /Inline::C#generate/)
|
28
|
-
ruby.should reek_of(:LongMethod, /Inline::C#load_cache/)
|
29
|
-
ruby.should reek_of(:LongMethod, /Inline::C#module_name/)
|
30
|
-
ruby.should reek_of(:LongMethod, /Inline::C#parse_signature/)
|
31
|
-
ruby.should reek_of(:LongMethod, /Inline::self.rootdir/)
|
32
|
-
ruby.should reek_of(:LongMethod, /Module#inline/)
|
33
|
-
ruby.should reek_of(:NestedIterators, /Inline::C#build/)
|
34
|
-
ruby.should reek_of(:UncommunicativeName, /Inline::C#build/, /'t'/)
|
35
|
-
ruby.should reek_of(:UncommunicativeName, /Inline::C#build/, /'n'/)
|
36
|
-
ruby.should reek_of(:UncommunicativeName, /Inline::C#c/, /'c'/)
|
37
|
-
ruby.should reek_of(:UncommunicativeName, /Inline::C#module_name/, /'m'/)
|
38
|
-
ruby.should reek_of(:UncommunicativeName, /Inline::C#module_name/, /'x'/)
|
39
|
-
ruby.should reek_of(:UncommunicativeName, /Inline::C#parse_signature/, /'x'/)
|
40
|
-
ruby.should reek_of(:UtilityFunction, /Inline::C#strip_comments/)
|
41
|
-
ruby.report.should have_at_most(35).smells
|
42
|
-
end
|
43
|
-
end
|
data/spec/slow/optparse_spec.rb
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
-
|
3
|
-
describe 'sample gem source code' do
|
4
|
-
it "reports the correct smells in optparse.rb" do
|
5
|
-
ruby = File.new("#{SAMPLES_DIR}/optparse.rb").to_source
|
6
|
-
ruby.should reek_of(:ControlCouple, /OptionParser#List#accept/, /pat/)
|
7
|
-
ruby.should reek_of(:ControlCouple, /OptionParser#List#update/, /lopts/)
|
8
|
-
ruby.should reek_of(:ControlCouple, /OptionParser#List#update/, /sopts/)
|
9
|
-
ruby.should reek_of(:ControlCouple, /OptionParser#ParseError#set_option/, /eq/)
|
10
|
-
ruby.should reek_of(:ControlCouple, /OptionParser#Switch#NoArgument#parse/, /arg/)
|
11
|
-
ruby.should reek_of(:ControlCouple, /OptionParser#Switch#OptionalArgument#parse/, /arg/)
|
12
|
-
ruby.should reek_of(:ControlCouple, /OptionParser#Switch#RequiredArgument#parse/, /arg/)
|
13
|
-
ruby.should reek_of(:ControlCouple, /OptionParser#block/, /o/)
|
14
|
-
ruby.should reek_of(:ControlCouple, /OptionParser#block/, /s/)
|
15
|
-
ruby.should reek_of(:ControlCouple, /OptionParser#block\/block/, /pkg/)
|
16
|
-
ruby.should reek_of(:ControlCouple, /OptionParser#getopts\/block/, /val/)
|
17
|
-
ruby.should reek_of(:ControlCouple, /OptionParser#parse_in_order/, /setter/)
|
18
|
-
ruby.should reek_of(:Duplication, /OptionParser#Completion::complete/, /candidates.size/)
|
19
|
-
ruby.should reek_of(:Duplication, /OptionParser#Completion::complete/, /k.id2name/)
|
20
|
-
ruby.should reek_of(:Duplication, /OptionParser#Switch#parse_arg/, /s.length/)
|
21
|
-
ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /left.collect \{ \|s\| s\.length \}\.max/)
|
22
|
-
ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /left.collect \{ \|s\| s\.length \}\.max\.to_i/)
|
23
|
-
ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /\(indent \+ l\)/)
|
24
|
-
ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /left.collect/)
|
25
|
-
ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /left.shift/)
|
26
|
-
ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /left\[-1\]/)
|
27
|
-
ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /s.length/)
|
28
|
-
ruby.should reek_of(:Duplication, /OptionParser#getopts/, /result\[opt\] = false/)
|
29
|
-
ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /default_style.guess\(arg = a\)/)
|
30
|
-
ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /\(long << o = q.downcase\)/)
|
31
|
-
ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /notwice\(a \? \(Object\) : \(TrueClass\), klass, "type"\)/)
|
32
|
-
ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /notwice\(NilClass, klass, "type"\)/)
|
33
|
-
ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /pattern.method\(:convert\)/)
|
34
|
-
ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /pattern.method\(:convert\).to_proc/)
|
35
|
-
ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /pattern.respond_to\?\(:convert\)/)
|
36
|
-
ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /q.downcase/)
|
37
|
-
ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /search\(:atype, o\)/)
|
38
|
-
ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /search\(:atype, FalseClass\)/)
|
39
|
-
ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /\(sdesc << "-\#\{q\}"\)/)
|
40
|
-
ruby.should reek_of(:Duplication, /OptionParser#order/, /argv\[0\]/)
|
41
|
-
ruby.should reek_of(:Duplication, /OptionParser#parse/, /argv\[0\]/)
|
42
|
-
ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /\$\!.set_option\(arg, true\)/)
|
43
|
-
ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /cb.call\(val\)/)
|
44
|
-
ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /setter.call\(sw.switch_name, val\)/)
|
45
|
-
ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /sw.block/)
|
46
|
-
ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /sw.switch_name/)
|
47
|
-
ruby.should reek_of(:Duplication, /OptionParser#permute/, /argv\[0\]/)
|
48
|
-
ruby.should reek_of(:FeatureEnvy, /OptionParser#Completion::complete/, /candidates/)
|
49
|
-
ruby.should reek_of(:FeatureEnvy, /OptionParser#List#accept/, /pat/)
|
50
|
-
ruby.should reek_of(:FeatureEnvy, /OptionParser#Switch#summarize/, /left/)
|
51
|
-
ruby.should reek_of(:FeatureEnvy, /OptionParser#order/, /argv/)
|
52
|
-
ruby.should reek_of(:FeatureEnvy, /OptionParser#parse/, /argv/)
|
53
|
-
ruby.should reek_of(:FeatureEnvy, /OptionParser#permute/, /argv/)
|
54
|
-
ruby.should reek_of(:LargeClass, /OptionParser/)
|
55
|
-
ruby.should reek_of(:LongMethod, /OptionParser#Completion::complete/)
|
56
|
-
ruby.should reek_of(:LongMethod, /OptionParser#List#update/)
|
57
|
-
ruby.should reek_of(:LongMethod, /OptionParser#Switch#parse_arg/)
|
58
|
-
ruby.should reek_of(:LongMethod, /OptionParser#Switch#summarize/)
|
59
|
-
ruby.should reek_of(:LongMethod, /OptionParser#getopts/)
|
60
|
-
ruby.should reek_of(:LongMethod, /OptionParser#make_switch/)
|
61
|
-
ruby.should reek_of(:LongMethod, /OptionParser#parse_in_order/)
|
62
|
-
ruby.should reek_of(:LongParameterList, /OptionParser#List#complete/)
|
63
|
-
ruby.should reek_of(:LongParameterList, /OptionParser#List#update/)
|
64
|
-
ruby.should reek_of(:LongParameterList, /OptionParser#Switch#initialize/)
|
65
|
-
ruby.should reek_of(:LongParameterList, /OptionParser#Switch#summarize/)
|
66
|
-
ruby.should reek_of(:LongParameterList, /OptionParser#complete/)
|
67
|
-
ruby.should reek_of(:LongParameterList, /OptionParser#summarize/)
|
68
|
-
ruby.should reek_of(:NestedIterators, /OptionParser#CompletingHash#match/)
|
69
|
-
ruby.should reek_of(:NestedIterators, /OptionParser#Switch#summarize/)
|
70
|
-
ruby.should reek_of(:NestedIterators, /OptionParser#block/)
|
71
|
-
ruby.should reek_of(:NestedIterators, /OptionParser#complete/)
|
72
|
-
ruby.should reek_of(:NestedIterators, /OptionParser#make_switch/)
|
73
|
-
ruby.should reek_of(:NestedIterators, /OptionParser#make_switch/)
|
74
|
-
ruby.should reek_of(:NestedIterators, /OptionParser#parse_in_order/)
|
75
|
-
ruby.should reek_of(:NestedIterators, /OptionParser#parse_in_order/)
|
76
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#Completion::complete/, /'k'/)
|
77
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#Completion::complete/, /'v'/)
|
78
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#List#accept/, /'t'/)
|
79
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#List#reject/, /'t'/)
|
80
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#List#update/, /'o'/)
|
81
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#add_banner/, /'s'/)
|
82
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#parse_arg/, /'m'/)
|
83
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#parse_arg/, /'s'/)
|
84
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#self.guess/, /'t'/)
|
85
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#self.incompatible_argument_styles/, /'t'/)
|
86
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#summarize/, /'l'/)
|
87
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#summarize/, /'r'/)
|
88
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#summarize/, /'s'/)
|
89
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'f'/)
|
90
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'k'/)
|
91
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'o'/)
|
92
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'s'/)
|
93
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'v'/)
|
94
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#load/, /'s'/)
|
95
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'a'/)
|
96
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'n'/)
|
97
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'o'/)
|
98
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'q'/)
|
99
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'s'/)
|
100
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'c'/)
|
101
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'v'/)
|
102
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#search/, /'k'/)
|
103
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#summarize/, /'l'/)
|
104
|
-
ruby.should reek_of(:UncommunicativeName, /OptionParser#ver/, /'v'/)
|
105
|
-
ruby.should reek_of(:UncommunicativeName, /block/, /'q'/)
|
106
|
-
ruby.report.should have_at_most(116).smells
|
107
|
-
end
|
108
|
-
end
|
data/spec/slow/redcloth_spec.rb
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
-
|
3
|
-
describe 'sample gem source code' do
|
4
|
-
it "reports the correct smells in redcloth.rb" do
|
5
|
-
ruby = File.new("#{SAMPLES_DIR}/redcloth.rb").to_source
|
6
|
-
ruby.should reek_of(:ControlCouple, /RedCloth#blocks\/block/, /deep_code/)
|
7
|
-
ruby.should reek_of(:ControlCouple, /RedCloth#check_refs/, /text/)
|
8
|
-
ruby.should reek_of(:ControlCouple, /RedCloth#pba/, /text_in/)
|
9
|
-
ruby.should reek_of(:ControlCouple, /RedCloth#textile_bq/, /atts/)
|
10
|
-
ruby.should reek_of(:ControlCouple, /RedCloth#textile_bq/, /cite/)
|
11
|
-
ruby.should reek_of(:ControlCouple, /RedCloth#textile_fn_/, /atts/)
|
12
|
-
ruby.should reek_of(:ControlCouple, /RedCloth#textile_p/, /atts/)
|
13
|
-
ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /depth.last/)
|
14
|
-
ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /depth.last.length/)
|
15
|
-
ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /depth\[i\]/)
|
16
|
-
ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /\(line_id - 1\)/)
|
17
|
-
ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /lines\[\(line_id - 1\)\]/)
|
18
|
-
ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /tl.length/)
|
19
|
-
ruby.should reek_of(:Duplication, /RedCloth#clean_html/, /tags\[tag\]/)
|
20
|
-
ruby.should reek_of(:Duplication, /RedCloth#pba/, /\$1.length/)
|
21
|
-
ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /@pre_list.last/)
|
22
|
-
ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /\(@pre_list.last << line\)/)
|
23
|
-
ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /\(codepre - used_offtags.length\)/)
|
24
|
-
ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /\(\(codepre - used_offtags.length\) > 0\)/)
|
25
|
-
ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /codepre.zero?/)
|
26
|
-
ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /htmlesc\(line, :NoQuotes\)/)
|
27
|
-
ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /used_offtags.length/)
|
28
|
-
ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /used_offtags\["notextile"\]/)
|
29
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#block_markdown_atx/, /text/)
|
30
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#block_markdown_rule/, /text/)
|
31
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#block_markdown_setext/, /text/)
|
32
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#block_textile_lists/, /depth/)
|
33
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#clean_html/, /raw/)
|
34
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#clean_html/, /tags/)
|
35
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#clean_white_space/, /text/)
|
36
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#flush_left/, /indt/)
|
37
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#flush_left/, /text/)
|
38
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#footnote_ref/, /text/)
|
39
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#htmlesc/, /str/)
|
40
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#incoming_entities/, /text/)
|
41
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#no_textile/, /text/)
|
42
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#pba/, /style/)
|
43
|
-
ruby.should reek_of(:FeatureEnvy, /RedCloth#pba/, /text/)
|
44
|
-
ruby.should reek_of(:LargeClass, /RedCloth/)
|
45
|
-
ruby.should reek_of(:LongMethod, /RedCloth#block_markdown_bq/)
|
46
|
-
ruby.should reek_of(:LongMethod, /RedCloth#block_textile_lists/)
|
47
|
-
ruby.should reek_of(:LongMethod, /RedCloth#block_textile_table/)
|
48
|
-
ruby.should reek_of(:LongMethod, /RedCloth#blocks/)
|
49
|
-
ruby.should reek_of(:LongMethod, /RedCloth#clean_html/)
|
50
|
-
ruby.should reek_of(:LongMethod, /RedCloth#clean_white_space/)
|
51
|
-
ruby.should reek_of(:LongMethod, /RedCloth#glyphs_textile/)
|
52
|
-
ruby.should reek_of(:LongMethod, /RedCloth#inline_markdown_link/)
|
53
|
-
ruby.should reek_of(:LongMethod, /RedCloth#inline_markdown_reflink/)
|
54
|
-
ruby.should reek_of(:LongMethod, /RedCloth#inline_textile_image/)
|
55
|
-
ruby.should reek_of(:LongMethod, /RedCloth#inline_textile_link/)
|
56
|
-
ruby.should reek_of(:LongMethod, /RedCloth#inline_textile_span/)
|
57
|
-
ruby.should reek_of(:LongMethod, /RedCloth#pba/)
|
58
|
-
ruby.should reek_of(:LongMethod, /RedCloth#rip_offtags/)
|
59
|
-
ruby.should reek_of(:LongMethod, /RedCloth#to_html/)
|
60
|
-
ruby.should reek_of(:LongParameterList, /RedCloth#textile_bq/)
|
61
|
-
ruby.should reek_of(:LongParameterList, /RedCloth#textile_fn_/)
|
62
|
-
ruby.should reek_of(:LongParameterList, /RedCloth#textile_p/)
|
63
|
-
ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_lists/)
|
64
|
-
ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_lists/)
|
65
|
-
ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_table/)
|
66
|
-
ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_table/)
|
67
|
-
ruby.should reek_of(:NestedIterators, /RedCloth#blocks/)
|
68
|
-
ruby.should reek_of(:NestedIterators, /RedCloth#clean_html/)
|
69
|
-
ruby.should reek_of(:NestedIterators, /RedCloth#clean_html/)
|
70
|
-
ruby.should reek_of(:NestedIterators, /RedCloth#inline/)
|
71
|
-
ruby.should reek_of(:NestedIterators, /RedCloth#inline_textile_span/)
|
72
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#block/, /'a'/)
|
73
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#block/, /'b'/)
|
74
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#block_textile_lists/, /'i'/)
|
75
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#block_textile_lists/, /'v'/)
|
76
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#block_textile_table/, /'x'/)
|
77
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#clean_html/, /'q'/)
|
78
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#clean_html/, /'q2'/)
|
79
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#initialize/, /'r'/)
|
80
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_markdown_link/, /'m'/)
|
81
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_markdown_reflink/, /'m'/)
|
82
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_code/, /'m'/)
|
83
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_image/, /'m'/)
|
84
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_link/, /'m'/)
|
85
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_span/, /'m'/)
|
86
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#refs_markdown/, /'m'/)
|
87
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#refs_textile/, /'m'/)
|
88
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#retrieve/, /'i'/)
|
89
|
-
ruby.should reek_of(:UncommunicativeName, /RedCloth#retrieve/, /'r'/)
|
90
|
-
ruby.should reek_of(:UtilityFunction, /RedCloth#block_markdown_rule/)
|
91
|
-
ruby.should reek_of(:UtilityFunction, /RedCloth#clean_html/)
|
92
|
-
ruby.should reek_of(:UtilityFunction, /RedCloth#flush_left/)
|
93
|
-
ruby.should reek_of(:UtilityFunction, /RedCloth#footnote_ref/)
|
94
|
-
ruby.should reek_of(:UtilityFunction, /RedCloth#h_align/)
|
95
|
-
ruby.should reek_of(:UtilityFunction, /RedCloth#htmlesc/)
|
96
|
-
ruby.should reek_of(:UtilityFunction, /RedCloth#incoming_entities/)
|
97
|
-
ruby.should reek_of(:UtilityFunction, /RedCloth#no_textile/)
|
98
|
-
ruby.should reek_of(:UtilityFunction, /RedCloth#v_align/)
|
99
|
-
ruby.report.should have_at_most(93).smells
|
100
|
-
end
|
101
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
-
|
3
|
-
describe 'Reek source code:' do
|
4
|
-
Dir['lib/**/*.rb'].each do |path|
|
5
|
-
it "reports no smells in #{path}" do
|
6
|
-
File.new(path).should_not reek
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'reports no smells via the Dir matcher' do
|
11
|
-
Dir['lib/**/*.rb'].should_not reek
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'RakeTask' do
|
16
|
-
it 'should report no duplication' do
|
17
|
-
report = `rake reek`.split("\n")
|
18
|
-
report.length.should == 1
|
19
|
-
end
|
20
|
-
end
|
data/spec/slow/script_spec.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'reek'
|
2
|
-
|
3
|
-
describe 'version number' do
|
4
|
-
it 'should report the correct value' do
|
5
|
-
actual = `ruby -Ilib bin/reek --version`.split
|
6
|
-
$?.exitstatus.should == 0
|
7
|
-
actual[0].should == 'reek'
|
8
|
-
actual[1].should == Reek::VERSION
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'exit status', 'when reek is used incorrectly' do
|
13
|
-
it 'should return non-zero status on bad option' do
|
14
|
-
`ruby -Ilib bin/reek --no-such-option`
|
15
|
-
$?.exitstatus.should == 1
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should complain about missing file' do
|
19
|
-
`ruby -Ilib bin/reek nosuchfile.rb`
|
20
|
-
$?.exitstatus.should == 1
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should return non-zero status on missing argument' do
|
24
|
-
`ruby -Ilib bin/reek -f 2>/dev/null`
|
25
|
-
$?.exitstatus.should == 1
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'exit status', 'when reek is used correctly' do
|
30
|
-
it 'should return non-zero status when smells are reported' do
|
31
|
-
`echo "def x() 3; end" | ruby -Ilib bin/reek`
|
32
|
-
$?.exitstatus.should == 2
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should return zero status with no smells' do
|
36
|
-
`echo "def simple() @fred = 3 end" | ruby -Ilib bin/reek`
|
37
|
-
$?.exitstatus.should == 0
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe 'report format', 'with one source' do
|
42
|
-
it 'should output nothing with empty source' do
|
43
|
-
`echo "" | ruby -Ilib bin/reek`.should be_empty
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should output nothing when no smells' do
|
47
|
-
`echo "def simple() @fred = 3; end" | ruby -Ilib bin/reek`.should be_empty
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should not adorn the list of warnings' do
|
51
|
-
report = `echo "class Turn; def y() @x = 3; end end" | ruby -Ilib bin/reek`
|
52
|
-
report.split(/\n/).length.should == 2
|
53
|
-
report.should_not match(/\n\n/)
|
54
|
-
end
|
55
|
-
end
|
@@ -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
|
data/tasks/rspec.rake
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec'
|
2
|
-
require 'spec/rake/spectask'
|
3
|
-
|
4
|
-
namespace 'rspec' do
|
5
|
-
FAST = FileList['spec/reek/**/*_spec.rb']
|
6
|
-
SLOW = FileList['spec/slow/**/*_spec.rb']
|
7
|
-
|
8
|
-
Spec::Rake::SpecTask.new('fast') do |t|
|
9
|
-
t.spec_files = FAST
|
10
|
-
t.ruby_opts = ['-Ilib']
|
11
|
-
t.rcov = false
|
12
|
-
end
|
13
|
-
|
14
|
-
Spec::Rake::SpecTask.new('all') do |t|
|
15
|
-
t.spec_files = FAST + SLOW
|
16
|
-
t.rcov = false
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
desc 'runs the unit tests'
|
21
|
-
task 'spec' => 'rspec:fast'
|