reek 3.1 → 3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/{CHANGELOG → CHANGELOG.md} +150 -123
- data/README.md +61 -21
- data/Rakefile +2 -1
- data/bin/reek +1 -0
- data/config/defaults.reek +2 -2
- data/docs/Attribute.md +9 -13
- data/docs/Basic-Smell-Options.md +2 -2
- data/docs/Command-Line-Options.md +2 -2
- data/docs/Too-Many-Instance-Variables.md +1 -1
- data/features/samples.feature +22 -31
- data/features/step_definitions/sample_file_steps.rb +2 -2
- data/features/support/env.rb +1 -0
- data/lib/reek.rb +1 -0
- data/lib/reek/ast/ast_node_class_map.rb +5 -1
- data/lib/reek/ast/node.rb +4 -2
- data/lib/reek/ast/object_refs.rb +9 -5
- data/lib/reek/ast/reference_collector.rb +4 -2
- data/lib/reek/cli/application.rb +12 -9
- data/lib/reek/cli/command.rb +4 -0
- data/lib/reek/cli/input.rb +4 -4
- data/lib/reek/cli/option_interpreter.rb +11 -7
- data/lib/reek/cli/options.rb +42 -40
- data/lib/reek/cli/reek_command.rb +3 -3
- data/lib/reek/cli/warning_collector.rb +7 -3
- data/lib/reek/code_comment.rb +5 -1
- data/lib/reek/configuration/app_configuration.rb +4 -4
- data/lib/reek/context/code_context.rb +19 -17
- data/lib/reek/examiner.rb +8 -6
- data/lib/reek/rake/task.rb +13 -22
- data/lib/reek/report/formatter.rb +5 -1
- data/lib/reek/report/report.rb +46 -44
- data/lib/reek/smells/attribute.rb +42 -24
- data/lib/reek/smells/control_parameter.rb +21 -13
- data/lib/reek/smells/data_clump.rb +17 -9
- data/lib/reek/smells/duplicate_method_call.rb +12 -6
- data/lib/reek/smells/long_parameter_list.rb +2 -2
- data/lib/reek/smells/long_yield_list.rb +4 -4
- data/lib/reek/smells/nested_iterators.rb +4 -2
- data/lib/reek/smells/nil_check.rb +6 -2
- data/lib/reek/smells/repeated_conditional.rb +2 -2
- data/lib/reek/smells/smell_configuration.rb +15 -7
- data/lib/reek/smells/smell_detector.rb +23 -10
- data/lib/reek/smells/smell_repository.rb +9 -16
- data/lib/reek/smells/smell_warning.rb +6 -6
- data/lib/reek/smells/too_many_instance_variables.rb +4 -4
- data/lib/reek/smells/too_many_methods.rb +2 -2
- data/lib/reek/smells/too_many_statements.rb +4 -4
- data/lib/reek/smells/uncommunicative_method_name.rb +5 -5
- data/lib/reek/smells/uncommunicative_module_name.rb +5 -5
- data/lib/reek/smells/uncommunicative_parameter_name.rb +8 -4
- data/lib/reek/smells/uncommunicative_variable_name.rb +8 -4
- data/lib/reek/source/source_code.rb +6 -2
- data/lib/reek/source/source_locator.rb +4 -4
- data/lib/reek/spec/should_reek.rb +9 -4
- data/lib/reek/spec/should_reek_of.rb +8 -5
- data/lib/reek/spec/should_reek_only_of.rb +12 -8
- data/lib/reek/tree_dresser.rb +6 -2
- data/lib/reek/tree_walker.rb +28 -22
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +6 -5
- data/spec/gem/yard_spec.rb +6 -9
- data/spec/reek/code_comment_spec.rb +1 -1
- data/spec/reek/report/xml_report_spec.rb +11 -21
- data/spec/reek/smells/attribute_spec.rb +73 -57
- data/spec/reek/smells/too_many_instance_variables_spec.rb +26 -12
- data/spec/reek/source/source_locator_spec.rb +2 -2
- data/spec/samples/checkstyle.xml +12 -1
- data/spec/spec_helper.rb +1 -0
- metadata +20 -7
- data/spec/samples/unusual_syntax.rb +0 -21
data/README.md
CHANGED
@@ -218,7 +218,7 @@ end
|
|
218
218
|
This is further explained under [Smell Suppresion](docs/Smell-Suppression.md).
|
219
219
|
|
220
220
|
|
221
|
-
##
|
221
|
+
## Usage
|
222
222
|
|
223
223
|
Besides the obvious
|
224
224
|
|
@@ -277,23 +277,73 @@ If you don't feel like getting your hands dirty with code there are still other
|
|
277
277
|
|
278
278
|
## Working with Rails
|
279
279
|
|
280
|
-
|
280
|
+
Making `reek` "Rails"-friendly is fairly simple since we support directory specific configurations (`directory directives` in `reek` talk).
|
281
|
+
Just add this to your configuration file:
|
281
282
|
|
282
|
-
|
283
|
+
```Yaml
|
284
|
+
"app/controllers":
|
285
|
+
IrresponsibleModule:
|
286
|
+
enabled: false
|
287
|
+
NestedIterators:
|
288
|
+
max_allowed_nesting: 2
|
289
|
+
"app/helpers":
|
290
|
+
IrresponsibleModule:
|
291
|
+
enabled: false
|
292
|
+
UtilityFunction:
|
293
|
+
enabled: false
|
294
|
+
```
|
283
295
|
|
284
|
-
|
296
|
+
Be careful though, `reek` does not merge your configuration entries, so if you already have a directory directive for "app/controllers" or "app/helpers" you need to update those directives instead of copying the above YAML sample into your configuration file.
|
285
297
|
|
286
|
-
##
|
298
|
+
## Integrations
|
287
299
|
|
288
|
-
###
|
300
|
+
### Editor integrations
|
301
|
+
|
302
|
+
* [Vim plugin](https://github.com/rainerborene/vim-reek)
|
303
|
+
* [TextMate Bundle](https://github.com/peeyush1234/reek.tmbundle)
|
304
|
+
* [Atom plugin](https://atom.io/packages/linter-reek)
|
305
|
+
|
306
|
+
### Projects that use or support us
|
307
|
+
|
308
|
+
* [overcommit](https://github.com/brigade/overcommit) - a Git commit hook manager with support for
|
309
|
+
`reek`
|
310
|
+
* [ruby-critic](https://github.com/whitesmith/rubycritic) - gem that wraps around static analysis gems such as `reek`, [flay](https://github.com/seattlerb/flay) and [flog](https://github.com/seattlerb/flog)
|
311
|
+
* [pronto-reek](https://github.com/mmozuras/pronto-reek) - `reek` integration for [pronto](https://github.com/mmozuras/pronto)
|
312
|
+
|
313
|
+
### Misc
|
289
314
|
|
290
|
-
* [Vim plugin for `reek`](https://github.com/rainerborene/vim-reek)
|
291
|
-
* [TextMate Bundle for `reek`](https://github.com/peeyush1234/reek.tmbundle)
|
292
315
|
* [Colorful output for `reek`](https://github.com/joenas/preek)
|
293
316
|
(also with [Guard::Preek](https://github.com/joenas/guard-preek))
|
294
|
-
|
295
|
-
|
296
|
-
|
317
|
+
|
318
|
+
## Brothers and sisters
|
319
|
+
|
320
|
+
A non-exhaustive list of other static code analyzers you might want to look into:
|
321
|
+
|
322
|
+
* [debride](https://github.com/seattlerb/debride) - analyze code for potentially uncalled / dead methods
|
323
|
+
* [flay](https://github.com/seattlerb/flay) - analyze code for structural similarities
|
324
|
+
* [flog](https://github.com/seattlerb/flog) - reports the most tortured code in an easy to read pain
|
325
|
+
report
|
326
|
+
* [SandiMeter](https://github.com/makaroni4/sandi_meter) - checking your Ruby code for Sandi Metz' four rules
|
327
|
+
* [ruby-lint](https://github.com/YorickPeterse/ruby-lint) - static code analysis tool
|
328
|
+
* [Fasterer](https://github.com/DamirSvrtan/fasterer) - Fasterer will suggest some speed improvements based on [fast-ruby](https://github.com/JuanitoFatas/fast-ruby)
|
329
|
+
|
330
|
+
## Contributors
|
331
|
+
|
332
|
+
The `reek` core team consists of:
|
333
|
+
|
334
|
+
* [Matijs van Zuijlen](https://github.com/mvz)
|
335
|
+
* [Piotr Szotkowski](https://github.com/chastell)
|
336
|
+
* [Timo Rößner](https://github.com/troessner)
|
337
|
+
|
338
|
+
The original author of `reek` is [Kevin Rutherford](https://github.com/kevinrutherford).
|
339
|
+
|
340
|
+
Notable contributions came from:
|
341
|
+
|
342
|
+
* [Andrew Wagner](https://github.com/arwagner)
|
343
|
+
* [Gilles Leblanc](https://github.com/gilles-leblanc)
|
344
|
+
* [Emil Rehnberg](https://github.com/EmilRehnberg)
|
345
|
+
|
346
|
+
## Additional resources
|
297
347
|
|
298
348
|
### Miscellaneous
|
299
349
|
|
@@ -304,13 +354,3 @@ We plan to improve Reek in the near future so that it plays better with Rails. F
|
|
304
354
|
|
305
355
|
* [Stack Overflow](https://stackoverflow.com/questions/tagged/reek)
|
306
356
|
* [RubyDoc.info](http://www.rubydoc.info/gems/reek)
|
307
|
-
|
308
|
-
## Contributors
|
309
|
-
|
310
|
-
A non-exhaustive list:
|
311
|
-
|
312
|
-
* Kevin Rutherford
|
313
|
-
* Matijs van Zuijlen
|
314
|
-
* Andrew Wagner
|
315
|
-
* Gilles Leblanc
|
316
|
-
* Timo Rößner
|
data/Rakefile
CHANGED
data/bin/reek
CHANGED
data/config/defaults.reek
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
Attribute:
|
3
|
-
enabled:
|
3
|
+
enabled: true
|
4
4
|
exclude: []
|
5
5
|
BooleanParameter:
|
6
6
|
enabled: true
|
@@ -59,7 +59,7 @@ RepeatedConditional:
|
|
59
59
|
TooManyInstanceVariables:
|
60
60
|
enabled: true
|
61
61
|
exclude: []
|
62
|
-
max_instance_variables:
|
62
|
+
max_instance_variables: 4
|
63
63
|
TooManyMethods:
|
64
64
|
enabled: true
|
65
65
|
exclude: []
|
data/docs/Attribute.md
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
## Introduction
|
4
4
|
|
5
|
-
A class that publishes a
|
5
|
+
A class that publishes a setter for an instance variable invites
|
6
|
+
client classes to become too intimate with its inner workings, and in
|
7
|
+
particular with its representation of state.
|
8
|
+
|
9
|
+
The same holds to a lesser extent for getters, but Reek doesn't flag those.
|
6
10
|
|
7
11
|
## Example
|
8
12
|
|
@@ -20,24 +24,16 @@ end
|
|
20
24
|
reek test.rb
|
21
25
|
|
22
26
|
test.rb -- 1 warning:
|
23
|
-
[2]:Klass declares the attribute dummy (Attribute)
|
27
|
+
[2]:Klass declares the writable attribute dummy (Attribute)
|
24
28
|
```
|
25
29
|
|
26
30
|
## Support in Reek
|
27
31
|
|
28
|
-
|
32
|
+
This detector it raises a warning for every public `attr_writer`,
|
33
|
+
`attr_accessor`, and `attr` with the writable flag set to `true`.
|
29
34
|
|
30
|
-
|
35
|
+
Reek does not raise warnings for read-only attributes.
|
31
36
|
|
32
37
|
## Configuration
|
33
38
|
|
34
|
-
If you want to enable it you can do so by placing
|
35
|
-
|
36
|
-
```yaml
|
37
|
-
Attribute:
|
38
|
-
enabled: true
|
39
|
-
```
|
40
|
-
|
41
|
-
in your reek configuration file.
|
42
|
-
|
43
39
|
`Attribute` supports only the [Basic Smell Options](Basic-Smell-Options.md).
|
data/docs/Basic-Smell-Options.md
CHANGED
@@ -23,7 +23,7 @@ ControlCouple:
|
|
23
23
|
- write
|
24
24
|
```
|
25
25
|
|
26
|
-
Or a little more sophisticated using a
|
26
|
+
Or a little more sophisticated using a Ruby regex like this:
|
27
27
|
|
28
28
|
```yaml
|
29
29
|
ControlCouple:
|
@@ -41,4 +41,4 @@ FeatureEnvy:
|
|
41
41
|
- "ApplicationController#respond"
|
42
42
|
```
|
43
43
|
|
44
|
-
This would not report FeatureEnvy for the instance method `MyModel#do_things`, the whole module `MyHelper` and the `respond` instance method of `ApplicationController`
|
44
|
+
This would not report FeatureEnvy for the instance method `MyModel#do_things`, the whole module `MyHelper` and the `respond` instance method of `ApplicationController`
|
@@ -14,7 +14,7 @@ for details.
|
|
14
14
|
|
15
15
|
## Telling Reek Which Code to Check
|
16
16
|
|
17
|
-
Probably the most standard use case would be to check all
|
17
|
+
Probably the most standard use case would be to check all Ruby files in the lib directory:
|
18
18
|
|
19
19
|
```Bash
|
20
20
|
reek lib/*.rb
|
@@ -81,4 +81,4 @@ test.rb -- 1 warning:
|
|
81
81
|
[2]:Dummy declares the class variable @@class_variable (ClassVariable) [https://github.com/troessner/reek/wiki/Class-Variable]
|
82
82
|
```
|
83
83
|
|
84
|
-
Note the link at the end.
|
84
|
+
Note the link at the end.
|
@@ -40,4 +40,4 @@ test.rb -- 5 warnings:
|
|
40
40
|
|
41
41
|
| Option | Value | Effect |
|
42
42
|
| ---------------|-------------|---------|
|
43
|
-
| max_instance_variables | integer | The maximum number of instance variables that are permitted. Defaults to
|
43
|
+
| max_instance_variables | integer | The maximum number of instance variables that are permitted. Defaults to 4 |
|
data/features/samples.feature
CHANGED
@@ -5,7 +5,9 @@ Feature: Basic smell detection
|
|
5
5
|
|
6
6
|
Scenario: Correct smells from inline.rb
|
7
7
|
Given the "inline.rb" sample file exists
|
8
|
-
|
8
|
+
And the "optparse.rb" sample file exists
|
9
|
+
And the "redcloth.rb" sample file exists
|
10
|
+
When I run reek --no-line-numbers inline.rb optparse.rb redcloth.rb
|
9
11
|
Then the exit status indicates smells
|
10
12
|
And it reports:
|
11
13
|
"""
|
@@ -55,16 +57,16 @@ Feature: Basic smell detection
|
|
55
57
|
Module#inline calls Inline.const_get(lang) 2 times (DuplicateMethodCall)
|
56
58
|
Module#inline calls options[:testing] 2 times (DuplicateMethodCall)
|
57
59
|
Module#inline has approx 12 statements (TooManyStatements)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
optparse.rb -- 111 warnings:
|
60
|
+
optparse.rb -- 121 warnings:
|
61
|
+
OptionParser declares the writable attribute banner (Attribute)
|
62
|
+
OptionParser declares the writable attribute default_argv (Attribute)
|
63
|
+
OptionParser declares the writable attribute program_name (Attribute)
|
64
|
+
OptionParser declares the writable attribute release (Attribute)
|
65
|
+
OptionParser declares the writable attribute summary_indent (Attribute)
|
66
|
+
OptionParser declares the writable attribute summary_width (Attribute)
|
67
|
+
OptionParser declares the writable attribute version (Attribute)
|
67
68
|
OptionParser has at least 42 methods (TooManyMethods)
|
69
|
+
OptionParser has at least 6 instance variables (TooManyInstanceVariables)
|
68
70
|
OptionParser has the variable name 'f' (UncommunicativeVariableName)
|
69
71
|
OptionParser has the variable name 'k' (UncommunicativeVariableName)
|
70
72
|
OptionParser has the variable name 'o' (UncommunicativeVariableName)
|
@@ -148,7 +150,9 @@ Feature: Basic smell detection
|
|
148
150
|
OptionParser::List#update has 5 parameters (LongParameterList)
|
149
151
|
OptionParser::List#update has approx 10 statements (TooManyStatements)
|
150
152
|
OptionParser::List#update has the variable name 'o' (UncommunicativeVariableName)
|
153
|
+
OptionParser::ParseError declares the writable attribute reason (Attribute)
|
151
154
|
OptionParser::ParseError#set_option is controlled by argument eq (ControlParameter)
|
155
|
+
OptionParser::Switch has at least 7 instance variables (TooManyInstanceVariables)
|
152
156
|
OptionParser::Switch#add_banner has the variable name 's' (UncommunicativeVariableName)
|
153
157
|
OptionParser::Switch#initialize has 7 parameters (LongParameterList)
|
154
158
|
OptionParser::Switch#parse_arg calls s.length 2 times (DuplicateMethodCall)
|
@@ -175,15 +179,13 @@ Feature: Basic smell detection
|
|
175
179
|
OptionParser::Switch::NoArgument#parse has unused parameter 'argv' (UnusedParameters)
|
176
180
|
OptionParser::Switch::OptionalArgument#parse has unused parameter 'argv' (UnusedParameters)
|
177
181
|
OptionParser::Switch::PlacedArgument#parse has approx 6 statements (TooManyStatements)
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
"""
|
186
|
-
redcloth.rb -- 95 warnings:
|
182
|
+
redcloth.rb -- 101 warnings:
|
183
|
+
RedCloth declares the writable attribute filter_html (Attribute)
|
184
|
+
RedCloth declares the writable attribute filter_styles (Attribute)
|
185
|
+
RedCloth declares the writable attribute hard_breaks (Attribute)
|
186
|
+
RedCloth declares the writable attribute lite_mode (Attribute)
|
187
|
+
RedCloth declares the writable attribute no_span_caps (Attribute)
|
188
|
+
RedCloth declares the writable attribute rules (Attribute)
|
187
189
|
RedCloth has at least 44 methods (TooManyMethods)
|
188
190
|
RedCloth has the variable name 'a' (UncommunicativeVariableName)
|
189
191
|
RedCloth has the variable name 'b' (UncommunicativeVariableName)
|
@@ -279,16 +281,5 @@ Feature: Basic smell detection
|
|
279
281
|
RedCloth#textile_popup_help has the parameter name 'windowW' (UncommunicativeParameterName)
|
280
282
|
RedCloth#to_html has approx 26 statements (TooManyStatements)
|
281
283
|
RedCloth#v_align doesn't depend on instance state (UtilityFunction)
|
282
|
-
|
283
|
-
|
284
|
-
Scenario: Correct smells from a source file with unusual syntax samples
|
285
|
-
Given the "unusual_syntax.rb" sample file exists
|
286
|
-
When I run reek unusual_syntax.rb
|
287
|
-
Then the exit status indicates smells
|
288
|
-
And it reports:
|
289
|
-
"""
|
290
|
-
unusual_syntax.rb -- 3 warnings:
|
291
|
-
[1]:SomeClass has no descriptive comment (IrresponsibleModule)
|
292
|
-
[18]:SomeClass#method_with_array_decomposition has the parameter name 'a' (UncommunicativeParameterName)
|
293
|
-
[18]:SomeClass#method_with_array_decomposition has the parameter name 'b' (UncommunicativeParameterName)
|
284
|
+
267 total warnings
|
294
285
|
"""
|
@@ -27,7 +27,7 @@ end
|
|
27
27
|
|
28
28
|
Given(/^the "(.*?)" sample file exists$/) do |file_name|
|
29
29
|
full_path = Pathname.new("#{__dir__}/../../spec/samples/#{file_name}")
|
30
|
-
|
30
|
+
cd('.') { FileUtils.cp full_path, file_name }
|
31
31
|
end
|
32
32
|
|
33
33
|
Given(/^a directory called 'clean_files' containing some clean files$/) do
|
@@ -135,7 +135,7 @@ When(/^I run "reek (.*?)" in the subdirectory$/) do |args|
|
|
135
135
|
end
|
136
136
|
|
137
137
|
Given(/^a masking configuration file in the HOME directory$/) do
|
138
|
-
|
138
|
+
set_environment_variable 'HOME', Pathname.new("#{expand_path('.')}/home")
|
139
139
|
write_file('home/config.reek', <<-EOS.strip_heredoc)
|
140
140
|
---
|
141
141
|
DuplicateMethodCall:
|
data/features/support/env.rb
CHANGED
data/lib/reek.rb
CHANGED
@@ -13,7 +13,7 @@ module Reek
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def klass_for(type)
|
16
|
-
|
16
|
+
klass_map[type] ||= Class.new(Node).tap do |klass|
|
17
17
|
extension = extension_map[type]
|
18
18
|
klass.send :include, extension if extension
|
19
19
|
end
|
@@ -31,6 +31,10 @@ module Reek
|
|
31
31
|
Hash[assoc]
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
private_attr_reader :klass_map
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
data/lib/reek/ast/node.rb
CHANGED
@@ -17,12 +17,12 @@ module Reek
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def full_comment
|
20
|
-
|
20
|
+
comments.map(&:text).join("\n")
|
21
21
|
end
|
22
22
|
|
23
23
|
def leading_comment
|
24
24
|
line = location.line
|
25
|
-
comment_lines =
|
25
|
+
comment_lines = comments.select do |comment|
|
26
26
|
comment.location.line < line
|
27
27
|
end
|
28
28
|
comment_lines.map(&:text).join("\n")
|
@@ -120,6 +120,8 @@ module Reek
|
|
120
120
|
|
121
121
|
private
|
122
122
|
|
123
|
+
private_attr_reader :comments
|
124
|
+
|
123
125
|
def each_sexp
|
124
126
|
children.each { |elem| yield elem if elem.is_a? ::Parser::AST::Node }
|
125
127
|
end
|
data/lib/reek/ast/object_refs.rb
CHANGED
@@ -11,21 +11,25 @@ module Reek
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def most_popular
|
14
|
-
max =
|
15
|
-
|
14
|
+
max = refs.values.map(&:size).max
|
15
|
+
refs.select { |_name, refs| refs.size == max }
|
16
16
|
end
|
17
17
|
|
18
18
|
def record_reference_to(name, line: nil)
|
19
|
-
|
19
|
+
refs[name] << ObjectRef.new(name, line)
|
20
20
|
end
|
21
21
|
|
22
22
|
def references_to(name)
|
23
|
-
|
23
|
+
refs[name]
|
24
24
|
end
|
25
25
|
|
26
26
|
def self_is_max?
|
27
|
-
|
27
|
+
refs.empty? || most_popular.keys.include?(:self)
|
28
28
|
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
private_attr_reader :refs
|
29
33
|
end
|
30
34
|
end
|
31
35
|
end
|
@@ -18,14 +18,16 @@ module Reek
|
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
+
private_attr_reader :ast
|
22
|
+
|
21
23
|
def explicit_self_calls
|
22
24
|
[:self, :zsuper, :ivar, :ivasgn].flat_map do |node_type|
|
23
|
-
|
25
|
+
ast.each_node(node_type, STOP_NODES)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
29
|
def implicit_self_calls
|
28
|
-
|
30
|
+
ast.each_node(:send, STOP_NODES).reject(&:receiver)
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
data/lib/reek/cli/application.rb
CHANGED
@@ -20,9 +20,9 @@ module Reek
|
|
20
20
|
@status = STATUS_SUCCESS
|
21
21
|
options_parser = Options.new(argv)
|
22
22
|
begin
|
23
|
-
|
24
|
-
@command = ReekCommand.new(OptionInterpreter.new(
|
25
|
-
@configuration = Configuration::AppConfiguration.new
|
23
|
+
options = options_parser.parse
|
24
|
+
@command = ReekCommand.new(OptionInterpreter.new(options))
|
25
|
+
@configuration = Configuration::AppConfiguration.new(options)
|
26
26
|
rescue OptionParser::InvalidOption, Reek::Configuration::ConfigFileException => error
|
27
27
|
$stderr.puts "Error: #{error}"
|
28
28
|
@status = STATUS_ERROR
|
@@ -30,9 +30,9 @@ module Reek
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def execute
|
33
|
-
return
|
34
|
-
|
35
|
-
|
33
|
+
return status if error_occured?
|
34
|
+
command.execute self
|
35
|
+
status
|
36
36
|
end
|
37
37
|
|
38
38
|
def output(text)
|
@@ -40,17 +40,20 @@ module Reek
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def report_success
|
43
|
-
|
43
|
+
self.status = STATUS_SUCCESS
|
44
44
|
end
|
45
45
|
|
46
46
|
def report_smells
|
47
|
-
|
47
|
+
self.status = STATUS_SMELLS
|
48
48
|
end
|
49
49
|
|
50
50
|
private
|
51
51
|
|
52
|
+
private_attr_accessor :status
|
53
|
+
private_attr_reader :command
|
54
|
+
|
52
55
|
def error_occured?
|
53
|
-
|
56
|
+
status == STATUS_ERROR
|
54
57
|
end
|
55
58
|
end
|
56
59
|
end
|