reek 1.2.13 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.3
2
+
3
+ * (mvz) Use new ruby_parser 3 and friends
4
+ * (EmilRehnberg) Unused parameter smell added
5
+ * (dkubb) Fix problem with IrresponsibleModule flagging the same module twice
6
+
1
7
  == 1.2.13 (2012-12-07)
2
8
 
3
9
  * (mvz) Update to rspec2.
data/config/defaults.reek CHANGED
@@ -112,3 +112,6 @@ LongYieldList:
112
112
  exclude: []
113
113
 
114
114
  enabled: true
115
+ UnusedParameters:
116
+ exclude: *id001
117
+ enabled: true
@@ -9,12 +9,16 @@ Feature: The Reek API maintains backwards compatibility
9
9
  Then the exit status indicates smells
10
10
  And it reports:
11
11
  """
12
- spec/samples/demo/demo.rb -- 6 warnings:
12
+ spec/samples/demo/demo.rb -- 10 warnings:
13
13
  Dirty has no descriptive comment (IrresponsibleModule)
14
14
  Dirty#awful has 4 parameters (LongParameterList)
15
15
  Dirty#awful has boolean parameter 'log' (BooleanParameter)
16
16
  Dirty#awful has the parameter name 'x' (UncommunicativeParameterName)
17
17
  Dirty#awful has the parameter name 'y' (UncommunicativeParameterName)
18
18
  Dirty#awful has the variable name 'w' (UncommunicativeVariableName)
19
+ Dirty#awful has unused parameter 'log' (UnusedParameters)
20
+ Dirty#awful has unused parameter 'offset' (UnusedParameters)
21
+ Dirty#awful has unused parameter 'x' (UnusedParameters)
22
+ Dirty#awful has unused parameter 'y' (UnusedParameters)
19
23
 
20
24
  """
@@ -8,169 +8,181 @@ Feature: Basic smell detection
8
8
  Scenario: Correct smells from inline.rb
9
9
  When I run reek spec/samples/inline.rb
10
10
  Then the exit status indicates smells
