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
@@ -37,13 +37,14 @@ Feature: Reek can be controlled using command-line options
|
|
37
37
|
reek -s lib
|
38
38
|
cat my_class.rb | reek
|
39
39
|
|
40
|
-
See https://
|
40
|
+
See https://github.com/troessner/reek for detailed help.
|
41
41
|
|
42
42
|
Configuration:
|
43
43
|
-c, --config FILE Read configuration options from FILE
|
44
44
|
--smell SMELL Only look for a specific smell.
|
45
|
-
Call it like this: reek --smell
|
46
|
-
Check out https://github.com/troessner/reek/blob/
|
45
|
+
Call it like this: reek --smell MissingSafeMethod source.rb
|
46
|
+
Check out https://github.com/troessner/reek/blob/v5.0.0/docs/Code-Smells.md for a list of smells
|
47
|
+
--stdin-filename FILE When passing code in via pipe, assume this filename when checking file or directory rules in the config.
|
47
48
|
|
48
49
|
Generate a todo list:
|
49
50
|
-t, --todo Generate a todo list
|
@@ -60,7 +61,7 @@ Feature: Reek can be controlled using command-line options
|
|
60
61
|
Text format options:
|
61
62
|
--[no-]color Use colors for the output (default: true)
|
62
63
|
-V, --[no-]empty-headings Show headings for smell-free source files (default: false)
|
63
|
-
-U, --[no-]
|
64
|
+
-U, --[no-]documentation Show link to related documentation page for each smell (default: true)
|
64
65
|
-n, --[no-]line-numbers Show line numbers in the output (default: true)
|
65
66
|
-s, --single-line Show location in editor-compatible single-line-per-smell format
|
66
67
|
-P, --[no-]progress Show progress of each source as it is examined (default: true)
|
@@ -76,5 +77,46 @@ Feature: Reek can be controlled using command-line options
|
|
76
77
|
|
77
78
|
Utility options:
|
78
79
|
-h, --help Show this message
|
80
|
+
-l, --list List all available smell detectors
|
79
81
|
-v, --version Show version
|
80
82
|
"""
|
83
|
+
|
84
|
+
Scenario: List all available smell detectors
|
85
|
+
When I run reek --list
|
86
|
+
Then it succeeds
|
87
|
+
And it reports:
|
88
|
+
"""
|
89
|
+
All available smell detectors:
|
90
|
+
|
91
|
+
Attribute
|
92
|
+
BooleanParameter
|
93
|
+
ClassVariable
|
94
|
+
ControlParameter
|
95
|
+
DataClump
|
96
|
+
DuplicateMethodCall
|
97
|
+
FeatureEnvy
|
98
|
+
InstanceVariableAssumption
|
99
|
+
IrresponsibleModule
|
100
|
+
LongParameterList
|
101
|
+
LongYieldList
|
102
|
+
ManualDispatch
|
103
|
+
MissingSafeMethod
|
104
|
+
ModuleInitialize
|
105
|
+
NestedIterators
|
106
|
+
NilCheck
|
107
|
+
RepeatedConditional
|
108
|
+
SubclassedFromCoreClass
|
109
|
+
TooManyConstants
|
110
|
+
TooManyInstanceVariables
|
111
|
+
TooManyMethods
|
112
|
+
TooManyStatements
|
113
|
+
UncommunicativeMethodName
|
114
|
+
UncommunicativeModuleName
|
115
|
+
UncommunicativeParameterName
|
116
|
+
UncommunicativeVariableName
|
117
|
+
UnusedParameters
|
118
|
+
UnusedPrivateMethod
|
119
|
+
UtilityFunction
|
120
|
+
|
121
|
+
Check out https://github.com/troessner/reek/blob/v5.0.0/docs/Code-Smells.md for a details on each detector
|
122
|
+
"""
|
@@ -34,10 +34,32 @@ Feature: Reek reads from $stdin when no files are given
|
|
34
34
|
|
35
35
|
Scenario: syntax error causes the source to be ignored
|
36
36
|
When I pass "= invalid syntax =" to reek
|
37
|
-
Then
|
38
|
-
And it reports:
|
37
|
+
Then it succeeds
|
38
|
+
And it reports the error "Parser::SyntaxError: unexpected token tEQL"
|
39
|
+
|
40
|
+
Scenario: providing a filename to use for the config to match against
|
41
|
+
Given a file named "web_app/config.reek" with:
|
39
42
|
"""
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
+
---
|
44
|
+
directories:
|
45
|
+
"web_app/app/controllers":
|
46
|
+
IrresponsibleModule:
|
47
|
+
enabled: false
|
48
|
+
NestedIterators:
|
49
|
+
enabled: false
|
50
|
+
InstanceVariableAssumption:
|
51
|
+
enabled: false
|
43
52
|
"""
|
53
|
+
When I pass a stdin to reek --config web_app/config.reek --stdin-filename web_app/app/controllers/users_controller with:
|
54
|
+
"""
|
55
|
+
class UsersController < ApplicationController
|
56
|
+
def show
|
57
|
+
respond_with do |format|
|
58
|
+
format.json { |json| @user.to_custom_json }
|
59
|
+
format.xml { |xml| @user.to_fancy_xml }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
"""
|
64
|
+
Then it succeeds
|
65
|
+
And it reports nothing
|
@@ -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
41
|
When I run reek -c config.reek smelly.rb
|
34
42
|
Then it reports:
|
35
43
|
"""
|
36
|
-
smelly.rb --
|
44
|
+
smelly.rb -- 3 warnings:
|
37
45
|
[8]:UncommunicativeMethodName: C1#m3 has the name 'm3'
|
38
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
80
|
When I run reek -c config.reek smelly.rb
|
65
81
|
Then it reports:
|
66
82
|
"""
|
67
|
-
smelly.rb --
|
83
|
+
smelly.rb -- 3 warnings:
|
68
84
|
[6]:UncommunicativeMethodName: Classy1#m2 has the name 'm2'
|
69
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
|
"""
|
@@ -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
|
"""
|
@@ -79,17 +81,18 @@ Feature: Directory directives
|
|
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
|
"""
|
@@ -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
|
"""
|
@@ -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
|
"""
|
@@ -194,19 +200,17 @@ Feature: Directory directives
|
|
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
|
"""
|
@@ -217,7 +221,7 @@ Feature: Directory directives
|
|
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
|
"""
|
@@ -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
|
"""
|
@@ -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
|
|
@@ -34,7 +37,17 @@ Feature: Masking smells using config files
|
|
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
|
@@ -53,13 +66,29 @@ Feature: Masking smells using config files
|
|
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
|