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 +6 -0
- data/config/defaults.reek +3 -0
- data/features/ruby_api/api.feature +5 -1
- data/features/samples.feature +170 -153
- data/features/step_definitions/reek_steps.rb +1 -9
- data/lib/reek/core/code_parser.rb +4 -4
- data/lib/reek/core/method_context.rb +2 -11
- data/lib/reek/core/smell_repository.rb +1 -0
- data/lib/reek/smells.rb +1 -0
- data/lib/reek/smells/duplication.rb +1 -1
- data/lib/reek/smells/irresponsible_module.rb +5 -1
- data/lib/reek/smells/simulated_polymorphism.rb +1 -1
- data/lib/reek/smells/uncommunicative_variable_name.rb +43 -3
- data/lib/reek/smells/unused_parameters.rb +37 -0
- data/lib/reek/source/source_code.rb +2 -13
- data/lib/reek/source/tree_dresser.rb +11 -24
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +4 -5
- data/spec/reek/smells/control_couple_spec.rb +1 -5
- data/spec/reek/smells/feature_envy_spec.rb +0 -3
- data/spec/reek/smells/irresponsible_module_spec.rb +10 -1
- data/spec/reek/smells/long_method_spec.rb +24 -2
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +66 -0
- data/spec/reek/smells/unused_parameters_spec.rb +47 -0
- data/spec/reek/smells/utility_function_spec.rb +3 -3
- data/spec/reek/source/tree_dresser_spec.rb +88 -33
- metadata +40 -40
data/CHANGELOG
CHANGED
data/config/defaults.reek
CHANGED
@@ -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 --
|
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
|
"""
|
data/features/samples.feature
CHANGED
@@ -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
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
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 --
|
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
|
-
|
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
|
-
|
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(
|
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
|