11
- And it reports something like: spec/samples/inline.rb -- 41 warnings:
12
- And it reports something like: File has no descriptive comment (IrresponsibleModule)
13
- And it reports something like: Inline declares the class variable @@directory (ClassVariable)
14
- And it reports something like: Inline declares the class variable @@rootdir (ClassVariable)
15
- And it reports something like: Inline#self.rootdir calls env.nil? twice (DuplicateMethodCall)
16
- And it reports something like: Inline#self.rootdir has approx 8 statements (TooManyStatements)
17
- And it reports something like: Inline::C declares the class variable @@type_map (ClassVariable)
18
- And it reports something like: Inline::C has at least 13 instance variables (TooManyInstanceVariables)
19
- And it reports something like: Inline::C takes parameters [options, src] to 5 methods (DataClump)
20
- And it reports something like: Inline::C tests $DEBUG at least 7 times (RepeatedConditional)
21
- And it reports something like: Inline::C tests $TESTING at least 4 times (RepeatedConditional)
22
- And it reports something like: Inline::C tests @@type_map.has_key?(type) at least 3 times (RepeatedConditional)
23
- And it reports something like: Inline::C#build calls ($? == 0) twice (DuplicateMethodCall)
24
- And it reports something like: Inline::C#build calls Inline.directory 5 times (DuplicateMethodCall)
25
- And it reports something like: Inline::C#build calls io.puts 6 times (DuplicateMethodCall)
26
- And it reports something like: Inline::C#build calls io.puts("#endif") twice (DuplicateMethodCall)
27
- And it reports something like: Inline::C#build calls io.puts("#ifdef __cplusplus") twice (DuplicateMethodCall)
28
- And it reports something like: Inline::C#build calls module_name twice (DuplicateMethodCall)
29
- And it reports something like (pending): Inline::C#build calls warn("Output:\n#{result}") twice (DuplicateMethodCall)
30
- And it reports something like: Inline::C#build contains iterators nested 2 deep (NestedIterators)
31
- And it reports something like: Inline::C#build has approx 60 statements (TooManyStatements)
32
- And it reports something like: Inline::C#build has the variable name 'n' (UncommunicativeVariableName)
33
- And it reports something like: Inline::C#build has the variable name 't' (UncommunicativeVariableName)
34
- And it reports something like: Inline::C#c has the name 'c' (UncommunicativeMethodName)
35
- And it reports something like: Inline::C#crap_for_windoze calls Config::CONFIG["libdir"] twice (DuplicateMethodCall)
36
- And it reports something like: Inline::C#generate calls result.sub!(/\A\n/, "") twice (DuplicateMethodCall)
37
- And it reports something like: Inline::C#generate calls signature["args"] twice (DuplicateMethodCall)
38
- And it reports something like: Inline::C#generate calls signature["args"].map twice (DuplicateMethodCall)
39
- And it reports something like: Inline::C#generate has approx 32 statements (TooManyStatements)
40
- And it reports something like: Inline::C#initialize calls stack.empty? twice (DuplicateMethodCall)
41
- And it reports something like: Inline::C#load calls so_name twice (DuplicateMethodCall)
42
- And it reports something like: Inline::C#module_name has the variable name 'm' (UncommunicativeVariableName)
43
- And it reports something like: Inline::C#module_name has the variable name 'x' (UncommunicativeVariableName)
44
- And it reports something like: Inline::C#parse_signature has approx 15 statements (TooManyStatements)
45
- And it reports something like: Inline::C#parse_signature has boolean parameter 'raw' (BooleanParameter)
46
- And it reports something like: Inline::C#parse_signature has the variable name 'x' (UncommunicativeVariableName)
47
- And it reports something like: Inline::C#parse_signature is controlled by argument raw (ControlParameter)
48
- And it reports something like: Inline::C#strip_comments doesn't depend on instance state (UtilityFunction)
49
- And it reports something like: Inline::C#strip_comments refers to src more than self (FeatureEnvy)
50
- And it reports something like: Module#inline calls Inline.const_get(lang) twice (DuplicateMethodCall)
51
- And it reports something like: Module#inline has approx 11 statements (TooManyStatements)
52
- And it reports something like: Module#inline is controlled by argument options (ControlParameter)
11
+ And it reports:
12
+ """
13
+ spec/samples/inline.rb -- 41 warnings:
14
+ File has no descriptive comment (IrresponsibleModule)
15
+ Inline declares the class variable @@directory (ClassVariable)
16
+ Inline declares the class variable @@rootdir (ClassVariable)
17
+ Inline#self.rootdir calls env.nil? twice (DuplicateMethodCall)
18
+ Inline#self.rootdir has approx 8 statements (TooManyStatements)
19
+ Inline::C declares the class variable @@type_map (ClassVariable)
20
+ Inline::C has at least 13 instance variables (TooManyInstanceVariables)
21
+ Inline::C takes parameters [options, src] to 5 methods (DataClump)
22
+ Inline::C tests $DEBUG at least 7 times (RepeatedConditional)
23
+ Inline::C tests $TESTING at least 4 times (RepeatedConditional)
24
+ Inline::C tests @@type_map.has_key?(type) at least 3 times (RepeatedConditional)
25
+ Inline::C#build calls $?.!=(0) twice (DuplicateMethodCall)
26
+ Inline::C#build calls Inline.directory 5 times (DuplicateMethodCall)
27
+ Inline::C#build calls io.puts 6 times (DuplicateMethodCall)
28
+ Inline::C#build calls io.puts("#endif") twice (DuplicateMethodCall)
29
+ Inline::C#build calls io.puts("#ifdef __cplusplus") twice (DuplicateMethodCall)
30
+ Inline::C#build calls module_name twice (DuplicateMethodCall)
31
+ Inline::C#build calls warn("Output:\n#{result}") twice (DuplicateMethodCall)
32
+ Inline::C#build contains iterators nested 2 deep (NestedIterators)
33
+ Inline::C#build has approx 60 statements (TooManyStatements)
34
+ Inline::C#build has the variable name 'n' (UncommunicativeVariableName)
35
+ Inline::C#build has the variable name 't' (UncommunicativeVariableName)
36
+ Inline::C#c has the name 'c' (UncommunicativeMethodName)
37
+ Inline::C#crap_for_windoze calls Config::CONFIG["libdir"] twice (DuplicateMethodCall)
38
+ Inline::C#generate calls result.sub!(/\A\n/, "") twice (DuplicateMethodCall)
39
+ Inline::C#generate calls signature["args"] twice (DuplicateMethodCall)
40
+ Inline::C#generate calls signature["args"].map twice (DuplicateMethodCall)
41
+ Inline::C#generate has approx 32 statements (TooManyStatements)
42
+ Inline::C#initialize calls stack.empty? twice (DuplicateMethodCall)
43
+ Inline::C#load calls so_name twice (DuplicateMethodCall)
44
+ Inline::C#module_name has the variable name 'm' (UncommunicativeVariableName)
45
+ Inline::C#module_name has the variable name 'x' (UncommunicativeVariableName)
46
+ Inline::C#parse_signature has approx 15 statements (TooManyStatements)
47
+ Inline::C#parse_signature has boolean parameter 'raw' (BooleanParameter)
48
+ Inline::C#parse_signature has the variable name 'x' (UncommunicativeVariableName)
49
+ Inline::C#parse_signature is controlled by argument raw (ControlParameter)
50
+ Inline::C#strip_comments doesn't depend on instance state (UtilityFunction)
51
+ Inline::C#strip_comments refers to src more than self (FeatureEnvy)
52
+ Module#inline calls Inline.const_get(lang) twice (DuplicateMethodCall)
53
+ Module#inline has approx 11 statements (TooManyStatements)
54
+ Module#inline is controlled by argument options (ControlParameter)
55
+
56
+ """
53
57
 
