reek 4.8.2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/{samples/configuration/more_than_one_configuration_file/regular.reek → .reek.yml} +0 -0
- data/.rubocop.yml +17 -3
- data/.simplecov +1 -0
- data/.travis.yml +0 -5
- data/.yardopts +1 -1
- data/CHANGELOG.md +28 -0
- data/Gemfile +1 -1
- data/README.md +113 -98
- data/Rakefile +16 -3
- data/bin/reek +1 -3
- data/docs/API.md +2 -9
- data/docs/Basic-Smell-Options.md +51 -11
- data/docs/Code-Smells.md +1 -1
- data/docs/Command-Line-Options.md +14 -4
- data/docs/Duplicate-Method-Call.md +49 -1
- data/docs/Feature-Envy.md +44 -0
- data/docs/How-To-Write-New-Detectors.md +2 -3
- data/docs/{Prima-Donna-Method.md → Missing-Safe-Method.md} +11 -9
- data/docs/Rake-Task.md +1 -1
- data/docs/Reek-4-to-Reek-5-migration.md +193 -0
- data/docs/Reek-Driven-Development.md +1 -1
- data/docs/Uncommunicative-Method-Name.md +43 -4
- data/docs/Uncommunicative-Module-Name.md +48 -6
- data/docs/Uncommunicative-Parameter-Name.md +42 -4
- data/docs/Uncommunicative-Variable-Name.md +73 -2
- data/docs/Unused-Private-Method.md +1 -1
- data/docs/defaults.reek.yml +129 -0
- data/docs/yard_plugin.rb +1 -0
- data/features/command_line_interface/options.feature +46 -4
- data/features/command_line_interface/stdin.feature +27 -5
- data/features/configuration_files/accept_setting.feature +39 -22
- data/features/configuration_files/directory_specific_directives.feature +58 -53
- data/features/configuration_files/exclude_directives.feature +8 -7
- data/features/configuration_files/masking_smells.feature +35 -6
- data/features/configuration_files/mix_accept_reject_setting.feature +24 -21
- data/features/configuration_files/reject_setting.feature +45 -34
- data/features/configuration_files/schema_validation.feature +59 -0
- data/features/configuration_files/unused_private_method.feature +14 -12
- data/features/configuration_loading.feature +50 -7
- data/features/rake_task/rake_task.feature +5 -5
- data/features/reports/json.feature +4 -1
- data/features/reports/reports.feature +12 -12
- data/features/reports/yaml.feature +3 -0
- data/features/rspec_matcher.feature +9 -1
- data/features/step_definitions/reek_steps.rb +4 -0
- data/features/step_definitions/sample_file_steps.rb +9 -4
- data/features/support/env.rb +2 -2
- data/features/todo_list.feature +16 -13
- data/lib/reek/ast/node.rb +3 -6
- data/lib/reek/ast/object_refs.rb +1 -1
- data/lib/reek/ast/sexp_extensions/if.rb +1 -1
- data/lib/reek/ast/sexp_extensions/methods.rb +1 -1
- data/lib/reek/cli/application.rb +4 -3
- data/lib/reek/cli/command/report_command.rb +1 -2
- data/lib/reek/cli/command/todo_list_command.rb +4 -2
- data/lib/reek/cli/options.rb +27 -13
- data/lib/reek/cli/silencer.rb +14 -3
- data/lib/reek/code_comment.rb +14 -16
- data/lib/reek/configuration/app_configuration.rb +32 -28
- data/lib/reek/configuration/configuration_converter.rb +110 -0
- data/lib/reek/configuration/configuration_file_finder.rb +15 -40
- data/lib/reek/configuration/configuration_validator.rb +12 -23
- data/lib/reek/configuration/default_directive.rb +17 -3
- data/lib/reek/configuration/directory_directives.rb +17 -11
- data/lib/reek/configuration/excluded_paths.rb +1 -1
- data/lib/reek/configuration/rake_task_converter.rb +29 -0
- data/lib/reek/configuration/schema.yml +210 -0
- data/lib/reek/configuration/schema_validator.rb +38 -0
- data/lib/reek/context/attribute_context.rb +1 -1
- data/lib/reek/context/code_context.rb +4 -4
- data/lib/reek/context/method_context.rb +2 -2
- data/lib/reek/context/module_context.rb +1 -1
- data/lib/reek/context_builder.rb +9 -9
- data/lib/reek/detector_repository.rb +6 -0
- data/lib/reek/documentation_link.rb +2 -2
- data/lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb +1 -1
- data/lib/reek/errors/bad_detector_in_comment_error.rb +1 -1
- data/lib/reek/errors/config_file_error.rb +11 -0
- data/lib/reek/errors/encoding_error.rb +2 -2
- data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +1 -1
- data/lib/reek/errors/incomprehensible_source_error.rb +2 -2
- data/lib/reek/errors/syntax_error.rb +41 -0
- data/lib/reek/examiner.rb +9 -19
- data/lib/reek/rake/task.rb +3 -3
- data/lib/reek/report.rb +15 -10
- data/lib/reek/report/base_report.rb +8 -12
- data/lib/reek/report/code_climate/code_climate_configuration.yml +5 -9
- data/lib/reek/report/documentation_link_warning_formatter.rb +17 -0
- data/lib/reek/report/heading_formatter.rb +54 -0
- data/lib/reek/report/json_report.rb +1 -1
- data/lib/reek/report/location_formatter.rb +40 -0
- data/lib/reek/report/progress_formatter.rb +79 -0
- data/lib/reek/report/simple_warning_formatter.rb +34 -0
- data/lib/reek/report/text_report.rb +1 -2
- data/lib/reek/report/xml_report.rb +3 -3
- data/lib/reek/report/yaml_report.rb +1 -1
- data/lib/reek/smell_configuration.rb +2 -2
- data/lib/reek/smell_detectors.rb +1 -2
- data/lib/reek/smell_detectors/attribute.rb +0 -1
- data/lib/reek/smell_detectors/base_detector.rb +8 -11
- data/lib/reek/smell_detectors/boolean_parameter.rb +0 -1
- data/lib/reek/smell_detectors/class_variable.rb +0 -1
- data/lib/reek/smell_detectors/control_parameter.rb +17 -32
- data/lib/reek/smell_detectors/data_clump.rb +3 -4
- data/lib/reek/smell_detectors/duplicate_method_call.rb +5 -6
- data/lib/reek/smell_detectors/feature_envy.rb +0 -1
- data/lib/reek/smell_detectors/instance_variable_assumption.rb +0 -1
- data/lib/reek/smell_detectors/irresponsible_module.rb +0 -1
- data/lib/reek/smell_detectors/long_parameter_list.rb +1 -2
- data/lib/reek/smell_detectors/long_yield_list.rb +2 -3
- data/lib/reek/smell_detectors/manual_dispatch.rb +2 -2
- data/lib/reek/smell_detectors/{prima_donna_method.rb → missing_safe_method.rb} +6 -7
- data/lib/reek/smell_detectors/module_initialize.rb +0 -1
- data/lib/reek/smell_detectors/nested_iterators.rb +4 -5
- data/lib/reek/smell_detectors/nil_check.rb +0 -1
- data/lib/reek/smell_detectors/repeated_conditional.rb +3 -4
- data/lib/reek/smell_detectors/subclassed_from_core_class.rb +0 -1
- data/lib/reek/smell_detectors/too_many_constants.rb +1 -2
- data/lib/reek/smell_detectors/too_many_instance_variables.rb +1 -2
- data/lib/reek/smell_detectors/too_many_methods.rb +1 -2
- data/lib/reek/smell_detectors/too_many_statements.rb +1 -2
- data/lib/reek/smell_detectors/uncommunicative_method_name.rb +2 -3
- data/lib/reek/smell_detectors/uncommunicative_module_name.rb +2 -3
- data/lib/reek/smell_detectors/uncommunicative_parameter_name.rb +2 -3
- data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +4 -5
- data/lib/reek/smell_detectors/unused_parameters.rb +0 -1
- data/lib/reek/smell_detectors/unused_private_method.rb +0 -1
- data/lib/reek/smell_detectors/utility_function.rb +1 -2
- data/lib/reek/smell_warning.rb +10 -8
- data/lib/reek/source/source_code.rb +40 -55
- data/lib/reek/source/source_locator.rb +7 -7
- data/lib/reek/spec.rb +6 -6
- data/lib/reek/spec/should_reek.rb +2 -2
- data/lib/reek/spec/should_reek_of.rb +9 -16
- data/lib/reek/spec/should_reek_only_of.rb +4 -4
- data/lib/reek/tree_dresser.rb +5 -5
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +3 -3
- data/samples/checkstyle.xml +1 -1
- data/samples/{clean.rb → clean_source/clean.rb} +0 -0
- data/samples/configuration/accepts_rejects_and_excludes_for_detectors.reek.yml +29 -0
- data/samples/configuration/accepts_rejects_and_excludes_for_directory_directives.reek.yml +30 -0
- data/samples/configuration/full_configuration.reek +8 -4
- data/samples/configuration/full_mask.reek +5 -4
- data/samples/{exceptions.reek → configuration/home/home.reek.yml} +0 -0
- data/samples/configuration/partial_mask.reek +3 -2
- data/samples/configuration/regular_configuration/.reek.yml +4 -0
- data/samples/configuration/{more_than_one_configuration_file/todo.reek → regular_configuration/empty_sub_directory/.gitignore} +0 -0
- data/samples/{configuration/single_configuration_file/.reek → no_config_file/.keep} +0 -0
- data/samples/paths.rb +5 -4
- data/samples/{inline.rb → smelly_source/inline.rb} +0 -0
- data/samples/{optparse.rb → smelly_source/optparse.rb} +0 -0
- data/samples/{redcloth.rb → smelly_source/redcloth.rb} +0 -0
- data/samples/{smelly.rb → smelly_source/smelly.rb} +0 -0
- data/samples/source_with_hidden_directories/.hidden/hidden.rb +1 -0
- data/samples/source_with_hidden_directories/not_hidden.rb +1 -0
- data/samples/{source_with_hidden_directories/uncommunicative_parameter_name.rb → source_with_non_ruby_files/ruby.rb} +0 -0
- data/spec/reek/ast/node_spec.rb +5 -5
- data/spec/reek/cli/application_spec.rb +18 -4
- data/spec/reek/cli/command/todo_list_command_spec.rb +4 -2
- data/spec/reek/cli/silencer_spec.rb +28 -0
- data/spec/reek/code_comment_spec.rb +0 -7
- data/spec/reek/configuration/app_configuration_spec.rb +44 -31
- data/spec/reek/configuration/configuration_file_finder_spec.rb +133 -49
- data/spec/reek/configuration/default_directive_spec.rb +1 -1
- data/spec/reek/configuration/directory_directives_spec.rb +3 -4
- data/spec/reek/configuration/excluded_paths_spec.rb +5 -5
- data/spec/reek/configuration/rake_task_converter_spec.rb +33 -0
- data/spec/reek/configuration/schema_validator_spec.rb +165 -0
- data/spec/reek/context/code_context_spec.rb +1 -1
- data/spec/reek/examiner_spec.rb +28 -1
- data/spec/reek/report/json_report_spec.rb +13 -46
- data/spec/reek/report/{formatter/location_formatter_spec.rb → location_formatter_spec.rb} +5 -5
- data/spec/reek/report/{formatter/progress_formatter_spec.rb → progress_formatter_spec.rb} +4 -4
- data/spec/reek/report/text_report_spec.rb +4 -4
- data/spec/reek/report/xml_report_spec.rb +1 -1
- data/spec/reek/report/yaml_report_spec.rb +9 -38
- data/spec/reek/report_spec.rb +3 -3
- data/spec/reek/smell_detectors/feature_envy_spec.rb +2 -2
- data/spec/reek/smell_detectors/{prima_donna_method_spec.rb → missing_safe_method_spec.rb} +9 -9
- data/spec/reek/smell_detectors/too_many_constants_spec.rb +3 -3
- data/spec/reek/smell_detectors/too_many_instance_variables_spec.rb +1 -1
- data/spec/reek/smell_detectors/uncommunicative_method_name_spec.rb +6 -6
- data/spec/reek/smell_detectors/uncommunicative_module_name_spec.rb +6 -4
- data/spec/reek/smell_detectors/uncommunicative_parameter_name_spec.rb +6 -4
- data/spec/reek/smell_detectors/uncommunicative_variable_name_spec.rb +6 -6
- data/spec/reek/smell_detectors/unused_private_method_spec.rb +1 -1
- data/spec/reek/smell_warning_spec.rb +4 -0
- data/spec/reek/source/source_code_spec.rb +16 -22
- data/spec/reek/source/source_locator_spec.rb +11 -11
- data/spec/reek/spec/should_reek_of_spec.rb +0 -4
- data/spec/reek/spec/should_reek_only_of_spec.rb +2 -2
- data/spec/reek/spec/should_reek_spec.rb +1 -1
- data/spec/reek/tree_dresser_spec.rb +2 -6
- data/spec/spec_helper.rb +3 -5
- data/tasks/configuration.rake +8 -5
- metadata +56 -35
- data/defaults.reek +0 -131
- data/features/configuration_files/warn_about_multiple_configuration_files.feature +0 -44
- data/lib/reek/report/formatter.rb +0 -33
- data/lib/reek/report/formatter/heading_formatter.rb +0 -52
- data/lib/reek/report/formatter/location_formatter.rb +0 -42
- data/lib/reek/report/formatter/progress_formatter.rb +0 -81
- data/lib/reek/report/formatter/simple_warning_formatter.rb +0 -35
- data/lib/reek/report/formatter/wiki_link_warning_formatter.rb +0 -23
- data/lib/reek/smell_detectors/syntax.rb +0 -37
- data/samples/configuration/non_public_modifiers_mask.reek +0 -3
- data/samples/smelly_with_inline_mask.rb +0 -8
- data/samples/smelly_with_modifiers.rb +0 -12
- data/samples/source_with_hidden_directories/.hidden/uncommunicative_method_name.rb +0 -5
- data/samples/source_with_non_ruby_files/uncommunicative_parameter_name.rb +0 -6
- data/spec/reek/smell_detectors/syntax_spec.rb +0 -17
@@ -14,7 +14,7 @@ Reek::Rake::Task.new do |t|
|
|
14
14
|
end
|
15
15
|
```
|
16
16
|
|
17
|
-
Now the command `reek` will run Reek on your source code (and in this case, it fails if it finds any smells). For more detailed information about Reek's integration with Rake, see [Rake Task](Rake-Task.md)
|
17
|
+
Now the command `reek` will run Reek on your source code (and in this case, it fails if it finds any smells). For more detailed information about Reek's integration with Rake, see [Rake Task](Rake-Task.md).
|
18
18
|
|
19
19
|
## reek/spec
|
20
20
|
|
@@ -21,8 +21,8 @@ Reek's _Uncommunicative Method Name_ detector supports the
|
|
21
21
|
|
22
22
|
| Option | Value | Effect |
|
23
23
|
| ---------------|-------------|---------|
|
24
|
-
| `reject` | array of
|
25
|
-
| `accept` | array of
|
24
|
+
| `reject` | array of strings | The set of names that Reek uses to check for bad names. Defaults to single-letter names, names ending with a number or names containing upper case letters. |
|
25
|
+
| `accept` | array of strings | The set of names that Reek will accept (and not report) even if they match one of the `reject` expressions. |
|
26
26
|
|
27
27
|
An example configuration could look like this:
|
28
28
|
|
@@ -30,13 +30,15 @@ An example configuration could look like this:
|
|
30
30
|
---
|
31
31
|
UncommunicativeMethodName:
|
32
32
|
accept:
|
33
|
-
-
|
33
|
+
- x
|
34
34
|
- meth1
|
35
35
|
reject:
|
36
|
-
-
|
36
|
+
- helper
|
37
37
|
- foobar
|
38
38
|
```
|
39
39
|
|
40
|
+
Reek will convert whatever you give it as a string to the corresponding regex, so "foobar" from above will be converted to /foobar/ internally.
|
41
|
+
|
40
42
|
Applying a configuration to a source file like this:
|
41
43
|
|
42
44
|
```Ruby
|
@@ -53,3 +55,40 @@ smelly.rb -- 2 warnings:
|
|
53
55
|
[4]:UncommunicativeMethodName: awesome_helper has the name 'awesome_helper'
|
54
56
|
[3]:UncommunicativeMethodName: foobar has the name 'foobar'
|
55
57
|
```
|
58
|
+
|
59
|
+
## Advanced configuration
|
60
|
+
|
61
|
+
Sometimes just strings are not enough for configuration. E.g. consider this code sample:
|
62
|
+
|
63
|
+
```Ruby
|
64
|
+
class Klass
|
65
|
+
def foo; end
|
66
|
+
def foobar; end;
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
and now imagine that you want to reject the name "foo" but not "foobar". This wouldn't be possible with just using strings.
|
71
|
+
For this reason Reek has a special syntax that allows you to use regexes by using a forward slash at the beginning and the end of the string.
|
72
|
+
Everything within the forward slashes will be loaded as a regex.
|
73
|
+
|
74
|
+
A possible configuration that allows "foobar" but rejects "foo" could look like this:
|
75
|
+
|
76
|
+
```Yaml
|
77
|
+
---
|
78
|
+
UncommunicativeMethodName:
|
79
|
+
reject:
|
80
|
+
- "/^foo$/"
|
81
|
+
```
|
82
|
+
|
83
|
+
## Reek 4
|
84
|
+
|
85
|
+
In Reek 4 you could also pass regexes to `accept` or `reject`, meaning this was perfectly valid as well:
|
86
|
+
|
87
|
+
```yaml
|
88
|
+
UncommunicativeMethodName:
|
89
|
+
accept:
|
90
|
+
- !ruby/regexp /foobar/
|
91
|
+
```
|
92
|
+
|
93
|
+
Support for this has been scrapped with Reek 5 to make the Reek configuration more yaml standard compliant.
|
94
|
+
You can still pass in regexes, you just have to wrap them into a string. Please see "Advanced configuration" above.
|
@@ -19,8 +19,8 @@ Reek's _Uncommunicative Module Name_ detector supports the [Basic Smell Options]
|
|
19
19
|
|
20
20
|
| Option | Value | Effect |
|
21
21
|
| ---------------|-------------|---------|
|
22
|
-
| `reject` | array of
|
23
|
-
| `accept` | array
|
22
|
+
| `reject` | array of strings | The set of names that Reek uses to check for bad names. Defaults to single-letter names and names ending with a number. |
|
23
|
+
| `accept` | array or strings | The set of names that Reek will accept (and not report) even if they match one of the `reject` expressions. Empty by default.|
|
24
24
|
|
25
25
|
An example configuration could look like this:
|
26
26
|
|
@@ -28,17 +28,19 @@ An example configuration could look like this:
|
|
28
28
|
---
|
29
29
|
UncommunicativeModuleName:
|
30
30
|
accept:
|
31
|
-
-
|
32
|
-
-
|
31
|
+
- lassy
|
32
|
+
- Util
|
33
33
|
reject:
|
34
|
-
-
|
34
|
+
- Helper
|
35
35
|
```
|
36
36
|
|
37
|
+
Reek will convert whatever you give it as a string to the corresponding regex, so "Helper" from above will be converted to /Helper/ internally.
|
38
|
+
|
37
39
|
Applying a configuration to a source file like this:
|
38
40
|
|
39
41
|
```Ruby
|
40
42
|
class Classy1; end # Should not be reported
|
41
|
-
class
|
43
|
+
class Util; end # Should not be reported
|
42
44
|
class BaseHelper; end # Should be reported
|
43
45
|
```
|
44
46
|
|
@@ -48,3 +50,43 @@ Reek would report:
|
|
48
50
|
smelly.rb -- 1 warning:
|
49
51
|
[3]:UncommunicativeModuleName: BaseHelper has the name 'BaseHelper'
|
50
52
|
```
|
53
|
+
|
54
|
+
## Advanced configuration
|
55
|
+
|
56
|
+
Sometimes just strings are not enough for configuration. E.g. consider this code sample:
|
57
|
+
|
58
|
+
```Ruby
|
59
|
+
class Klassy
|
60
|
+
# ...
|
61
|
+
end
|
62
|
+
|
63
|
+
class KlassyModule
|
64
|
+
# ...
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
68
|
+
and now imagine that you want to reject the name "Klassy" but not "KlassyModule". This wouldn't be possible with just using strings.
|
69
|
+
For this reason Reek has a special syntax that allows you to use regexes by using a forward slash at the beginning and the end of the string.
|
70
|
+
Everything within the forward slashes will be loaded as a regex.
|
71
|
+
|
72
|
+
A possible configuration that allows "KlassyModule" but rejects "Klassy" could look like this:
|
73
|
+
|
74
|
+
```Yaml
|
75
|
+
---
|
76
|
+
UncommunicativeModuleName:
|
77
|
+
reject:
|
78
|
+
- "/^Klassy$/"
|
79
|
+
```
|
80
|
+
|
81
|
+
## Reek 4
|
82
|
+
|
83
|
+
In Reek 4 you could also pass regexes to `accept` or `reject`, meaning this was perfectly valid as well:
|
84
|
+
|
85
|
+
```yaml
|
86
|
+
UncommunicativeModuleName:
|
87
|
+
accept:
|
88
|
+
- !ruby/regexp /foobar/
|
89
|
+
```
|
90
|
+
|
91
|
+
Support for this has been scrapped with Reek 5 to make the Reek configuration more yaml standard compliant.
|
92
|
+
You can still pass in regexes, you just have to wrap them into a string. Please see "Advanced configuration" above.
|
@@ -20,8 +20,8 @@ Reek's _Uncommunicative Parameter Name_ detector supports the [Basic Smell Optio
|
|
20
20
|
|
21
21
|
| Option | Value | Effect |
|
22
22
|
| ---------|-------------|---------|
|
23
|
-
| `reject` | array of
|
24
|
-
| `accept` | array of
|
23
|
+
| `reject` | array of strings | The set of names that Reek uses to check for bad names. Defaults to single-letter names, names containing an uppercase letter, names with a number at the end and '_'. |
|
24
|
+
| `accept` | array of strings | The set of names that Reek will accept (and not report) even if they match one of the `reject` expressions. |
|
25
25
|
|
26
26
|
|
27
27
|
An example configuration could look like this:
|
@@ -30,12 +30,14 @@ An example configuration could look like this:
|
|
30
30
|
---
|
31
31
|
UncommunicativeParameterName:
|
32
32
|
accept:
|
33
|
-
-
|
33
|
+
- x
|
34
34
|
- arg1
|
35
35
|
reject:
|
36
|
-
-
|
36
|
+
- foobar
|
37
37
|
```
|
38
38
|
|
39
|
+
Reek will convert whatever you give it as a string to the corresponding regex, so "foobar" from above will be converted to /foobar/ internally.
|
40
|
+
|
39
41
|
Applying a configuration to a source file like this:
|
40
42
|
|
41
43
|
```Ruby
|
@@ -50,3 +52,39 @@ Reek would report:
|
|
50
52
|
smelly.rb -- 1 warning:
|
51
53
|
[3]:UncommunicativeParameterName: omg has the parameter name 'foobar'
|
52
54
|
```
|
55
|
+
|
56
|
+
## Advanced configuration
|
57
|
+
|
58
|
+
Sometimes just strings are not enough for configuration. E.g. consider this code sample:
|
59
|
+
|
60
|
+
```Ruby
|
61
|
+
class Klass
|
62
|
+
def my_method(foo, foobar); end
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
and now imagine that you want to reject the name "foo" but not "foobar". This wouldn't be possible with just using strings.
|
67
|
+
For this reason Reek has a special syntax that allows you to use regexes by using a forward slash at the beginning and the end of the string.
|
68
|
+
Everything within the forward slashes will be loaded as a regex.
|
69
|
+
|
70
|
+
A possible configuration that allows "foobar" but rejects "foo" could look like this:
|
71
|
+
|
72
|
+
```Yaml
|
73
|
+
---
|
74
|
+
UncommunicativeParameterName:
|
75
|
+
reject:
|
76
|
+
- "/^foo$/"
|
77
|
+
```
|
78
|
+
|
79
|
+
## Reek 4
|
80
|
+
|
81
|
+
In Reek 4 you could also pass regexes to `accept` or `reject`, meaning this was perfectly valid as well:
|
82
|
+
|
83
|
+
```yaml
|
84
|
+
UncommunicativeParameterName:
|
85
|
+
accept:
|
86
|
+
- !ruby/regexp /foobar/
|
87
|
+
```
|
88
|
+
|
89
|
+
Support for this has been scrapped with Reek 5 to make the Reek configuration more yaml standard compliant.
|
90
|
+
You can still pass in regexes, you just have to wrap them into a string. Please see "Advanced configuration" above.
|
@@ -21,5 +21,76 @@ Reek's _Uncommunicative Variable Name_ detector supports the
|
|
21
21
|
|
22
22
|
| Option | Value | Effect |
|
23
23
|
| ---------------|-------------|---------|
|
24
|
-
| `reject` | array of
|
25
|
-
| `accept` | array of strings
|
24
|
+
| `reject` | array of strings | The set of names that Reek uses to check for bad names. Defaults to single-letter names, names ending with a number or names containing upper case letters. |
|
25
|
+
| `accept` | array of strings | Names that will be accepted (not reported) even if they match one of the `reject` expressions. Defaults to `_`.|
|
26
|
+
|
27
|
+
An example configuration could look like this:
|
28
|
+
|
29
|
+
```Yaml
|
30
|
+
---
|
31
|
+
UncommunicativeVariableName:
|
32
|
+
accept:
|
33
|
+
- x
|
34
|
+
- var1
|
35
|
+
reject:
|
36
|
+
- helper
|
37
|
+
- foobar
|
38
|
+
```
|
39
|
+
|
40
|
+
Reek will convert whatever you give it as a string to the corresponding regex, so "foobar" from above will be converted to /foobar/ internally.
|
41
|
+
|
42
|
+
Applying a configuration to a source file like this:
|
43
|
+
|
44
|
+
```Ruby
|
45
|
+
def omg
|
46
|
+
x = 5 # Should not be reported
|
47
|
+
var1 = true # Should not be reported
|
48
|
+
helper = 42 # Should be reported
|
49
|
+
foobar = false # Should be reported
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
Reek would report:
|
54
|
+
|
55
|
+
```
|
56
|
+
smelly.rb -- 2 warnings:
|
57
|
+
[5]:UncommunicativeVariableName: omg has the variable name 'foobar' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
58
|
+
[4]:UncommunicativeVariableName: omg has the variable name 'helper' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
59
|
+
```
|
60
|
+
|
61
|
+
## Advanced configuration
|
62
|
+
|
63
|
+
Sometimes just strings are not enough for configuration. E.g. consider this code sample:
|
64
|
+
|
65
|
+
```Ruby
|
66
|
+
def omg
|
67
|
+
foo = 42
|
68
|
+
foobar = 4242
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
and now imagine that you want to reject the name "foo" but not "foobar". This wouldn't be possible with just using strings.
|
73
|
+
For this reason Reek has a special syntax that allows you to use regexes by using a forward slash at the beginning and the end of the string.
|
74
|
+
Everything within the forward slashes will be loaded as a regex.
|
75
|
+
|
76
|
+
A possible configuration that allows "foobar" but rejects "foo" could look like this:
|
77
|
+
|
78
|
+
```Yaml
|
79
|
+
---
|
80
|
+
UncommunicativeVariableName:
|
81
|
+
reject:
|
82
|
+
- "/^foo$/"
|
83
|
+
```
|
84
|
+
|
85
|
+
## Reek 4
|
86
|
+
|
87
|
+
In Reek 4 you could also pass regexes to `accept` or `reject`, meaning this was perfectly valid as well:
|
88
|
+
|
89
|
+
```yaml
|
90
|
+
UncommunicativeVariableName:
|
91
|
+
accept:
|
92
|
+
- !ruby/regexp /write/
|
93
|
+
```
|
94
|
+
|
95
|
+
Support for this has been scrapped with Reek 5 to make the Reek configuration more yaml standard compliant.
|
96
|
+
You can still pass in regexes, you just have to wrap them into a string. Please see "Advanced configuration" above.
|
@@ -37,7 +37,7 @@ configuration option (which is part of the [Basic Smell Options](Basic-Smell-Opt
|
|
37
37
|
for instance like this (an example from Reek's own codebase):
|
38
38
|
|
39
39
|
```Ruby
|
40
|
-
# :reek:UnusedPrivateMethod { exclude: [
|
40
|
+
# :reek:UnusedPrivateMethod { exclude: [ process_ ] }
|
41
41
|
class ContextBuilder
|
42
42
|
def process_begin
|
43
43
|
# ....
|
@@ -0,0 +1,129 @@
|
|
1
|
+
---
|
2
|
+
detectors:
|
3
|
+
Attribute:
|
4
|
+
enabled: true
|
5
|
+
exclude: []
|
6
|
+
BooleanParameter:
|
7
|
+
enabled: true
|
8
|
+
exclude: []
|
9
|
+
ClassVariable:
|
10
|
+
enabled: true
|
11
|
+
exclude: []
|
12
|
+
ControlParameter:
|
13
|
+
enabled: true
|
14
|
+
exclude: []
|
15
|
+
DataClump:
|
16
|
+
enabled: true
|
17
|
+
exclude: []
|
18
|
+
max_copies: 2
|
19
|
+
min_clump_size: 2
|
20
|
+
DuplicateMethodCall:
|
21
|
+
enabled: true
|
22
|
+
exclude: []
|
23
|
+
max_calls: 1
|
24
|
+
allow_calls: []
|
25
|
+
FeatureEnvy:
|
26
|
+
enabled: true
|
27
|
+
exclude: []
|
28
|
+
InstanceVariableAssumption:
|
29
|
+
enabled: true
|
30
|
+
exclude: []
|
31
|
+
IrresponsibleModule:
|
32
|
+
enabled: true
|
33
|
+
exclude: []
|
34
|
+
LongParameterList:
|
35
|
+
enabled: true
|
36
|
+
exclude: []
|
37
|
+
max_params: 3
|
38
|
+
overrides:
|
39
|
+
initialize:
|
40
|
+
max_params: 5
|
41
|
+
LongYieldList:
|
42
|
+
enabled: true
|
43
|
+
exclude: []
|
44
|
+
max_params: 3
|
45
|
+
ManualDispatch:
|
46
|
+
enabled: true
|
47
|
+
exclude: []
|
48
|
+
MissingSafeMethod:
|
49
|
+
enabled: true
|
50
|
+
exclude: []
|
51
|
+
ModuleInitialize:
|
52
|
+
enabled: true
|
53
|
+
exclude: []
|
54
|
+
NestedIterators:
|
55
|
+
enabled: true
|
56
|
+
exclude: []
|
57
|
+
max_allowed_nesting: 1
|
58
|
+
ignore_iterators:
|
59
|
+
- tap
|
60
|
+
NilCheck:
|
61
|
+
enabled: true
|
62
|
+
exclude: []
|
63
|
+
RepeatedConditional:
|
64
|
+
enabled: true
|
65
|
+
exclude: []
|
66
|
+
max_ifs: 2
|
67
|
+
SubclassedFromCoreClass:
|
68
|
+
enabled: true
|
69
|
+
exclude: []
|
70
|
+
TooManyConstants:
|
71
|
+
enabled: true
|
72
|
+
exclude: []
|
73
|
+
max_constants: 5
|
74
|
+
TooManyInstanceVariables:
|
75
|
+
enabled: true
|
76
|
+
exclude: []
|
77
|
+
max_instance_variables: 4
|
78
|
+
TooManyMethods:
|
79
|
+
enabled: true
|
80
|
+
exclude: []
|
81
|
+
max_methods: 15
|
82
|
+
TooManyStatements:
|
83
|
+
enabled: true
|
84
|
+
exclude:
|
85
|
+
- initialize
|
86
|
+
max_statements: 5
|
87
|
+
UncommunicativeMethodName:
|
88
|
+
enabled: true
|
89
|
+
exclude: []
|
90
|
+
reject:
|
91
|
+
- "/^[a-z]$/"
|
92
|
+
- "/[0-9]$/"
|
93
|
+
- "/[A-Z]/"
|
94
|
+
accept: []
|
95
|
+
UncommunicativeModuleName:
|
96
|
+
enabled: true
|
97
|
+
exclude: []
|
98
|
+
reject:
|
99
|
+
- "/^.$/"
|
100
|
+
- "/[0-9]$/"
|
101
|
+
accept: []
|
102
|
+
UncommunicativeParameterName:
|
103
|
+
enabled: true
|
104
|
+
exclude: []
|
105
|
+
reject:
|
106
|
+
- "/^.$/"
|
107
|
+
- "/[0-9]$/"
|
108
|
+
- "/[A-Z]/"
|
109
|
+
- "/^_/"
|
110
|
+
accept: []
|
111
|
+
UncommunicativeVariableName:
|
112
|
+
enabled: true
|
113
|
+
exclude: []
|
114
|
+
reject:
|
115
|
+
- "/^.$/"
|
116
|
+
- "/[0-9]$/"
|
117
|
+
- "/[A-Z]/"
|
118
|
+
accept:
|
119
|
+
- "/^_$/"
|
120
|
+
UnusedParameters:
|
121
|
+
enabled: true
|
122
|
+
exclude: []
|
123
|
+
UnusedPrivateMethod:
|
124
|
+
enabled: false
|
125
|
+
exclude: []
|
126
|
+
UtilityFunction:
|
127
|
+
enabled: true
|
128
|
+
exclude: []
|
129
|
+
public_methods_only: false
|
data/docs/yard_plugin.rb
CHANGED
@@ -13,4 +13,5 @@ end
|
|
13
13
|
|
14
14
|
YARD::Templates::Template.extra_includes << LocalLinkHelper
|
15
15
|
YARD::Tags::Library.define_tag('Guaranteed public API', :public)
|
16
|
+
YARD::Tags::Library.define_tag('Code quality configuration', :quality)
|
16
17
|
YARD::Templates::Engine.register_template_path File.join(File.dirname(__FILE__), 'templates')
|