reek 4.7.3 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codeclimate.yml +17 -12
- data/.rubocop.yml +18 -3
- data/.simplecov +1 -0
- data/.travis.yml +3 -4
- data/.yardopts +1 -1
- data/CHANGELOG.md +45 -0
- data/Gemfile +4 -4
- data/README.md +134 -104
- 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/Instance-Variable-Assumption.md +1 -1
- 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 +45 -6
- data/docs/Uncommunicative-Module-Name.md +49 -7
- data/docs/Uncommunicative-Parameter-Name.md +43 -5
- data/docs/Uncommunicative-Variable-Name.md +73 -2
- data/docs/Unused-Private-Method.md +2 -2
- data/docs/defaults.reek.yml +129 -0
- data/docs/yard_plugin.rb +1 -0
- data/features/command_line_interface/basic_usage.feature +2 -2
- data/features/command_line_interface/options.feature +46 -4
- data/features/command_line_interface/show_progress.feature +4 -4
- data/features/command_line_interface/smell_selection.feature +1 -1
- data/features/command_line_interface/smells_count.feature +6 -6
- data/features/command_line_interface/stdin.feature +30 -8
- data/features/configuration_files/accept_setting.feature +45 -28
- data/features/configuration_files/directory_specific_directives.feature +78 -73
- data/features/configuration_files/exclude_directives.feature +11 -10
- data/features/configuration_files/exclude_paths_directives.feature +4 -4
- data/features/configuration_files/masking_smells.feature +38 -9
- data/features/configuration_files/mix_accept_reject_setting.feature +31 -28
- data/features/configuration_files/reject_setting.feature +52 -41
- data/features/configuration_files/schema_validation.feature +59 -0
- data/features/configuration_files/unused_private_method.feature +18 -16
- data/features/configuration_loading.feature +53 -10
- data/features/configuration_via_source_comments/erroneous_source_comments.feature +2 -2
- data/features/configuration_via_source_comments/well_formed_source_comments.feature +2 -2
- data/features/locales.feature +2 -2
- data/features/rake_task/rake_task.feature +15 -15
- data/features/reports/json.feature +3 -3
- data/features/reports/reports.feature +34 -34
- data/features/reports/yaml.feature +3 -3
- data/features/rspec_matcher.feature +9 -1
- data/features/samples.feature +287 -287
- 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 +26 -23
- data/lib/reek/ast/node.rb +40 -55
- data/lib/reek/ast/object_refs.rb +1 -1
- data/lib/reek/ast/reference_collector.rb +2 -4
- data/lib/reek/ast/sexp_extensions/case.rb +1 -1
- data/lib/reek/ast/sexp_extensions/if.rb +8 -1
- data/lib/reek/ast/sexp_extensions/logical_operators.rb +1 -1
- data/lib/reek/ast/sexp_extensions/methods.rb +4 -6
- 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 +8 -8
- data/lib/reek/cli/options.rb +29 -14
- 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 +8 -11
- data/lib/reek/context/method_context.rb +7 -12
- data/lib/reek/context/module_context.rb +4 -4
- data/lib/reek/context_builder.rb +11 -11
- data/lib/reek/detector_repository.rb +6 -0
- data/lib/reek/documentation_link.rb +28 -0
- data/lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb +13 -12
- data/lib/reek/errors/bad_detector_in_comment_error.rb +11 -10
- data/lib/reek/errors/base_error.rb +3 -0
- data/lib/reek/errors/config_file_error.rb +11 -0
- data/lib/reek/errors/encoding_error.rb +16 -11
- data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +11 -10
- data/lib/reek/errors/incomprehensible_source_error.rb +20 -22
- data/lib/reek/errors/syntax_error.rb +41 -0
- data/lib/reek/examiner.rb +19 -25
- data/lib/reek/logging_error_handler.rb +7 -5
- data/lib/reek/rake/task.rb +3 -3
- data/lib/reek/report/base_report.rb +8 -12
- data/lib/reek/report/code_climate/code_climate_configuration.rb +1 -1
- data/lib/reek/report/code_climate/code_climate_configuration.yml +6 -10
- 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/report.rb +15 -10
- data/lib/reek/smell_configuration.rb +2 -2
- data/lib/reek/smell_detectors/attribute.rb +0 -1
- data/lib/reek/smell_detectors/base_detector.rb +9 -12
- data/lib/reek/smell_detectors/boolean_parameter.rb +0 -1
- data/lib/reek/smell_detectors/class_variable.rb +3 -11
- 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 +6 -7
- data/lib/reek/smell_detectors/feature_envy.rb +1 -1
- data/lib/reek/smell_detectors/instance_variable_assumption.rb +1 -10
- 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 +3 -3
- data/lib/reek/smell_detectors/{prima_donna_method.rb → missing_safe_method.rb} +6 -7
- data/lib/reek/smell_detectors/module_initialize.rb +1 -2
- data/lib/reek/smell_detectors/nested_iterators.rb +6 -6
- 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 +2 -3
- 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 +6 -7
- 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 +2 -3
- data/lib/reek/smell_detectors.rb +1 -2
- data/lib/reek/smell_warning.rb +15 -8
- data/lib/reek/source/source_code.rb +50 -72
- data/lib/reek/source/source_locator.rb +7 -7
- 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/spec.rb +6 -6
- data/lib/reek/tree_dresser.rb +5 -5
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +5 -5
- data/samples/checkstyle.xml +1 -1
- 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/configuration/partial_mask.reek +3 -2
- data/samples/configuration/regular_configuration/.reek.yml +4 -0
- data/samples/paths.rb +5 -4
- data/samples/source_with_hidden_directories/.hidden/hidden.rb +1 -0
- data/samples/source_with_hidden_directories/not_hidden.rb +1 -0
- data/spec/factories/factories.rb +2 -13
- data/spec/reek/ast/node_spec.rb +103 -10
- data/spec/reek/ast/reference_collector_spec.rb +1 -1
- data/spec/reek/ast/sexp_extensions_spec.rb +2 -2
- data/spec/reek/cli/application_spec.rb +50 -38
- data/spec/reek/cli/command/todo_list_command_spec.rb +6 -4
- data/spec/reek/cli/silencer_spec.rb +28 -0
- data/spec/reek/code_comment_spec.rb +31 -38
- data/spec/reek/configuration/app_configuration_spec.rb +46 -33
- 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 +6 -7
- data/spec/reek/configuration/excluded_paths_spec.rb +6 -6
- 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 +60 -96
- data/spec/reek/context/ghost_context_spec.rb +1 -1
- data/spec/reek/context/root_context_spec.rb +1 -1
- data/spec/reek/documentation_link_spec.rb +20 -0
- data/spec/reek/errors/base_error_spec.rb +13 -0
- data/spec/reek/examiner_spec.rb +100 -30
- data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +82 -80
- data/spec/reek/report/code_climate/code_climate_formatter_spec.rb +6 -6
- 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 +3 -3
- data/spec/reek/report/yaml_report_spec.rb +9 -38
- data/spec/reek/report_spec.rb +3 -3
- data/spec/reek/smell_detectors/boolean_parameter_spec.rb +2 -2
- data/spec/reek/smell_detectors/class_variable_spec.rb +26 -32
- data/spec/reek/smell_detectors/control_parameter_spec.rb +34 -4
- data/spec/reek/smell_detectors/duplicate_method_call_spec.rb +3 -3
- data/spec/reek/smell_detectors/feature_envy_spec.rb +47 -2
- data/spec/reek/smell_detectors/{prima_donna_method_spec.rb → missing_safe_method_spec.rb} +9 -9
- data/spec/reek/smell_detectors/module_initialize_spec.rb +14 -0
- data/spec/reek/smell_detectors/nested_iterators_spec.rb +1 -1
- 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 +9 -9
- data/spec/reek/smell_detectors/unused_parameters_spec.rb +3 -3
- data/spec/reek/smell_detectors/unused_private_method_spec.rb +10 -10
- data/spec/reek/smell_detectors/utility_function_spec.rb +5 -5
- data/spec/reek/smell_warning_spec.rb +12 -8
- data/spec/reek/source/source_code_spec.rb +17 -43
- data/spec/reek/source/source_locator_spec.rb +17 -17
- data/spec/reek/spec/should_reek_of_spec.rb +7 -11
- data/spec/reek/spec/should_reek_only_of_spec.rb +2 -2
- data/spec/reek/spec/should_reek_spec.rb +3 -3
- data/spec/reek/spec/smell_matcher_spec.rb +3 -3
- data/spec/reek/tree_dresser_spec.rb +12 -17
- data/spec/spec_helper.rb +6 -17
- data/tasks/configuration.rake +8 -5
- metadata +71 -41
- data/defaults.reek +0 -131
- data/features/configuration_files/warn_about_multiple_configuration_files.feature +0 -44
- 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 -36
- data/lib/reek/report/formatter.rb +0 -33
- 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
- /data/{samples/configuration/more_than_one_configuration_file/regular.reek → .reek.yml} +0 -0
- /data/samples/{clean.rb → clean_source/clean.rb} +0 -0
- /data/samples/{exceptions.reek → configuration/home/home.reek.yml} +0 -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/{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/uncommunicative_parameter_name.rb → source_with_non_ruby_files/ruby.rb} +0 -0
|
@@ -3,20 +3,25 @@ Feature: `accept` configuration setting
|
|
|
3
3
|
As a user
|
|
4
4
|
I want to be able to accept specific patterns and names to exclude them from reporting
|
|
5
5
|
|
|
6
|
-
Scenario: Accept names
|
|
6
|
+
Scenario: Accept names
|
|
7
7
|
Given a file named "config.reek" with:
|
|
8
8
|
"""
|
|
9
9
|
---
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
detectors:
|
|
11
|
+
UncommunicativeMethodName:
|
|
12
|
+
accept:
|
|
13
|
+
- m1
|
|
14
|
+
- m2
|
|
15
|
+
UncommunicativeParameterName:
|
|
16
|
+
accept:
|
|
17
|
+
- a1
|
|
18
|
+
- a2
|
|
19
|
+
UncommunicativeModuleName:
|
|
20
|
+
accept:
|
|
21
|
+
- C1
|
|
22
|
+
UncommunicativeVariableName:
|
|
23
|
+
accept:
|
|
24
|
+
- var1
|
|
20
25
|
"""
|
|
21
26
|
And a file named "smelly.rb" with:
|
|
22
27
|
"""
|
|
@@ -28,28 +33,37 @@ Feature: `accept` configuration setting
|
|
|
28
33
|
def m2(a2); a2; end
|
|
29
34
|
# Should report UncommunicativeMethodName and UncommunicativeParameterName
|
|
30
35
|
def m3(a3); a3; end
|
|
36
|
+
var1 = 2 # Should not report UncommunicativeVariableName
|
|
37
|
+
myvar1 = 2 # Should not report UncommunicativeVariableName
|
|
38
|
+
var2 = 2 # Should report UncommunicativeVariableName
|
|
31
39
|
end
|
|
32
40
|
"""
|
|
33
|
-
When I run
|
|
41
|
+
When I run reek -c config.reek smelly.rb
|
|
34
42
|
Then it reports:
|
|
35
43
|
"""
|
|
36
|
-
smelly.rb --
|
|
37
|
-
[8]:UncommunicativeMethodName: C1#m3 has the name 'm3'
|
|
38
|
-
[8]:UncommunicativeParameterName: C1#m3 has the parameter name 'a3'
|
|
44
|
+
smelly.rb -- 3 warnings:
|
|
45
|
+
[8]:UncommunicativeMethodName: C1#m3 has the name 'm3'
|
|
46
|
+
[8]:UncommunicativeParameterName: C1#m3 has the parameter name 'a3'
|
|
47
|
+
[11]:UncommunicativeVariableName: C1 has the variable name 'var2'
|
|
39
48
|
"""
|
|
40
49
|
|
|
41
|
-
Scenario: Accept regexes
|
|
50
|
+
Scenario: Accept regexes
|
|
42
51
|
Given a file named "config.reek" with:
|
|
43
52
|
"""
|
|
44
53
|
---
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
detectors:
|
|
55
|
+
UncommunicativeMethodName:
|
|
56
|
+
accept:
|
|
57
|
+
- /oobar/
|
|
58
|
+
UncommunicativeParameterName:
|
|
59
|
+
accept:
|
|
60
|
+
- /ola/
|
|
61
|
+
UncommunicativeModuleName:
|
|
62
|
+
accept:
|
|
63
|
+
- /lassy/
|
|
64
|
+
UncommunicativeVariableName:
|
|
65
|
+
accept:
|
|
66
|
+
- /^var1/
|
|
53
67
|
"""
|
|
54
68
|
And a file named "smelly.rb" with:
|
|
55
69
|
"""
|
|
@@ -59,12 +73,15 @@ Feature: `accept` configuration setting
|
|
|
59
73
|
def foobar1(hola1); hola1; end
|
|
60
74
|
# Should report UncommunicativeMethodName and UncommunicativeParameterName
|
|
61
75
|
def m2(a2); a2; end
|
|
76
|
+
var1 = 2 # Should not report UncommunicativeVariableName
|
|
77
|
+
myvar1 = 2 # Should report UncommunicativeVariableName
|
|
62
78
|
end
|
|
63
79
|
"""
|
|
64
|
-
When I run
|
|
80
|
+
When I run reek -c config.reek smelly.rb
|
|
65
81
|
Then it reports:
|
|
66
82
|
"""
|
|
67
|
-
smelly.rb --
|
|
68
|
-
[6]:UncommunicativeMethodName: Classy1#m2 has the name 'm2'
|
|
69
|
-
[6]:UncommunicativeParameterName: Classy1#m2 has the parameter name 'a2'
|
|
83
|
+
smelly.rb -- 3 warnings:
|
|
84
|
+
[6]:UncommunicativeMethodName: Classy1#m2 has the name 'm2'
|
|
85
|
+
[6]:UncommunicativeParameterName: Classy1#m2 has the parameter name 'a2'
|
|
86
|
+
[8]:UncommunicativeVariableName: Classy1 has the variable name 'myvar1'
|
|
70
87
|
"""
|
|
@@ -8,16 +8,17 @@ Feature: Directory directives
|
|
|
8
8
|
Given a file named "web_app/config.reek" with:
|
|
9
9
|
"""
|
|
10
10
|
---
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
directories:
|
|
12
|
+
"web_app/app/controllers":
|
|
13
|
+
IrresponsibleModule:
|
|
14
|
+
enabled: false
|
|
15
|
+
NestedIterators:
|
|
16
|
+
enabled: false
|
|
17
|
+
"web_app/app/helpers":
|
|
18
|
+
IrresponsibleModule:
|
|
19
|
+
enabled: false
|
|
20
|
+
UtilityFunction:
|
|
21
|
+
enabled: false
|
|
21
22
|
"""
|
|
22
23
|
And a file named "web_app/app/controllers/users_controller.rb" with:
|
|
23
24
|
"""
|
|
@@ -46,14 +47,14 @@ Feature: Directory directives
|
|
|
46
47
|
end
|
|
47
48
|
end
|
|
48
49
|
"""
|
|
49
|
-
When I run
|
|
50
|
+
When I run reek -c web_app/config.reek web_app/
|
|
50
51
|
Then it reports:
|
|
51
52
|
"""
|
|
52
53
|
web_app/app/controllers/users_controller.rb -- 1 warning:
|
|
53
|
-
[1]:InstanceVariableAssumption: UsersController assumes too much for instance variable '@user'
|
|
54
|
+
[1]:InstanceVariableAssumption: UsersController assumes too much for instance variable '@user'
|
|
54
55
|
web_app/app/models/user.rb -- 2 warnings:
|
|
55
|
-
[1]:IrresponsibleModule: User has no descriptive comment
|
|
56
|
-
[2]:UnusedParameters: User#logged_in_with_role has unused parameter 'role'
|
|
56
|
+
[1]:IrresponsibleModule: User has no descriptive comment
|
|
57
|
+
[2]:UnusedParameters: User#logged_in_with_role has unused parameter 'role'
|
|
57
58
|
3 total warnings
|
|
58
59
|
"""
|
|
59
60
|
|
|
@@ -61,9 +62,10 @@ Feature: Directory directives
|
|
|
61
62
|
Given a file named "web_app/config.reek" with:
|
|
62
63
|
"""
|
|
63
64
|
---
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
directories:
|
|
66
|
+
"controllers/":
|
|
67
|
+
IrresponsibleModule:
|
|
68
|
+
enabled: false
|
|
67
69
|
"""
|
|
68
70
|
And a file named "controllers/users_controller.rb" with:
|
|
69
71
|
"""
|
|
@@ -72,24 +74,25 @@ Feature: Directory directives
|
|
|
72
74
|
end
|
|
73
75
|
end
|
|
74
76
|
"""
|
|
75
|
-
When I run
|
|
77
|
+
When I run reek -c web_app/config.reek controllers
|
|
76
78
|
Then it reports nothing
|
|
77
79
|
|
|
78
80
|
Scenario: Partially mask smells in different directories
|
|
79
81
|
Given a file named "web_app/config.reek" with:
|
|
80
82
|
"""
|
|
81
83
|
---
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
directories:
|
|
85
|
+
"web_app/app/controllers":
|
|
86
|
+
IrresponsibleModule:
|
|
87
|
+
enabled: true
|
|
88
|
+
"web_app/app/helpers":
|
|
89
|
+
IrresponsibleModule:
|
|
90
|
+
enabled: false
|
|
91
|
+
UtilityFunction:
|
|
92
|
+
enabled: false
|
|
93
|
+
"web_app/app/models":
|
|
94
|
+
IrresponsibleModule:
|
|
95
|
+
enabled: false
|
|
93
96
|
"""
|
|
94
97
|
And a file named "web_app/app/controllers/users_controller.rb" with:
|
|
95
98
|
"""
|
|
@@ -117,15 +120,15 @@ Feature: Directory directives
|
|
|
117
120
|
end
|
|
118
121
|
end
|
|
119
122
|
"""
|
|
120
|
-
When I run
|
|
123
|
+
When I run reek -c web_app/config.reek web_app/
|
|
121
124
|
Then it reports:
|
|
122
125
|
"""
|
|
123
126
|
web_app/app/controllers/users_controller.rb -- 3 warnings:
|
|
124
|
-
[1]:InstanceVariableAssumption: UsersController assumes too much for instance variable '@user'
|
|
125
|
-
[1]:IrresponsibleModule: UsersController has no descriptive comment
|
|
126
|
-
[4]:NestedIterators: UsersController#show contains iterators nested 2 deep
|
|
127
|
+
[1]:InstanceVariableAssumption: UsersController assumes too much for instance variable '@user'
|
|
128
|
+
[1]:IrresponsibleModule: UsersController has no descriptive comment
|
|
129
|
+
[4]:NestedIterators: UsersController#show contains iterators nested 2 deep
|
|
127
130
|
web_app/app/models/user.rb -- 1 warning:
|
|
128
|
-
[2]:UnusedParameters: User#logged_in_with_role has unused parameter 'role'
|
|
131
|
+
[2]:UnusedParameters: User#logged_in_with_role has unused parameter 'role'
|
|
129
132
|
4 total warnings
|
|
130
133
|
"""
|
|
131
134
|
|
|
@@ -133,15 +136,17 @@ Feature: Directory directives
|
|
|
133
136
|
Given a file named "config.reek" with:
|
|
134
137
|
"""
|
|
135
138
|
---
|
|
136
|
-
|
|
139
|
+
directories:
|
|
140
|
+
"web_app/app/controllers":
|
|
141
|
+
IrresponsibleModule:
|
|
142
|
+
enabled: true
|
|
143
|
+
NestedIterators:
|
|
144
|
+
enabled: false
|
|
145
|
+
detectors:
|
|
137
146
|
IrresponsibleModule:
|
|
138
|
-
enabled: true
|
|
139
|
-
NestedIterators:
|
|
140
147
|
enabled: false
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
NestedIterators:
|
|
144
|
-
enabled: true
|
|
148
|
+
NestedIterators:
|
|
149
|
+
enabled: true
|
|
145
150
|
"""
|
|
146
151
|
And a file named "web_app/app/controllers/users_controller.rb" with:
|
|
147
152
|
"""
|
|
@@ -163,15 +168,15 @@ Feature: Directory directives
|
|
|
163
168
|
end
|
|
164
169
|
end
|
|
165
170
|
"""
|
|
166
|
-
When I run
|
|
171
|
+
When I run reek -c config.reek other/ web_app/
|
|
167
172
|
Then it reports:
|
|
168
173
|
"""
|
|
169
174
|
other/projects_controller.rb -- 2 warnings:
|
|
170
|
-
[1]:InstanceVariableAssumption: ProjectController assumes too much for instance variable '@project'
|
|
171
|
-
[4]:NestedIterators: ProjectController#show contains iterators nested 2 deep
|
|
175
|
+
[1]:InstanceVariableAssumption: ProjectController assumes too much for instance variable '@project'
|
|
176
|
+
[4]:NestedIterators: ProjectController#show contains iterators nested 2 deep
|
|
172
177
|
web_app/app/controllers/users_controller.rb -- 2 warnings:
|
|
173
|
-
[1]:InstanceVariableAssumption: UsersController assumes too much for instance variable '@user'
|
|
174
|
-
[1]:IrresponsibleModule: UsersController has no descriptive comment
|
|
178
|
+
[1]:InstanceVariableAssumption: UsersController assumes too much for instance variable '@user'
|
|
179
|
+
[1]:IrresponsibleModule: UsersController has no descriptive comment
|
|
175
180
|
4 total warnings
|
|
176
181
|
"""
|
|
177
182
|
|
|
@@ -179,10 +184,11 @@ Feature: Directory directives
|
|
|
179
184
|
Given a file named "config.reek" with:
|
|
180
185
|
"""
|
|
181
186
|
---
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
directories:
|
|
188
|
+
"dummy_directory":
|
|
189
|
+
# Typo: Should be NestedIterators
|
|
190
|
+
IteratorsNested:
|
|
191
|
+
enabled: false
|
|
186
192
|
"""
|
|
187
193
|
And a file named "dummy_directory/dummy.rb" with:
|
|
188
194
|
"""
|
|
@@ -190,34 +196,32 @@ Feature: Directory directives
|
|
|
190
196
|
end
|
|
191
197
|
"""
|
|
192
198
|
|
|
193
|
-
When I run
|
|
199
|
+
When I run reek -c config.reek dummy_directory/
|
|
194
200
|
Then the exit status indicates an error
|
|
195
201
|
And stderr reports:
|
|
196
202
|
"""
|
|
197
|
-
|
|
198
|
-
Please make sure you spelled it right. (See 'defaults.reek' in the Reek
|
|
199
|
-
repository for a list of all available smell types.)
|
|
200
|
-
|
|
203
|
+
Error: We found some problems with your configuration file: [/directories/dummy_directory/IteratorsNested] key 'IteratorsNested:' is undefined.
|
|
201
204
|
"""
|
|
202
205
|
|
|
203
206
|
Scenario: Abort on file as directory directive
|
|
204
207
|
Given a file named "config.reek" with:
|
|
205
208
|
"""
|
|
206
209
|
---
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
+
directories:
|
|
211
|
+
"dummy_directory/dummy.rb":
|
|
212
|
+
NestedIterators:
|
|
213
|
+
enabled: false
|
|
210
214
|
"""
|
|
211
215
|
And a file named "dummy_directory/dummy.rb" with:
|
|
212
216
|
"""
|
|
213
217
|
class Dummy
|
|
214
218
|
end
|
|
215
219
|
"""
|
|
216
|
-
When I run
|
|
220
|
+
When I run reek -c config.reek dummy_directory/
|
|
217
221
|
Then the exit status indicates an error
|
|
218
222
|
And stderr reports:
|
|
219
223
|
"""
|
|
220
|
-
|
|
224
|
+
Error: `dummy_directory/dummy.rb` is supposed to be a directory but is a file
|
|
221
225
|
|
|
222
226
|
"""
|
|
223
227
|
|
|
@@ -225,16 +229,17 @@ Feature: Directory directives
|
|
|
225
229
|
Given a file named "config.reek" with:
|
|
226
230
|
"""
|
|
227
231
|
---
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
232
|
+
directories:
|
|
233
|
+
"foo/bar/baz":
|
|
234
|
+
IrresponsibleModule:
|
|
235
|
+
enabled: false
|
|
236
|
+
NestedIterators:
|
|
237
|
+
enabled: true
|
|
238
|
+
"foo/bar":
|
|
239
|
+
IrresponsibleModule:
|
|
240
|
+
enabled: true
|
|
241
|
+
NestedIterators:
|
|
242
|
+
enabled: false
|
|
238
243
|
"""
|
|
239
244
|
And a file named "foo/bar/baz/klass.rb" with:
|
|
240
245
|
"""
|
|
@@ -258,12 +263,12 @@ Feature: Directory directives
|
|
|
258
263
|
end
|
|
259
264
|
end
|
|
260
265
|
"""
|
|
261
|
-
When I run
|
|
266
|
+
When I run reek -c config.reek foo/
|
|
262
267
|
Then it reports:
|
|
263
268
|
"""
|
|
264
269
|
foo/bar/baz/klass.rb -- 1 warning:
|
|
265
|
-
[4]:NestedIterators: Klass#meth contains iterators nested 2 deep
|
|
270
|
+
[4]:NestedIterators: Klass#meth contains iterators nested 2 deep
|
|
266
271
|
foo/bar/klazz.rb -- 1 warning:
|
|
267
|
-
[1]:IrresponsibleModule: Klazz has no descriptive comment
|
|
272
|
+
[1]:IrresponsibleModule: Klazz has no descriptive comment
|
|
268
273
|
2 total warnings
|
|
269
274
|
"""
|
|
@@ -7,13 +7,14 @@ Feature: Exclude directives
|
|
|
7
7
|
Given a file named "config.reek" with:
|
|
8
8
|
"""
|
|
9
9
|
---
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
detectors:
|
|
11
|
+
UncommunicativeMethodName:
|
|
12
|
+
exclude:
|
|
13
|
+
- "Smelly#x"
|
|
14
|
+
UnusedPrivateMethod:
|
|
15
|
+
enabled: true
|
|
16
|
+
exclude:
|
|
17
|
+
- "Smelly#foobar"
|
|
17
18
|
"""
|
|
18
19
|
And a file named "smelly.rb" with:
|
|
19
20
|
"""
|
|
@@ -25,10 +26,10 @@ Feature: Exclude directives
|
|
|
25
26
|
def foobar; end # Should not report UnusedPrivateMethod
|
|
26
27
|
end
|
|
27
28
|
"""
|
|
28
|
-
When I run
|
|
29
|
+
When I run reek -c config.reek smelly.rb
|
|
29
30
|
Then it reports:
|
|
30
31
|
"""
|
|
31
32
|
smelly.rb -- 2 warnings:
|
|
32
|
-
[1]:IrresponsibleModule: Smelly has no descriptive comment
|
|
33
|
-
[3]:UnusedParameters: Smelly#foo has unused parameter 'arg'
|
|
33
|
+
[1]:IrresponsibleModule: Smelly has no descriptive comment
|
|
34
|
+
[3]:UnusedParameters: Smelly#foo has unused parameter 'arg'
|
|
34
35
|
"""
|
|
@@ -11,7 +11,7 @@ Feature: Exclude paths directives
|
|
|
11
11
|
def alfa(bravo); end
|
|
12
12
|
end
|
|
13
13
|
"""
|
|
14
|
-
When I run
|
|
14
|
+
When I run reek .
|
|
15
15
|
Then the exit status indicates smells
|
|
16
16
|
Given a file named "config.reek" with:
|
|
17
17
|
"""
|
|
@@ -19,7 +19,7 @@ Feature: Exclude paths directives
|
|
|
19
19
|
exclude_paths:
|
|
20
20
|
- bad_files_live_here
|
|
21
21
|
"""
|
|
22
|
-
When I run
|
|
22
|
+
When I run reek -c config.reek .
|
|
23
23
|
Then it succeeds
|
|
24
24
|
And it reports nothing
|
|
25
25
|
Scenario: Using a file name within an excluded directory
|
|
@@ -36,8 +36,8 @@ Feature: Exclude paths directives
|
|
|
36
36
|
exclude_paths:
|
|
37
37
|
- bad_files_live_here
|
|
38
38
|
"""
|
|
39
|
-
When I run
|
|
39
|
+
When I run reek -c config.reek bad_files_live_here/smelly.rb
|
|
40
40
|
Then the exit status indicates smells
|
|
41
|
-
When I run
|
|
41
|
+
When I run reek -c config.reek --force-exclusion bad_files_live_here/smelly.rb
|
|
42
42
|
Then it succeeds
|
|
43
43
|
And it reports nothing
|
|
@@ -7,7 +7,10 @@ Feature: Masking smells using config files
|
|
|
7
7
|
Given the smelly file 'smelly.rb'
|
|
8
8
|
And a configuration file 'corrupt.reek'
|
|
9
9
|
When I run reek -c corrupt.reek smelly.rb
|
|
10
|
-
|
|
10
|
+
And stderr reports:
|
|
11
|
+
"""
|
|
12
|
+
Error: We found some problems with your configuration file: [/] 'Not a valid configuration file': not a mapping.
|
|
13
|
+
"""
|
|
11
14
|
And the exit status indicates an error
|
|
12
15
|
And it reports nothing
|
|
13
16
|
|
|
@@ -30,11 +33,21 @@ Feature: Masking smells using config files
|
|
|
30
33
|
And it reports:
|
|
31
34
|
"""
|
|
32
35
|
smelly.rb -- 1 warning:
|
|
33
|
-
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
|
|
36
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
|
|
34
37
|
"""
|
|
35
38
|
|
|
36
39
|
Scenario: provide extra masking inline in comments
|
|
37
|
-
Given
|
|
40
|
+
Given a file named "smelly_with_inline_mask.rb" with:
|
|
41
|
+
"""
|
|
42
|
+
# Smelly class
|
|
43
|
+
# disables :reek:UncommunicativeVariableName
|
|
44
|
+
class Smelly
|
|
45
|
+
# This will reek of UncommunicativeMethodName
|
|
46
|
+
def x
|
|
47
|
+
y = 10 # This will NOT reek of UncommunicativeVariableName
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
"""
|
|
38
51
|
And a configuration file 'partial_mask.reek'
|
|
39
52
|
When I run reek -c partial_mask.reek smelly_with_inline_mask.rb
|
|
40
53
|
Then it succeeds
|
|
@@ -48,18 +61,34 @@ Feature: Masking smells using config files
|
|
|
48
61
|
And it reports:
|
|
49
62
|
"""
|
|
50
63
|
smelly.rb -- 2 warnings:
|
|
51
|
-
[4]:UncommunicativeMethodName: Smelly#x has the name 'x'
|
|
52
|
-
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
|
|
64
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x'
|
|
65
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
|
|
53
66
|
"""
|
|
54
67
|
|
|
55
68
|
Scenario: Disable UtilityFunction for non-public methods
|
|
56
|
-
Given
|
|
57
|
-
|
|
58
|
-
|
|
69
|
+
Given a file named "smelly_with_modifiers.rb" with:
|
|
70
|
+
"""
|
|
71
|
+
# Smelly class for testing purposes
|
|
72
|
+
class Klass
|
|
73
|
+
def public_method(arg) arg.to_s; end
|
|
74
|
+
protected
|
|
75
|
+
def protected_method(arg) arg.to_s; end
|
|
76
|
+
private
|
|
77
|
+
def private_method(arg) arg.to_s; end
|
|
78
|
+
end
|
|
79
|
+
"""
|
|
80
|
+
And a file named "non_public_modifiers_mask.reek.yml" with:
|
|
81
|
+
"""
|
|
82
|
+
---
|
|
83
|
+
detectors:
|
|
84
|
+
UtilityFunction:
|
|
85
|
+
public_methods_only: true
|
|
86
|
+
"""
|
|
87
|
+
When I run reek -c non_public_modifiers_mask.reek.yml smelly_with_modifiers.rb
|
|
59
88
|
Then the exit status indicates smells
|
|
60
89
|
And it reports:
|
|
61
90
|
"""
|
|
62
91
|
smelly_with_modifiers.rb -- 1 warning:
|
|
63
|
-
[
|
|
92
|
+
[3]:UtilityFunction: Klass#public_method doesn't depend on instance state (maybe move it to another class?)
|
|
64
93
|
"""
|
|
65
94
|
But it does not report private or protected methods
|
|
@@ -7,13 +7,14 @@ Feature: Mix `accept` and `reject` configuration settings
|
|
|
7
7
|
Given a file named "config.reek" with:
|
|
8
8
|
"""
|
|
9
9
|
---
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
detectors:
|
|
11
|
+
UncommunicativeMethodName:
|
|
12
|
+
accept:
|
|
13
|
+
- x
|
|
14
|
+
- meth1
|
|
15
|
+
reject:
|
|
16
|
+
- helper
|
|
17
|
+
- foobar
|
|
17
18
|
"""
|
|
18
19
|
And a file named "smelly.rb" with:
|
|
19
20
|
"""
|
|
@@ -22,26 +23,27 @@ Feature: Mix `accept` and `reject` configuration settings
|
|
|
22
23
|
def foobar; end # Should be reported
|
|
23
24
|
def awesome_helper; end # Should be reported
|
|
24
25
|
"""
|
|
25
|
-
When I run
|
|
26
|
+
When I run reek -c config.reek smelly.rb
|
|
26
27
|
Then it reports:
|
|
27
28
|
"""
|
|
28
29
|
smelly.rb -- 2 warnings:
|
|
29
|
-
[4]:UncommunicativeMethodName: awesome_helper has the name 'awesome_helper'
|
|
30
|
-
[3]:UncommunicativeMethodName: foobar has the name 'foobar'
|
|
30
|
+
[4]:UncommunicativeMethodName: awesome_helper has the name 'awesome_helper'
|
|
31
|
+
[3]:UncommunicativeMethodName: foobar has the name 'foobar'
|
|
31
32
|
"""
|
|
32
33
|
|
|
33
34
|
Scenario: UncommunicativeModuleName
|
|
34
35
|
Given a file named "config.reek" with:
|
|
35
36
|
"""
|
|
36
37
|
---
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
detectors:
|
|
39
|
+
IrresponsibleModule:
|
|
40
|
+
enabled: false
|
|
41
|
+
UncommunicativeModuleName:
|
|
42
|
+
accept:
|
|
43
|
+
- lassy
|
|
44
|
+
- M
|
|
45
|
+
reject:
|
|
46
|
+
- Helper
|
|
45
47
|
"""
|
|
46
48
|
And a file named "smelly.rb" with:
|
|
47
49
|
"""
|
|
@@ -49,23 +51,24 @@ Feature: Mix `accept` and `reject` configuration settings
|
|
|
49
51
|
class M; end # Should not be reported
|
|
50
52
|
class BaseHelper; end # Should be reported
|
|
51
53
|
"""
|
|
52
|
-
When I run
|
|
54
|
+
When I run reek -c config.reek smelly.rb
|
|
53
55
|
Then it reports:
|
|
54
56
|
"""
|
|
55
57
|
smelly.rb -- 1 warning:
|
|
56
|
-
[3]:UncommunicativeModuleName: BaseHelper has the name 'BaseHelper'
|
|
58
|
+
[3]:UncommunicativeModuleName: BaseHelper has the name 'BaseHelper'
|
|
57
59
|
"""
|
|
58
60
|
|
|
59
61
|
Scenario: UncommunicativeParameterName
|
|
60
62
|
Given a file named "config.reek" with:
|
|
61
63
|
"""
|
|
62
64
|
---
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
detectors:
|
|
66
|
+
UncommunicativeParameterName:
|
|
67
|
+
accept:
|
|
68
|
+
- x
|
|
69
|
+
- arg1
|
|
70
|
+
reject:
|
|
71
|
+
- foobar
|
|
69
72
|
"""
|
|
70
73
|
And a file named "smelly.rb" with:
|
|
71
74
|
"""
|
|
@@ -73,9 +76,9 @@ Feature: Mix `accept` and `reject` configuration settings
|
|
|
73
76
|
def omg(arg1); arg1; end # Should not be reported
|
|
74
77
|
def omg(foobar); foobar; end # Should be reported
|
|
75
78
|
"""
|
|
76
|
-
When I run
|
|
79
|
+
When I run reek -c config.reek smelly.rb
|
|
77
80
|
Then it reports:
|
|
78
81
|
"""
|
|
79
82
|
smelly.rb -- 1 warning:
|
|
80
|
-
[3]:UncommunicativeParameterName: omg has the parameter name 'foobar'
|
|
83
|
+
[3]:UncommunicativeParameterName: omg has the parameter name 'foobar'
|
|
81
84
|
"""
|