54
58
  Scenario: Correct smells from optparse.rb
55
59
  When I run reek spec/samples/optparse.rb
56
60
  Then the exit status indicates smells
57
- And it reports something like: spec/samples/optparse.rb -- 109 warnings:
58
- And it reports something like: OptionParser has at least 42 methods (TooManyMethods)
59
- And it reports something like: OptionParser has the variable name 'f' (UncommunicativeVariableName)
60
- And it reports something like: OptionParser has the variable name 'k' (UncommunicativeVariableName)
61
- And it reports something like: OptionParser has the variable name 'o' (UncommunicativeVariableName)
62
- And it reports something like: OptionParser has the variable name 's' (UncommunicativeVariableName)
63
- And it reports something like: OptionParser has the variable name 'v' (UncommunicativeVariableName)
64
- And it reports something like: OptionParser tests ((argv.size == 1) and Array.===(argv[0])) at least 3 times (RepeatedConditional)
65
- And it reports something like: OptionParser tests a at least 7 times (RepeatedConditional)
66
- And it reports something like: OptionParser tests default_pattern at least 7 times (RepeatedConditional)
67
- And it reports something like: OptionParser tests not_style at least 3 times (RepeatedConditional)
68
- And it reports something like: OptionParser tests s at least 7 times (RepeatedConditional)
69
- And it reports something like: OptionParser#complete contains iterators nested 2 deep (NestedIterators)
70
- And it reports something like: OptionParser#complete has 4 parameters (LongParameterList)
71
- And it reports something like: OptionParser#complete has boolean parameter 'icase' (BooleanParameter)
72
- And it reports something like: OptionParser#getopts calls result[opt] = false twice (DuplicateMethodCall)
73
- And it reports something like: OptionParser#getopts has approx 17 statements (TooManyStatements)
74
- And it reports something like: OptionParser#load has the variable name 's' (UncommunicativeVariableName)
75
- And it reports something like: OptionParser#make_switch calls (long << o = q.downcase) twice (DuplicateMethodCall)
76
- And it reports something like (pending): OptionParser#make_switch calls (sdesc << "-#{q}") twice (DuplicateMethodCall)
77
- And it reports something like: OptionParser#make_switch calls default_style.guess(arg = a) 4 times (DuplicateMethodCall)
78
- And it reports something like: OptionParser#make_switch calls notwice(NilClass, klass, "type") twice (DuplicateMethodCall)
79
- And it reports something like: OptionParser#make_switch calls notwice(a ? (Object) : (TrueClass), klass, "type") twice (DuplicateMethodCall)
80
- And it reports something like: OptionParser#make_switch calls pattern.method(:convert) twice (DuplicateMethodCall)
81
- And it reports something like: OptionParser#make_switch calls pattern.method(:convert).to_proc twice (DuplicateMethodCall)
82
- And it reports something like: OptionParser#make_switch calls pattern.respond_to?(:convert) twice (DuplicateMethodCall)
83
- And it reports something like: OptionParser#make_switch calls q.downcase 3 times (DuplicateMethodCall)
84
- And it reports something like: OptionParser#make_switch calls search(:atype, FalseClass) twice (DuplicateMethodCall)
85
- And it reports something like: OptionParser#make_switch calls search(:atype, o) 6 times (DuplicateMethodCall)
86
- And it reports something like: OptionParser#make_switch contains iterators nested 2 deep (NestedIterators)
87
- And it reports something like: OptionParser#make_switch contains iterators nested 3 deep (NestedIterators)
88
- And it reports something like: OptionParser#make_switch has approx 68 statements (TooManyStatements)
89
- And it reports something like: OptionParser#make_switch has the variable name 'a' (UncommunicativeVariableName)
90
- And it reports something like: OptionParser#make_switch has the variable name 'c' (UncommunicativeVariableName)
91
- And it reports something like: OptionParser#make_switch has the variable name 'n' (UncommunicativeVariableName)
92
- And it reports something like: OptionParser#make_switch has the variable name 'o' (UncommunicativeVariableName)
93
- And it reports something like: OptionParser#make_switch has the variable name 'q' (UncommunicativeVariableName)
94
- And it reports something like: OptionParser#make_switch has the variable name 's' (UncommunicativeVariableName)
95
- And it reports something like: OptionParser#make_switch has the variable name 'v' (UncommunicativeVariableName)
96
- And it reports something like: OptionParser#order calls argv[0] twice (DuplicateMethodCall)
97
- And it reports something like: OptionParser#order refers to argv more than self (FeatureEnvy)
98
- And it reports something like: OptionParser#parse calls argv[0] twice (DuplicateMethodCall)
99
- And it reports something like: OptionParser#parse refers to argv more than self (FeatureEnvy)
100
- And it reports something like: OptionParser#parse_in_order calls $!.set_option(arg, true) twice (DuplicateMethodCall)
101
- And it reports something like: OptionParser#parse_in_order calls cb.call(val) twice (DuplicateMethodCall)
102
- And it reports something like: OptionParser#parse_in_order calls raise($!.set_option(arg, true)) twice (DuplicateMethodCall)
103
- And it reports something like: OptionParser#parse_in_order calls raise(*exc) twice (DuplicateMethodCall)
104
- And it reports something like: OptionParser#parse_in_order calls setter.call(sw.switch_name, val) twice (DuplicateMethodCall)
105
- And it reports something like: OptionParser#parse_in_order calls sw.block twice (DuplicateMethodCall)
106
- And it reports something like: OptionParser#parse_in_order calls sw.switch_name twice (DuplicateMethodCall)
107
- And it reports something like: OptionParser#parse_in_order contains iterators nested 2 deep (NestedIterators)
108
- And it reports something like: OptionParser#parse_in_order contains iterators nested 3 deep (NestedIterators)
109
- And it reports something like: OptionParser#parse_in_order has approx 28 statements (TooManyStatements)
110
- And it reports something like: OptionParser#parse_in_order is controlled by argument setter (ControlParameter)
111
- And it reports something like: OptionParser#permute calls argv[0] twice (DuplicateMethodCall)
112
- And it reports something like: OptionParser#permute refers to argv more than self (FeatureEnvy)
113
- And it reports something like: OptionParser#search has the variable name 'k' (UncommunicativeVariableName)
114
- And it reports something like: OptionParser#summarize has 4 parameters (LongParameterList)
115
- And it reports something like: OptionParser#summarize has the variable name 'l' (UncommunicativeVariableName)
116
- And it reports something like: OptionParser#ver has the variable name 'v' (UncommunicativeVariableName)
117
- And it reports something like: OptionParser::CompletingHash#match contains iterators nested 2 deep (NestedIterators)
118
- And it reports something like: OptionParser::Completion#complete calls candidates.size twice (DuplicateMethodCall)
119
- And it reports something like: OptionParser::Completion#complete calls k.id2name twice (DuplicateMethodCall)
120
- And it reports something like: OptionParser::Completion#complete has approx 22 statements (TooManyStatements)
121
- And it reports something like: OptionParser::Completion#complete has boolean parameter 'icase' (BooleanParameter)
122
- And it reports something like: OptionParser::Completion#complete has the variable name 'k' (UncommunicativeVariableName)
123
- And it reports something like: OptionParser::Completion#complete has the variable name 'v' (UncommunicativeVariableName)
124
- And it reports something like: OptionParser::Completion#complete refers to candidates more than self (FeatureEnvy)
125
- And it reports something like: OptionParser::List#accept has the parameter name 't' (UncommunicativeParameterName)
126
- And it reports something like: OptionParser::List#accept is controlled by argument pat (ControlParameter)
127
- And it reports something like: OptionParser::List#accept refers to pat more than self (FeatureEnvy)
128
- And it reports something like: OptionParser::List#add_banner refers to opt more than self (FeatureEnvy)
129
- And it reports something like: OptionParser::List#complete has 4 parameters (LongParameterList)
130
- And it reports something like: OptionParser::List#complete has boolean parameter 'icase' (BooleanParameter)
131
- And it reports something like: OptionParser::List#reject has the parameter name 't' (UncommunicativeParameterName)
132
- And it reports something like: OptionParser::List#summarize refers to opt more than self (FeatureEnvy)
133
- And it reports something like: OptionParser::List#update has 5 parameters (LongParameterList)
134
- And it reports something like: OptionParser::List#update has approx 6 statements (TooManyStatements)
135
- And it reports something like: OptionParser::List#update has the variable name 'o' (UncommunicativeVariableName)
136
- And it reports something like: OptionParser::List#update is controlled by argument lopts (ControlParameter)
137
- And it reports something like: OptionParser::List#update is controlled by argument sopts (ControlParameter)
138
- And it reports something like: OptionParser::ParseError#set_option is controlled by argument eq (ControlParameter)
139
- And it reports something like: OptionParser::Switch#add_banner has the variable name 's' (UncommunicativeVariableName)
140
- And it reports something like: OptionParser::Switch#conv_arg calls conv twice (DuplicateMethodCall)
141
- And it reports something like: OptionParser::Switch#initialize has 7 parameters (LongParameterList)
142
- And it reports something like: OptionParser::Switch#parse_arg calls pattern twice (DuplicateMethodCall)
143
- And it reports something like: OptionParser::Switch#parse_arg calls s.length twice (DuplicateMethodCall)
144
- And it reports something like: OptionParser::Switch#parse_arg has approx 11 statements (TooManyStatements)
145
- And it reports something like: OptionParser::Switch#parse_arg has the variable name 'm' (UncommunicativeVariableName)
146
- And it reports something like: OptionParser::Switch#parse_arg has the variable name 's' (UncommunicativeVariableName)
147
- And it reports something like: OptionParser::Switch#self.guess has the variable name 't' (UncommunicativeVariableName)
148
- And it reports something like: OptionParser::Switch#self.incompatible_argument_styles has the parameter name 't' (UncommunicativeParameterName)
149
- And it reports something like: OptionParser::Switch#summarize calls (indent + l) twice (DuplicateMethodCall)
150
- And it reports something like: OptionParser::Switch#summarize calls arg 4 times (DuplicateMethodCall)
151
- And it reports something like: OptionParser::Switch#summarize calls left.collect twice (DuplicateMethodCall)
152
- And it reports something like: OptionParser::Switch#summarize calls left.collect { |s| s.length }.max twice (DuplicateMethodCall)
153
- And it reports something like: OptionParser::Switch#summarize calls left.collect { |s| s.length }.max.to_i twice (DuplicateMethodCall)
154
- And it reports something like: OptionParser::Switch#summarize calls left.shift twice (DuplicateMethodCall)
155
- And it reports something like: OptionParser::Switch#summarize calls left[-1] 3 times (DuplicateMethodCall)
156
- And it reports something like: OptionParser::Switch#summarize calls s.length 3 times (DuplicateMethodCall)
157
- And it reports something like: OptionParser::Switch#summarize contains iterators nested 2 deep (NestedIterators)
158
- And it reports something like: OptionParser::Switch#summarize has 5 parameters (LongParameterList)
159
- And it reports something like: OptionParser::Switch#summarize has approx 25 statements (TooManyStatements)
160
- And it reports something like: OptionParser::Switch#summarize has the variable name 'l' (UncommunicativeVariableName)
161
- And it reports something like: OptionParser::Switch#summarize has the variable name 'r' (UncommunicativeVariableName)
162
- And it reports something like: OptionParser::Switch#summarize has the variable name 's' (UncommunicativeVariableName)
163
- And it reports something like: OptionParser::Switch::NoArgument#parse is controlled by argument arg (ControlParameter)
164
- And it reports something like: OptionParser::Switch::OptionalArgument#parse is controlled by argument arg (ControlParameter)
165
- And it reports something like: OptionParser::Switch::PlacedArgument#parse has approx 6 statements (TooManyStatements)
166
- And it reports something like: OptionParser::Switch::RequiredArgument#parse is controlled by argument arg (ControlParameter)
61
+ And it reports:
62
+ """
63
+ spec/samples/optparse.rb -- 113 warnings:
64
+ OptionParser has at least 42 methods (TooManyMethods)
65
+ OptionParser has the variable name 'f' (UncommunicativeVariableName)
66
+ OptionParser has the variable name 'k' (UncommunicativeVariableName)
67
+ OptionParser has the variable name 'o' (UncommunicativeVariableName)
68
+ OptionParser has the variable name 's' (UncommunicativeVariableName)
69
+ OptionParser has the variable name 'v' (UncommunicativeVariableName)
70
+ OptionParser tests (argv.size == 1) and Array.===(argv[0]) at least 3 times (RepeatedConditional)
71
+ OptionParser tests a at least 7 times (RepeatedConditional)
72
+ OptionParser tests default_pattern at least 7 times (RepeatedConditional)
73
+ OptionParser tests not_style at least 3 times (RepeatedConditional)
74
+ OptionParser tests s at least 7 times (RepeatedConditional)
75
+ OptionParser#complete contains iterators nested 2 deep (NestedIterators)
76
+ OptionParser#complete has 4 parameters (LongParameterList)
77
+ OptionParser#complete has boolean parameter 'icase' (BooleanParameter)
78
+ OptionParser#getopts calls result[opt] = false twice (DuplicateMethodCall)
79
+ OptionParser#getopts has approx 17 statements (TooManyStatements)
80
+ OptionParser#load has the variable name 's' (UncommunicativeVariableName)
81
+ OptionParser#make_switch calls (long << (o = q.downcase)) twice (DuplicateMethodCall)
82
+ OptionParser#make_switch calls (sdesc << "-#{q}") twice (DuplicateMethodCall)
83
+ OptionParser#make_switch calls default_style.guess((arg = a)) 4 times (DuplicateMethodCall)
84
+ OptionParser#make_switch calls notwice((a ? (Object) : (TrueClass)), klass, "type") twice (DuplicateMethodCall)
85
+ OptionParser#make_switch calls notwice(NilClass, klass, "type") twice (DuplicateMethodCall)
86
+ OptionParser#make_switch calls pattern.method(:convert) twice (DuplicateMethodCall)
87
+ OptionParser#make_switch calls pattern.method(:convert).to_proc twice (DuplicateMethodCall)
88
+ OptionParser#make_switch calls pattern.respond_to?(:convert) twice (DuplicateMethodCall)
89
+ OptionParser#make_switch calls q.downcase 3 times (DuplicateMethodCall)
90
+ OptionParser#make_switch calls search(:atype, FalseClass) twice (DuplicateMethodCall)
91
+ OptionParser#make_switch calls search(:atype, o) 6 times (DuplicateMethodCall)
92
+ OptionParser#make_switch contains iterators nested 2 deep (NestedIterators)
93
+ OptionParser#make_switch contains iterators nested 3 deep (NestedIterators)
94
+ OptionParser#make_switch has approx 68 statements (TooManyStatements)
95
+ OptionParser#make_switch has the variable name 'a' (UncommunicativeVariableName)
96
+ OptionParser#make_switch has the variable name 'c' (UncommunicativeVariableName)
97
+ OptionParser#make_switch has the variable name 'n' (UncommunicativeVariableName)
98
+ OptionParser#make_switch has the variable name 'o' (UncommunicativeVariableName)
99
+ OptionParser#make_switch has the variable name 'q' (UncommunicativeVariableName)
100
+ OptionParser#make_switch has the variable name 's' (UncommunicativeVariableName)
101
+ OptionParser#make_switch has the variable name 'v' (UncommunicativeVariableName)
102
+ OptionParser#order calls argv[0] twice (DuplicateMethodCall)
103
+ OptionParser#order refers to argv more than self (FeatureEnvy)
104
+ OptionParser#parse calls argv[0] twice (DuplicateMethodCall)
105
+ OptionParser#parse refers to argv more than self (FeatureEnvy)
106
+ OptionParser#parse_in_order calls $!.set_option(arg, true) twice (DuplicateMethodCall)
107
+ OptionParser#parse_in_order calls cb.call(val) twice (DuplicateMethodCall)
108
+ OptionParser#parse_in_order calls raise($!.set_option(arg, true)) twice (DuplicateMethodCall)
109
+ OptionParser#parse_in_order calls raise(*exc) twice (DuplicateMethodCall)
110
+ OptionParser#parse_in_order calls setter.call(sw.switch_name, val) twice (DuplicateMethodCall)
111
+ OptionParser#parse_in_order calls sw.block twice (DuplicateMethodCall)
112
+ OptionParser#parse_in_order calls sw.switch_name twice (DuplicateMethodCall)
113
+ OptionParser#parse_in_order contains iterators nested 2 deep (NestedIterators)
114
+ OptionParser#parse_in_order contains iterators nested 3 deep (NestedIterators)
115
+ OptionParser#parse_in_order has approx 28 statements (TooManyStatements)
116
+ OptionParser#parse_in_order is controlled by argument setter (ControlParameter)
117
+ OptionParser#permute calls argv[0] twice (DuplicateMethodCall)
118
+ OptionParser#permute refers to argv more than self (FeatureEnvy)
119
+ OptionParser#search has the variable name 'k' (UncommunicativeVariableName)
120
+ OptionParser#summarize has 4 parameters (LongParameterList)
121
+ OptionParser#summarize has the variable name 'l' (UncommunicativeVariableName)
122
+ OptionParser#ver has the variable name 'v' (UncommunicativeVariableName)
123
+ OptionParser::Arguable#initialize has unused parameter '*args' (UnusedParameters)
124
+ OptionParser::CompletingHash#match contains iterators nested 2 deep (NestedIterators)
125
+ OptionParser::Completion#complete calls candidates.size twice (DuplicateMethodCall)
126
+ OptionParser::Completion#complete calls k.id2name twice (DuplicateMethodCall)
127
+ OptionParser::Completion#complete has approx 22 statements (TooManyStatements)
128
+ OptionParser::Completion#complete has boolean parameter 'icase' (BooleanParameter)
129
+ OptionParser::Completion#complete has the variable name 'k' (UncommunicativeVariableName)
130
+ OptionParser::Completion#complete has the variable name 'v' (UncommunicativeVariableName)
131
+ OptionParser::Completion#complete refers to candidates more than self (FeatureEnvy)
132
+ OptionParser::Completion#convert has unused parameter 'opt' (UnusedParameters)
133
+ OptionParser::List#accept has the parameter name 't' (UncommunicativeParameterName)
134
+ OptionParser::List#accept is controlled by argument pat (ControlParameter)
135
+ OptionParser::List#accept refers to pat more than self (FeatureEnvy)
136
+ OptionParser::List#add_banner refers to opt more than self (FeatureEnvy)
137
+ OptionParser::List#complete has 4 parameters (LongParameterList)
138
+ OptionParser::List#complete has boolean parameter 'icase' (BooleanParameter)
139
+ OptionParser::List#reject has the parameter name 't' (UncommunicativeParameterName)
140
+ OptionParser::List#summarize refers to opt more than self (FeatureEnvy)
141
+ OptionParser::List#update has 5 parameters (LongParameterList)
142
+ OptionParser::List#update has approx 6 statements (TooManyStatements)
143
+ OptionParser::List#update has the variable name 'o' (UncommunicativeVariableName)
144
+ OptionParser::List#update is controlled by argument lopts (ControlParameter)
145
+ OptionParser::List#update is controlled by argument sopts (ControlParameter)
146
+ OptionParser::ParseError#set_option is controlled by argument eq (ControlParameter)
147
+ OptionParser::Switch#add_banner has the variable name 's' (UncommunicativeVariableName)
148
+ OptionParser::Switch#conv_arg calls conv twice (DuplicateMethodCall)
149
+ OptionParser::Switch#initialize has 7 parameters (LongParameterList)
150
+ OptionParser::Switch#parse_arg calls pattern twice (DuplicateMethodCall)
151
+ OptionParser::Switch#parse_arg calls s.length twice (DuplicateMethodCall)
152
+ OptionParser::Switch#parse_arg has approx 11 statements (TooManyStatements)
153
+ OptionParser::Switch#parse_arg has the variable name 'm' (UncommunicativeVariableName)
154
+ OptionParser::Switch#parse_arg has the variable name 's' (UncommunicativeVariableName)
155
+ OptionParser::Switch#self.guess has the variable name 't' (UncommunicativeVariableName)
156
+ OptionParser::Switch#self.incompatible_argument_styles has the parameter name 't' (UncommunicativeParameterName)
157
+ OptionParser::Switch#summarize calls (indent + l) twice (DuplicateMethodCall)
158
+ OptionParser::Switch#summarize calls arg 4 times (DuplicateMethodCall)
159
+ OptionParser::Switch#summarize calls left.collect twice (DuplicateMethodCall)
160
+ OptionParser::Switch#summarize calls left.collect { |s| s.length }.max twice (DuplicateMethodCall)
161
+ OptionParser::Switch#summarize calls left.collect { |s| s.length }.max.to_i twice (DuplicateMethodCall)
162
+ OptionParser::Switch#summarize calls left.shift twice (DuplicateMethodCall)
163
+ OptionParser::Switch#summarize calls left[-1] 3 times (DuplicateMethodCall)
164
+ OptionParser::Switch#summarize calls s.length 3 times (DuplicateMethodCall)
165
+ OptionParser::Switch#summarize contains iterators nested 2 deep (NestedIterators)
166
+ OptionParser::Switch#summarize has 5 parameters (LongParameterList)
167
+ OptionParser::Switch#summarize has approx 25 statements (TooManyStatements)
168
+ OptionParser::Switch#summarize has the variable name 'l' (UncommunicativeVariableName)
169
+ OptionParser::Switch#summarize has the variable name 'r' (UncommunicativeVariableName)
170
+ OptionParser::Switch#summarize has the variable name 's' (UncommunicativeVariableName)
171
+ OptionParser::Switch::NoArgument#parse has unused parameter 'argv' (UnusedParameters)
172
+ OptionParser::Switch::NoArgument#parse is controlled by argument arg (ControlParameter)
173
+ OptionParser::Switch::OptionalArgument#parse has unused parameter 'argv' (UnusedParameters)
174
+ OptionParser::Switch::OptionalArgument#parse is controlled by argument arg (ControlParameter)
175
+ OptionParser::Switch::PlacedArgument#parse has approx 6 statements (TooManyStatements)
176
+ OptionParser::Switch::RequiredArgument#parse is controlled by argument arg (ControlParameter)
177
+
178
+ """
167
179
 
