reek 4.4.2 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -1
- data/CHANGELOG.md +16 -0
- data/CONTRIBUTING.md +52 -23
- data/README.md +16 -3
- data/ataru_setup.rb +1 -1
- data/docs/API.md +1 -4
- data/docs/How-reek-works-internally.md +5 -5
- data/docs/Style-Guide.md +7 -0
- data/features/command_line_interface/options.feature +1 -0
- data/features/command_line_interface/show_progress.feature +33 -0
- data/features/configuration_files/masking_smells.feature +0 -1
- data/features/configuration_via_source_comments/erroneous_source_comments.feature +18 -4
- data/features/configuration_via_source_comments/well_formed_source_comments.feature +116 -0
- data/features/step_definitions/sample_file_steps.rb +5 -0
- data/features/todo_list.feature +42 -14
- data/lib/reek.rb +1 -1
- data/lib/reek/cli/application.rb +5 -0
- data/lib/reek/cli/command/report_command.rb +6 -1
- data/lib/reek/cli/command/todo_list_command.rb +1 -2
- data/lib/reek/cli/options.rb +19 -3
- data/lib/reek/code_comment.rb +83 -11
- data/lib/reek/configuration/configuration_validator.rb +2 -2
- data/lib/reek/errors/bad_detector_in_comment_error.rb +35 -0
- data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +34 -0
- data/lib/reek/examiner.rb +36 -14
- data/lib/reek/report.rb +28 -9
- data/lib/reek/report/base_report.rb +77 -0
- data/lib/reek/report/code_climate.rb +4 -0
- data/lib/reek/report/code_climate/code_climate_fingerprint.rb +48 -0
- data/lib/reek/report/code_climate/code_climate_formatter.rb +5 -0
- data/lib/reek/report/code_climate/code_climate_report.rb +19 -0
- data/lib/reek/report/formatter.rb +5 -56
- data/lib/reek/report/{heading_formatter.rb → formatter/heading_formatter.rb} +4 -4
- data/lib/reek/report/formatter/location_formatter.rb +41 -0
- data/lib/reek/report/formatter/progress_formatter.rb +80 -0
- data/lib/reek/report/formatter/simple_warning_formatter.rb +35 -0
- data/lib/reek/report/formatter/wiki_link_warning_formatter.rb +35 -0
- data/lib/reek/report/html_report.rb +21 -0
- data/lib/reek/report/{html_report.html.erb → html_report/html_report.html.erb} +0 -0
- data/lib/reek/report/json_report.rb +18 -0
- data/lib/reek/report/text_report.rb +68 -0
- data/lib/reek/report/xml_report.rb +61 -0
- data/lib/reek/report/yaml_report.rb +18 -0
- data/lib/reek/smell_detectors.rb +30 -0
- data/lib/reek/{smells → smell_detectors}/attribute.rb +3 -3
- data/lib/reek/{smells/smell_detector.rb → smell_detectors/base_detector.rb} +3 -3
- data/lib/reek/{smells → smell_detectors}/boolean_parameter.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/class_variable.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/control_parameter.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/data_clump.rb +3 -3
- data/lib/reek/{smells/smell_repository.rb → smell_detectors/detector_repository.rb} +9 -9
- data/lib/reek/{smells → smell_detectors}/duplicate_method_call.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/feature_envy.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/instance_variable_assumption.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/irresponsible_module.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/long_parameter_list.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/long_yield_list.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/manual_dispatch.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/module_initialize.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/nested_iterators.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/nil_check.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/prima_donna_method.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/repeated_conditional.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/smell_configuration.rb +1 -1
- data/lib/reek/{smells → smell_detectors}/smell_warning.rb +1 -1
- data/lib/reek/{smells → smell_detectors}/subclassed_from_core_class.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/too_many_constants.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/too_many_instance_variables.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/too_many_methods.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/too_many_statements.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/uncommunicative_method_name.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/uncommunicative_module_name.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/uncommunicative_parameter_name.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/uncommunicative_variable_name.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/unused_parameters.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/unused_private_method.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/utility_function.rb +3 -3
- data/lib/reek/spec/should_reek_of.rb +1 -1
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +1 -1
- data/spec/factories/factories.rb +6 -6
- data/spec/reek/cli/command/report_command_spec.rb +3 -1
- data/spec/reek/cli/options_spec.rb +12 -2
- data/spec/reek/code_comment_spec.rb +18 -6
- data/spec/reek/configuration/app_configuration_spec.rb +12 -12
- data/spec/reek/configuration/default_directive_spec.rb +1 -1
- data/spec/reek/configuration/directory_directives_spec.rb +2 -2
- data/spec/reek/examiner_spec.rb +56 -28
- data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +122 -0
- data/spec/reek/report/{code_climate_formatter_spec.rb → code_climate/code_climate_formatter_spec.rb} +6 -2
- data/spec/reek/report/{code_climate_report_spec.rb → code_climate/code_climate_report_spec.rb} +7 -5
- data/spec/reek/report/{location_formatter_spec.rb → formatter/location_formatter_spec.rb} +4 -4
- data/spec/reek/report/formatter/progress_formatter_spec.rb +68 -0
- data/spec/reek/report/html_report_spec.rb +1 -1
- data/spec/reek/report/json_report_spec.rb +2 -2
- data/spec/reek/report/text_report_spec.rb +3 -4
- data/spec/reek/report/xml_report_spec.rb +1 -1
- data/spec/reek/report/yaml_report_spec.rb +2 -2
- data/spec/reek/report_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/attribute_spec.rb +2 -2
- data/spec/reek/{smells/smell_detector_spec.rb → smell_detectors/base_detector_spec.rb} +5 -5
- data/spec/reek/{smells → smell_detectors}/boolean_parameter_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/class_variable_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/control_parameter_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/data_clump_spec.rb +2 -2
- data/spec/reek/smell_detectors/detector_repository_spec.rb +22 -0
- data/spec/reek/{smells → smell_detectors}/duplicate_method_call_spec.rb +6 -6
- data/spec/reek/{smells → smell_detectors}/feature_envy_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/instance_variable_assumption_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/irresponsible_module_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/long_parameter_list_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/long_yield_list_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/manual_dispatch_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/module_initialize_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/nested_iterators_spec.rb +4 -4
- data/spec/reek/{smells → smell_detectors}/nil_check_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/prima_donna_method_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/repeated_conditional_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/smell_configuration_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/smell_warning_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/subclassed_from_core_class_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/too_many_constants_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/too_many_instance_variables_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/too_many_methods_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/too_many_statements_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/uncommunicative_method_name_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/uncommunicative_module_name_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/uncommunicative_parameter_name_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/uncommunicative_variable_name_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/unused_parameters_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/unused_private_method_spec.rb +4 -4
- data/spec/reek/{smells → smell_detectors}/utility_function_spec.rb +3 -3
- data/spec/reek/spec/should_reek_of_spec.rb +3 -3
- data/tasks/configuration.rake +2 -2
- metadata +95 -81
- data/features/smells/subclassed_from_core_class.feature +0 -14
- data/features/smells/too_many_constants.feature +0 -19
- data/lib/reek/errors.rb +0 -32
- data/lib/reek/report/location_formatter.rb +0 -39
- data/lib/reek/report/report.rb +0 -229
- data/lib/reek/smells.rb +0 -30
- data/spec/reek/smells/smell_repository_spec.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f44c19009380c9dff7c4d8ef4dcdbe6f788d46b2
|
4
|
+
data.tar.gz: b9cfe47dc250a613611f414463a6dbca748690c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 221c0dbe79b6a6758a30ded23285fd715634843c3ac9bb0b9883aef9a0ebffcf84531dc6e492f091b2fa11cb7087470c96632aa45b53704da831a0a64feb7c1a
|
7
|
+
data.tar.gz: 51c17f02b1aa2c8ff8cf701ba7bc9d98c058a9c4e62fc2b6f246fd43f3be17ed12b6cc58ccb247f99527f909db50c5b4ab7085b08392a4b2c9e26137c8081bb2
|
data/.rubocop.yml
CHANGED
@@ -44,7 +44,9 @@ RSpec/ExampleLength:
|
|
44
44
|
RSpec/MultipleDescribes:
|
45
45
|
Exclude:
|
46
46
|
- 'spec/reek/ast/sexp_extensions_spec.rb'
|
47
|
-
- 'spec/reek/
|
47
|
+
- 'spec/reek/code_comment_spec.rb'
|
48
|
+
- 'spec/reek/report/formatter/location_formatter_spec.rb'
|
49
|
+
- 'spec/reek/report/formatter/progress_formatter_spec.rb'
|
48
50
|
|
49
51
|
# FIXME: Update specs to avoid offenses
|
50
52
|
RSpec/MultipleExpectations:
|
@@ -69,6 +71,13 @@ RSpec/VerifiedDoubles:
|
|
69
71
|
- 'spec/reek/context/method_context_spec.rb'
|
70
72
|
- 'spec/reek/context/module_context_spec.rb'
|
71
73
|
|
74
|
+
# rubocop-rspec expects a CodeClimate namespace to go with the code_climate directory.
|
75
|
+
RSpec/FilePath:
|
76
|
+
Exclude:
|
77
|
+
- 'spec/reek/report/code_climate/code_climate_fingerprint_spec.rb'
|
78
|
+
- 'spec/reek/report/code_climate/code_climate_formatter_spec.rb'
|
79
|
+
- 'spec/reek/report/code_climate/code_climate_report_spec.rb'
|
80
|
+
|
72
81
|
Style/AccessorMethodName:
|
73
82
|
Exclude:
|
74
83
|
- 'lib/reek/context/visibility_tracker.rb'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## 4.5.0 (2016-10-12)
|
4
|
+
|
5
|
+
* (maxjacobson) Emit fingerprints in Code Climate reporter
|
6
|
+
* (mvz) Disable progress for piped output
|
7
|
+
* (mvz) Update progress formatter to match changed file location
|
8
|
+
* (jhubert) Add progress formatters for showing progress on each file
|
9
|
+
|
10
|
+
## 4.4.4 (2016-09-29)
|
11
|
+
|
12
|
+
* (troessner) Create a fresh todo file on every run
|
13
|
+
* (troessner) Handle garbage in comment config properly
|
14
|
+
|
15
|
+
## 4.4.3 (2016-09-24)
|
16
|
+
|
17
|
+
* (troessner) Improve handling of internal errors in detectors and the corresponding error messages
|
18
|
+
|
3
19
|
## 4.4.2 (2016-09-21)
|
4
20
|
|
5
21
|
* (troessner) Fail properly on bad configuration comments
|
data/CONTRIBUTING.md
CHANGED
@@ -27,7 +27,7 @@ version, Ruby platform (MRI, JRuby, etc.), operating system.
|
|
27
27
|
Try to provide a minimal example that reproduces the issue.
|
28
28
|
Extra kudos if you can write it as a failing test. :)
|
29
29
|
|
30
|
-
##
|
30
|
+
## Contributing features, bugfixes, documentation
|
31
31
|
|
32
32
|
### Getting started
|
33
33
|
|
@@ -55,20 +55,21 @@ start contributing.
|
|
55
55
|
Then start hacking and add new tests which make sure that your new feature works or
|
56
56
|
demonstrate that your fix was needed.
|
57
57
|
|
58
|
-
###
|
58
|
+
### RSpec Specs
|
59
59
|
|
60
|
-
Reek
|
60
|
+
Reek uses [Rspec](http://rspec.info/) for unit and functional testing.
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
We're trying to follow [betterspecs](http://betterspecs.org/). We're not using
|
63
|
+
RSpec's
|
64
|
+
[shared examples](https://www.relishapp.com/rspec/rspec-core/docs/example-groups/shared-examples)
|
65
|
+
because we find them rather harming than helpful. You can find an excellent
|
66
|
+
cheat sheet on how to write idiomatic Rspec
|
67
|
+
[here](http://www.rubypigeon.com/posts/rspec-core-cheat-sheet).
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
which means that we would write this
|
69
|
+
We do not use the popular "foo" / "bar" naming when it comes to the question
|
70
|
+
"how to come up with good example names?". Instead, we use the
|
71
|
+
[military alphabet](https://en.wikipedia.org/wiki/NATO_phonetic_alphabet) in
|
72
|
+
ascending order which means that we would write this
|
72
73
|
|
73
74
|
```Ruby
|
74
75
|
class Foo
|
@@ -88,13 +89,43 @@ class Alfa
|
|
88
89
|
end
|
89
90
|
```
|
90
91
|
|
91
|
-
###
|
92
|
+
### Cucumber Features
|
93
|
+
|
94
|
+
Reek uses [Cucumber](https://cucumber.io/) with
|
95
|
+
[Aruba](https://github.com/cucumber/aruba) for integration tests. Keep the
|
96
|
+
following in mind when writing cucumber features.
|
97
|
+
|
98
|
+
#### What to test
|
99
|
+
|
100
|
+
Not everything needs a cucumber feature. We try to limit cucumber features to
|
101
|
+
things that really require end-to-end testing of Reek's behavior. In
|
102
|
+
particular, this means individual smell detectors should not have their own
|
103
|
+
scenarios.
|
104
|
+
|
105
|
+
#### TTY output checks
|
106
|
+
|
107
|
+
Some default behaviors of Reek depend on whether the output is a TTY, for
|
108
|
+
example output coloring and the progress bar. Because under Aruba stdout is
|
109
|
+
*not* a TTY, Reeks default behavior in the scenarios is different in this
|
110
|
+
regard than if it were run in a terminal.
|
111
|
+
|
112
|
+
#### Failing Cucumber Scenarios
|
113
|
+
|
114
|
+
If there is a failing scenario and you can not figure out why it is failing,
|
115
|
+
just run the failing scenario: `bundle exec cucumber
|
116
|
+
features/failing_scenario.feature:line`. By doing so Aruba will leave its set
|
117
|
+
up in the `tmp/aruba` directory. You can then `cd` into this directory and run
|
118
|
+
Reek the same way the cucumber scenario actually ran it. This way you can debug
|
119
|
+
scenario failures that can be very opaque sometimes.
|
120
|
+
|
121
|
+
### Writing new smell detectors
|
92
122
|
|
93
123
|
Please see [our separate guide](docs/How-To-Write-New-Detectors.md) for this.
|
94
124
|
|
95
|
-
###
|
125
|
+
### Creating your pull request
|
96
126
|
|
97
|
-
We care a lot about [good commit
|
127
|
+
We care a lot about [good commit
|
128
|
+
messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
98
129
|
|
99
130
|
Once you’re happy with your feature / fix – or want to
|
100
131
|
share it as a work-in-progress and request comments – once
|
@@ -116,13 +147,14 @@ Then go to your GitHub fork and [make a pull
|
|
116
147
|
request](https://help.github.com/articles/creating-a-pull-request/)
|
117
148
|
to the original repository.
|
118
149
|
|
119
|
-
|
150
|
+
### Review and Fixes
|
120
151
|
|
121
152
|
Try to gauge and let us know in the pull request whether what
|
122
153
|
you propose is a backward-compatible bugfix and should go into the
|
123
154
|
next patch release, is a backward-compatible feature and should go
|
124
155
|
into the next minor release, or has to break backward-compatibility
|
125
|
-
and so needs to wait for the next major release of Reek.
|
156
|
+
and so needs to wait for the next major release of Reek. See also our
|
157
|
+
versioning policy below.
|
126
158
|
|
127
159
|
Once your PR is open someone will review it, discuss the details (if
|
128
160
|
needed) and either merge right away or ask for some further fixes.
|
@@ -142,14 +174,11 @@ git rebase -i master
|
|
142
174
|
# squash squash squash
|
143
175
|
git push -f origin
|
144
176
|
```
|
145
|
-
## Failing Cucumber Scenarios
|
146
|
-
|
147
|
-
If there is a failing scenario and you can not figure out why it is failing, just run the failing scenario: `bundle exec cucumber features/failing_scenario.feature:line`. By doing so Aruba will leave its set up in the `tmp/aruba` directory. You can then `cd` into this directory and run Reek the same way the cucumber scenario actually ran it. This way you can debug scenario failures that can be very opaque sometimes.
|
148
177
|
|
149
178
|
## Versioning policy
|
150
179
|
|
151
180
|
We are following [semantic versioning](http://semver.org/).
|
152
181
|
|
153
|
-
|
154
|
-
|
155
|
-
|
182
|
+
If you're working on a change that is breaking backwards-compatibility
|
183
|
+
just go ahead with your pull request like normal. We'll discuss this then in
|
184
|
+
the pull request and help you to point your pull request to the right branch.
|
data/README.md
CHANGED
@@ -84,6 +84,9 @@ Reek will report the following code smells in this file:
|
|
84
84
|
|
85
85
|
```
|
86
86
|
$ reek demo.rb
|
87
|
+
Inspecting 1 file(s):
|
88
|
+
S
|
89
|
+
|
87
90
|
demo.rb -- 2 warnings:
|
88
91
|
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
89
92
|
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
@@ -404,13 +407,23 @@ via:
|
|
404
407
|
reek -c whatever/.todo.reek lib/
|
405
408
|
```
|
406
409
|
|
407
|
-
|
410
|
+
It's important to understand that the number one use case of the `--todo` flag
|
411
|
+
is to be run once at the beginning of the introduction of Reek to ease the transition.
|
412
|
+
If you find yourself re-running Reek with the `--todo` flag in order to silence new warnings
|
413
|
+
you're defeating the purpose of both the `--todo` flag and of Reek itself.
|
414
|
+
|
415
|
+
As a consequence, running Reek with the `--todo` flag again will overwrite '.todo.reek' without
|
416
|
+
asking (should not be a problem since this file is supposed to be versioned) and
|
417
|
+
without taking **any** other configuration file you might have into account.
|
418
|
+
|
419
|
+
This means that when you run
|
408
420
|
|
409
421
|
```Bash
|
410
|
-
reek --todo lib/
|
422
|
+
reek -c other_configuration.reek --todo lib/
|
411
423
|
```
|
412
424
|
|
413
|
-
|
425
|
+
`other_configuration.reek` will simply be ignored (as outlined before, Reek
|
426
|
+
is supposed to have one configuration file and one file only).
|
414
427
|
|
415
428
|
## Usage
|
416
429
|
|
data/ataru_setup.rb
CHANGED
data/docs/API.md
CHANGED
@@ -55,9 +55,6 @@ Note that `Reek::Examiner.new` can take `source` as `String`, `Pathname`, `File`
|
|
55
55
|
Everything that is mentioned in this document can be considered stable in the
|
56
56
|
sense that it will only change across major versions.
|
57
57
|
|
58
|
-
`Reek 3` was the first major version with a stable API. As soon as `Reek 4`
|
59
|
-
is released we will mark the differences between `3` and `4`.
|
60
|
-
|
61
58
|
There is one thing in this API documentation you can't and shouldn't rely on:
|
62
59
|
The `SmellWarning` messages itself.
|
63
60
|
|
@@ -147,7 +144,7 @@ Instead of the smell detector names you can also use the full detector class in
|
|
147
144
|
your configuration hash, for example:
|
148
145
|
|
149
146
|
```ruby
|
150
|
-
config_hash = { Reek::
|
147
|
+
config_hash = { Reek::SmellDetectors::IrresponsibleModule => { 'enabled' => false } }
|
151
148
|
```
|
152
149
|
|
153
150
|
Of course, directory specific configuration and excluded paths are supported as
|
@@ -40,9 +40,9 @@
|
|
40
40
|
Examiner (core/examiner) --------------------------------------
|
41
41
|
* generates the AST out of the given source
|
42
42
|
* adorns the generated AST via a TreeDresser (core/tree_dresser)
|
43
|
-
* initializes a
|
43
|
+
* initializes a DetectorRepository with all relevant smells (smells/detector_repository)
|
44
44
|
* builds a tree of Contexts using ContextBuilder
|
45
|
-
* tells the
|
45
|
+
* tells the DetectorRepository above to run each of its smell detectors above on each of the contexts
|
46
46
|
/ | \
|
47
47
|
/ | \
|
48
48
|
/ | \
|
@@ -50,7 +50,7 @@
|
|
50
50
|
\ | /
|
51
51
|
\ | /
|
52
52
|
\ | /
|
53
|
-
|
53
|
+
DetectorRepository
|
54
54
|
|
|
55
55
|
|
|
56
56
|
|
|
@@ -66,7 +66,7 @@ The overall workflow is like this:
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
Initialize
|
69
|
+
Initialize DetectorRepository only with eligible SmellDetectors
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
@@ -111,4 +111,4 @@ The overall workflow is like this:
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
A ContextBuilder then traverses this now adorned tree again and
|
114
|
-
runs all SmellDetectors from the
|
114
|
+
runs all SmellDetectors from the DetectorRepository above
|
data/docs/Style-Guide.md
CHANGED
@@ -10,3 +10,10 @@ We use instance vars only:
|
|
10
10
|
For everything else we use proper getters / setters.
|
11
11
|
|
12
12
|
If possible those should be private.
|
13
|
+
|
14
|
+
## Data types
|
15
|
+
|
16
|
+
- Class or module names that are carried around in hashes and configuration and what
|
17
|
+
not should be designated by constants. So `DuplicateMethodCall`, not `:DuplicateMethodCall` or `"DuplicateMethodCall"`
|
18
|
+
- Hash keys should be all symbols unless they designate classes / modules - see above.
|
19
|
+
- Everything else like messages or parameters in smell warnings should be strings, nothing else.
|
@@ -61,6 +61,7 @@ Feature: Reek can be controlled using command-line options
|
|
61
61
|
-U, --[no-]wiki-links Show link to related wiki page for each smell (default: true)
|
62
62
|
-n, --[no-]line-numbers Show line numbers in the output (default: true)
|
63
63
|
-s, --single-line Show location in editor-compatible single-line-per-smell format
|
64
|
+
-P, --[no-]progress Show progress of each source as it is examined (default: true)
|
64
65
|
--sort-by SORTING Sort reported files by the given criterium:
|
65
66
|
smelliness ("smelliest" files first)
|
66
67
|
none (default - output in processing order)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Feature: Show progress
|
2
|
+
In order to see the progress of the examiners
|
3
|
+
As a developer
|
4
|
+
I want to be able to selectively activate progress reporting
|
5
|
+
|
6
|
+
# Note that --progress is the default on TTYs, but needs to be explicitely
|
7
|
+
# enabled here because output in the cucumber scenarios does not go to a TTY.
|
8
|
+
Scenario: shows progress output on mixed files by default
|
9
|
+
Given a directory called 'mixed_files' containing some clean and smelly files
|
10
|
+
When I run reek --progress mixed_files
|
11
|
+
Then the exit status indicates smells
|
12
|
+
And it reports:
|
13
|
+
"""
|
14
|
+
Inspecting 2 file(s):
|
15
|
+
.S
|
16
|
+
|
17
|
+
mixed_files/dirty.rb -- 2 warnings:
|
18
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
19
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
20
|
+
2 total warnings
|
21
|
+
"""
|
22
|
+
|
23
|
+
Scenario: --no-progress disables progress output
|
24
|
+
Given a directory called 'mixed_files' containing some clean and smelly files
|
25
|
+
When I run reek --no-progress mixed_files
|
26
|
+
Then the exit status indicates smells
|
27
|
+
And it reports:
|
28
|
+
"""
|
29
|
+
mixed_files/dirty.rb -- 2 warnings:
|
30
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
31
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
32
|
+
2 total warnings
|
33
|
+
"""
|
@@ -52,7 +52,6 @@ Feature: Masking smells using config files
|
|
52
52
|
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
53
53
|
"""
|
54
54
|
|
55
|
-
|
56
55
|
Scenario: Disable UtilityFunction for non-public methods
|
57
56
|
Given the smelly file 'smelly_with_modifiers.rb'
|
58
57
|
And a configuration file 'non_public_modifiers_mask.reek'
|
@@ -8,18 +8,18 @@ Feature: Erroneous source comments are handled properly
|
|
8
8
|
re-run Reek.
|
9
9
|
|
10
10
|
Scenario: Unknown smell detector
|
11
|
-
Given a file named "
|
11
|
+
Given a file named "bad_comment.rb" with:
|
12
12
|
"""
|
13
13
|
# Test class
|
14
14
|
# :reek:UnknownDetectorName
|
15
15
|
def x
|
16
16
|
end
|
17
17
|
"""
|
18
|
-
When I run reek
|
18
|
+
When I run reek bad_comment.rb
|
19
19
|
Then it reports the error "Error: You are trying to configure an unknown smell detector 'UnknownDetectorName'"
|
20
20
|
|
21
21
|
Scenario: One good file, one bad file
|
22
|
-
Given a file named "
|
22
|
+
Given a file named "bad_comment.rb" with:
|
23
23
|
"""
|
24
24
|
# Test class
|
25
25
|
# :reek:UnknownDetectorName
|
@@ -27,7 +27,7 @@ Feature: Erroneous source comments are handled properly
|
|
27
27
|
end
|
28
28
|
"""
|
29
29
|
Given the smelly file 'smelly.rb'
|
30
|
-
When I run reek
|
30
|
+
When I run reek bad_comment.rb smelly.rb
|
31
31
|
Then it reports the error "Error: You are trying to configure an unknown smell detector 'UnknownDetectorName'"
|
32
32
|
And the exit status indicates smells
|
33
33
|
And it reports:
|
@@ -37,3 +37,17 @@ Feature: Erroneous source comments are handled properly
|
|
37
37
|
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
38
38
|
2 total warnings
|
39
39
|
"""
|
40
|
+
|
41
|
+
Scenario: Garbage as content
|
42
|
+
Given a file named "bad_comment.rb" with:
|
43
|
+
"""
|
44
|
+
# Test class
|
45
|
+
# :reek:UncommunicativeMethodName { thats: a: bad: config }
|
46
|
+
def x
|
47
|
+
end
|
48
|
+
"""
|
49
|
+
When I run reek bad_comment.rb
|
50
|
+
Then it reports the error "Error: You are trying to configure the smell detector 'UncommunicativeMethodName'"
|
51
|
+
And it reports the error "Unfortunately we can not parse the configuration you have given."
|
52
|
+
And it reports the error "The source is 'bad_comment.rb'"
|
53
|
+
And it reports the error "the comment belongs to the expression starting in line 3"
|
@@ -0,0 +1,116 @@
|
|
1
|
+
Feature: Well formed source comments are handled properly
|
2
|
+
As a developer I want to be able to have a fine-grained control
|
3
|
+
over how Reek handles smells via source code comments.
|
4
|
+
|
5
|
+
Scenario: Disable smell detector implicitly
|
6
|
+
Given a file named "disable_detector_implicitly.rb" with:
|
7
|
+
"""
|
8
|
+
# Test class
|
9
|
+
# :reek:TooManyInstanceVariables
|
10
|
+
class Alfa
|
11
|
+
def initialize
|
12
|
+
@charlie = @delta = @echo = @foxtrot = @hotel = 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
"""
|
16
|
+
When I run reek disable_detector_implicitly.rb
|
17
|
+
Then it succeeds
|
18
|
+
And it reports nothing
|
19
|
+
|
20
|
+
Scenario: Disable smell detector explicitly
|
21
|
+
Given a file named "disable_detector_explicitly.rb" with:
|
22
|
+
"""
|
23
|
+
# Test class
|
24
|
+
# :reek:TooManyInstanceVariables { enabled: false }
|
25
|
+
class Alfa
|
26
|
+
def initialize
|
27
|
+
@charlie = @delta = @echo = @foxtrot = @hotel = 1
|
28
|
+
end
|
29
|
+
end
|
30
|
+
"""
|
31
|
+
When I run reek disable_detector_explicitly.rb
|
32
|
+
Then it succeeds
|
33
|
+
And it reports nothing
|
34
|
+
|
35
|
+
Scenario: Enable smell detector explicitly
|
36
|
+
Given a file named "enable_detector_explicitly.rb" with:
|
37
|
+
"""
|
38
|
+
# Test class
|
39
|
+
# :reek:TooManyInstanceVariables { enabled: true }
|
40
|
+
class Alfa
|
41
|
+
def initialize
|
42
|
+
@charlie = @delta = @echo = @foxtrot = @hotel = 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
"""
|
46
|
+
When I run reek enable_detector_explicitly.rb
|
47
|
+
Then the exit status indicates smells
|
48
|
+
And it reports:
|
49
|
+
"""
|
50
|
+
enable_detector_explicitly.rb -- 1 warning:
|
51
|
+
[3]:TooManyInstanceVariables: Alfa has at least 5 instance variables [https://github.com/troessner/reek/blob/master/docs/Too-Many-Instance-Variables.md]
|
52
|
+
"""
|
53
|
+
|
54
|
+
Scenario: Configure smell detector with the basic exclude option as string
|
55
|
+
Given a file named "configure_exclude_option.rb" with:
|
56
|
+
"""
|
57
|
+
# Test class
|
58
|
+
# :reek:TooManyInstanceVariables { exclude: '@hotel' }
|
59
|
+
class Alfa
|
60
|
+
def initialize
|
61
|
+
@charlie = @delta = @echo = @foxtrot = @hotel = 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
"""
|
65
|
+
When I run reek configure_exclude_option.rb
|
66
|
+
Then it succeeds
|
67
|
+
And it reports nothing
|
68
|
+
|
69
|
+
Scenario: Configure smell detector with the basic exclude option as regex
|
70
|
+
Given a file named "configure_exclude_option.rb" with:
|
71
|
+
"""
|
72
|
+
# Test class
|
73
|
+
# :reek:TooManyInstanceVariables { exclude: /hotel/ }
|
74
|
+
class Alfa
|
75
|
+
def initialize
|
76
|
+
@charlie = @delta = @echo = @foxtrot = @hotel = 1
|
77
|
+
end
|
78
|
+
end
|
79
|
+
"""
|
80
|
+
When I run reek configure_exclude_option.rb
|
81
|
+
Then it succeeds
|
82
|
+
And it reports nothing
|
83
|
+
|
84
|
+
Scenario: Configure smell detector with a detector specific option that silences it
|
85
|
+
Given a file named "configure_detector_specific_option.rb" with:
|
86
|
+
"""
|
87
|
+
# Test class
|
88
|
+
# :reek:TooManyInstanceVariables { max_instance_variables: 5 }
|
89
|
+
class Alfa
|
90
|
+
def initialize
|
91
|
+
@charlie = @delta = @echo = @foxtrot = @hotel = 1
|
92
|
+
end
|
93
|
+
end
|
94
|
+
"""
|
95
|
+
When I run reek configure_detector_specific_option.rb
|
96
|
+
Then it succeeds
|
97
|
+
And it reports nothing
|
98
|
+
|
99
|
+
Scenario: Configure smell detector with a detector specific option that makes it report again
|
100
|
+
Given a file named "configure_detector_specific_option.rb" with:
|
101
|
+
"""
|
102
|
+
# Test class
|
103
|
+
# :reek:TooManyInstanceVariables { max_instance_variables: 2 }
|
104
|
+
class Alfa
|
105
|
+
def initialize
|
106
|
+
@charlie = @delta = @echo = 1
|
107
|
+
end
|
108
|
+
end
|
109
|
+
"""
|
110
|
+
When I run reek configure_detector_specific_option.rb
|
111
|
+
Then the exit status indicates smells
|
112
|
+
And it reports:
|
113
|
+
"""
|
114
|
+
configure_detector_specific_option.rb -- 1 warning:
|
115
|
+
[3]:TooManyInstanceVariables: Alfa has at least 3 instance variables [https://github.com/troessner/reek/blob/master/docs/Too-Many-Instance-Variables.md]
|
116
|
+
"""
|