168
180
  Scenario: Correct smells from redcloth.rb
169
181
  When I run reek spec/samples/redcloth.rb
170
182
  Then the exit status indicates smells
171
183
  And it reports:
172
184
  """
173
- spec/samples/redcloth.rb -- 97 warnings:
185
+ spec/samples/redcloth.rb -- 102 warnings:
174
186
  RedCloth has at least 44 methods (TooManyMethods)
175
187
  RedCloth has the variable name 'a' (UncommunicativeVariableName)
176
188
  RedCloth has the variable name 'b' (UncommunicativeVariableName)
@@ -181,6 +193,7 @@ Feature: Basic smell detection
181
193
  RedCloth tests title at least 4 times (RepeatedConditional)
182
194
  RedCloth#block_markdown_atx refers to text more than self (FeatureEnvy)
183
195
  RedCloth#block_markdown_bq has approx 6 statements (TooManyStatements)
196
+ RedCloth#block_markdown_lists has unused parameter 'text' (UnusedParameters)
184
197
  RedCloth#block_markdown_rule refers to text more than self (FeatureEnvy)
185
198
  RedCloth#block_markdown_setext refers to text more than self (FeatureEnvy)
186
199
  RedCloth#block_textile_lists calls (line_id - 1) twice (DuplicateMethodCall)
@@ -259,11 +272,15 @@ Feature: Basic smell detection
259
272
  RedCloth#rip_offtags calls used_offtags["notextile"] 3 times (DuplicateMethodCall)
260
273
  RedCloth#rip_offtags has approx 18 statements (TooManyStatements)
261
274
  RedCloth#textile_bq has 4 parameters (LongParameterList)
275
+ RedCloth#textile_bq has unused parameter 'tag' (UnusedParameters)
262
276
  RedCloth#textile_bq is controlled by argument atts (ControlParameter)
263
277
  RedCloth#textile_bq is controlled by argument cite (ControlParameter)
264
278
  RedCloth#textile_fn_ has 5 parameters (LongParameterList)
279
+ RedCloth#textile_fn_ has unused parameter 'cite' (UnusedParameters)
280
+ RedCloth#textile_fn_ has unused parameter 'tag' (UnusedParameters)
265
281
  RedCloth#textile_fn_ is controlled by argument atts (ControlParameter)
266
282
  RedCloth#textile_p has 4 parameters (LongParameterList)
283
+ RedCloth#textile_p has unused parameter 'cite' (UnusedParameters)
267
284
  RedCloth#textile_p is controlled by argument atts (ControlParameter)
268
285
  RedCloth#textile_popup_help has the parameter name 'windowH' (UncommunicativeParameterName)
269
286
  RedCloth#textile_popup_help has the parameter name 'windowW' (UncommunicativeParameterName)
@@ -40,10 +40,6 @@ Then /^it reports this yaml:$/ do |expected_yaml|
40
40
  actual_warnings.should == expected_warnings
41
41
  end
42
42
 
43
- Then /^it reports something like: (.*)$/ do |line|
44
- @last_stdout.chomp.should match Regexp.new(Regexp.escape(line))
45
- end
46
-
47
43
  Then /^stderr reports:$/ do |report|
48
44
  @last_stderr.should == report
49
45
  end
@@ -57,11 +53,7 @@ Then /^it reports the error ['"](.*)['"]$/ do |string|
57
53
  end
58
54
 
59
55
  Then /^it reports a parsing error$/ do
60
- if RUBY_VERSION < "1.9.3"
61
- @last_stderr.chomp.should match /Racc::ParseError/
62
- else
63
- @last_stderr.chomp.should match /RipperRubyParser::SyntaxError/
64
- end
56
+ @last_stderr.chomp.should match(/Racc::ParseError/)
65
57
  end
66
58
 
67
59
  Then /^it reports the current version$/ do
@@ -57,7 +57,7 @@ module Reek
57
57
  end
58
58
 
59
59
  def process_block(exp)
60
- @element.count_statements(CodeParser.count_statements(exp))
60
+ @element.count_statements(CodeParser.count_statements(exp[1..-1]))
61
61
  process_default(exp)
62
62
  end
63
63
 
@@ -110,7 +110,7 @@ module Reek
110
110
  end
111
111
 
112
112
  def process_when(exp)
113
- count_clause(exp[2])
113
+ @element.count_statements(CodeParser.count_statements(exp[2..-1].compact))
114
114
  process_default(exp)
115
115
  end
116
116
 
@@ -133,8 +133,7 @@ module Reek
133
133
  end
134
134
  end
135
135
 
136
- def self.count_statements(exp)
137
- stmts = exp[1..-1]
136
+ def self.count_statements(stmts)
138
137
  ignore = 0
139
138
  ignore += 1 if stmts[1] == s(:nil)
140
139
  stmts.length - ignore
@@ -145,6 +144,7 @@ module Reek
145
144
  def handle_context(klass, type, exp)
146
145
  scope = klass.new(@element, exp)
147
146
  push(scope) do
147
+ @element.count_statements(CodeParser.count_statements(exp.body))
148
148
  process_default(exp)
149
149
  check_smells(type)
150
150
  end