reek 4.2.3 → 4.2.4
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/.rubocop.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +7 -6
- data/Gemfile +2 -2
- data/README.md +8 -15
- data/Rakefile +1 -1
- data/defaults.reek +1 -0
- data/features/command_line_interface/basic_usage.feature +8 -14
- data/features/command_line_interface/smell_selection.feature +4 -4
- data/features/command_line_interface/smells_count.feature +12 -14
- data/features/configuration_files/masking_smells.feature +31 -24
- data/features/configuration_loading.feature +15 -18
- data/features/programmatic_access.feature +7 -9
- data/features/rake_task/rake_task.feature +20 -24
- data/features/reports/json.feature +16 -28
- data/features/reports/reports.feature +56 -67
- data/features/reports/yaml.feature +13 -26
- data/features/samples.feature +3 -3
- data/features/step_definitions/sample_file_steps.rb +22 -156
- data/features/todo_list.feature +13 -14
- data/lib/reek/cli/options.rb +1 -1
- data/lib/reek/examiner.rb +45 -10
- data/lib/reek/smells/attribute.rb +3 -4
- data/lib/reek/smells/boolean_parameter.rb +2 -2
- data/lib/reek/smells/class_variable.rb +1 -1
- data/lib/reek/smells/control_parameter.rb +4 -4
- data/lib/reek/smells/data_clump.rb +2 -3
- data/lib/reek/smells/duplicate_method_call.rb +1 -1
- data/lib/reek/smells/feature_envy.rb +2 -2
- data/lib/reek/smells/irresponsible_module.rb +2 -3
- data/lib/reek/smells/long_parameter_list.rb +1 -1
- data/lib/reek/smells/long_yield_list.rb +1 -1
- data/lib/reek/smells/module_initialize.rb +1 -1
- data/lib/reek/smells/nested_iterators.rb +2 -2
- data/lib/reek/smells/nil_check.rb +1 -1
- data/lib/reek/smells/prima_donna_method.rb +5 -2
- data/lib/reek/smells/repeated_conditional.rb +1 -1
- data/lib/reek/smells/smell_detector.rb +1 -1
- data/lib/reek/smells/smell_warning.rb +6 -5
- data/lib/reek/smells/subclassed_from_core_class.rb +3 -3
- data/lib/reek/smells/too_many_constants.rb +1 -1
- data/lib/reek/smells/too_many_instance_variables.rb +1 -1
- data/lib/reek/smells/too_many_methods.rb +1 -1
- data/lib/reek/smells/too_many_statements.rb +1 -1
- data/lib/reek/smells/uncommunicative_method_name.rb +1 -1
- data/lib/reek/smells/uncommunicative_module_name.rb +1 -1
- data/lib/reek/smells/uncommunicative_parameter_name.rb +1 -1
- data/lib/reek/smells/uncommunicative_variable_name.rb +1 -1
- data/lib/reek/smells/unused_parameters.rb +1 -1
- data/lib/reek/smells/unused_private_method.rb +1 -1
- data/lib/reek/smells/utility_function.rb +2 -3
- data/lib/reek/spec/should_reek_of.rb +14 -1
- data/lib/reek/version.rb +1 -1
- data/samples/checkstyle.xml +7 -0
- data/samples/clean.rb +6 -0
- data/samples/configuration/.reek +0 -0
- data/samples/configuration/corrupt.reek +1 -0
- data/samples/configuration/empty.reek +0 -0
- data/samples/configuration/full_configuration.reek +9 -0
- data/{spec/samples/configuration/simple_configuration.reek → samples/configuration/full_mask.reek} +2 -2
- data/samples/configuration/non_public_modifiers_mask.reek +3 -0
- data/samples/configuration/partial_mask.reek +3 -0
- data/samples/configuration/with_excluded_paths.reek +4 -0
- data/{spec/samples → samples}/exceptions.reek +0 -0
- data/{spec/samples → samples}/inline.rb +0 -0
- data/{spec/samples → samples}/optparse.rb +0 -0
- data/samples/paths.rb +4 -0
- data/{spec/samples → samples}/redcloth.rb +0 -0
- data/samples/smelly.rb +7 -0
- data/samples/smelly_with_inline_mask.rb +8 -0
- data/samples/smelly_with_modifiers.rb +12 -0
- data/{spec/samples → samples}/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb +0 -0
- data/{spec/samples → samples}/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb +0 -0
- data/{spec/samples → samples}/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb +0 -0
- data/{spec/samples → samples}/source_with_hidden_directories/.hidden/uncommunicative_method_name.rb +0 -0
- data/{spec/samples → samples}/source_with_hidden_directories/uncommunicative_parameter_name.rb +0 -0
- data/{spec/samples → samples}/source_with_non_ruby_files/gibberish +0 -0
- data/{spec/samples → samples}/source_with_non_ruby_files/python_source.py +0 -0
- data/{spec/samples → samples}/source_with_non_ruby_files/uncommunicative_parameter_name.rb +0 -0
- data/spec/reek/cli/application_spec.rb +1 -1
- data/spec/reek/cli/command/report_command_spec.rb +2 -5
- data/spec/reek/configuration/app_configuration_spec.rb +10 -8
- data/spec/reek/configuration/configuration_file_finder_spec.rb +24 -17
- data/spec/reek/examiner_spec.rb +84 -5
- data/spec/reek/report/json_report_spec.rb +1 -3
- data/spec/reek/report/xml_report_spec.rb +2 -3
- data/spec/reek/report/yaml_report_spec.rb +0 -2
- data/spec/reek/smells/attribute_spec.rb +21 -10
- data/spec/reek/smells/boolean_parameter_spec.rb +13 -12
- data/spec/reek/smells/class_variable_spec.rb +4 -4
- data/spec/reek/smells/control_parameter_spec.rb +25 -18
- data/spec/reek/smells/data_clump_spec.rb +5 -5
- data/spec/reek/smells/duplicate_method_call_spec.rb +1 -1
- data/spec/reek/smells/feature_envy_spec.rb +8 -2
- data/spec/reek/smells/irresponsible_module_spec.rb +16 -14
- data/spec/reek/smells/long_parameter_list_spec.rb +5 -1
- data/spec/reek/smells/long_yield_list_spec.rb +5 -2
- data/spec/reek/smells/nested_iterators_spec.rb +37 -13
- data/spec/reek/smells/nil_check_spec.rb +50 -53
- data/spec/reek/smells/prima_donna_method_spec.rb +9 -1
- data/spec/reek/smells/too_many_instance_variables_spec.rb +1 -1
- data/spec/reek/smells/too_many_methods_spec.rb +4 -4
- data/spec/reek/smells/too_many_statements_spec.rb +1 -1
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +3 -3
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +3 -3
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +3 -3
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +3 -3
- data/spec/reek/smells/utility_function_spec.rb +12 -8
- data/spec/reek/source/source_locator_spec.rb +5 -1
- data/spec/reek/spec/should_reek_of_spec.rb +20 -13
- data/spec/reek/spec/should_reek_spec.rb +6 -11
- data/spec/spec_helper.rb +2 -2
- metadata +28 -36
- data/spec/samples/all_but_one_masked/clean_one.rb +0 -7
- data/spec/samples/all_but_one_masked/dirty.rb +0 -8
- data/spec/samples/all_but_one_masked/masked.reek +0 -9
- data/spec/samples/checkstyle.xml +0 -13
- data/spec/samples/clean_due_to_masking/clean_one.rb +0 -7
- data/spec/samples/clean_due_to_masking/clean_three.rb +0 -7
- data/spec/samples/clean_due_to_masking/clean_two.rb +0 -7
- data/spec/samples/clean_due_to_masking/dirty_one.rb +0 -7
- data/spec/samples/clean_due_to_masking/dirty_two.rb +0 -7
- data/spec/samples/clean_due_to_masking/masked.reek +0 -11
- data/spec/samples/configuration/full_configuration.reek +0 -9
- data/spec/samples/configuration/with_excluded_paths.reek +0 -4
- data/spec/samples/masked_by_dotfile/.reek +0 -9
- data/spec/samples/masked_by_dotfile/dirty.rb +0 -8
- data/spec/samples/no_config_file/dirty.rb +0 -8
- data/spec/samples/three_clean_files/clean_one.rb +0 -7
- data/spec/samples/three_clean_files/clean_three.rb +0 -7
- data/spec/samples/three_clean_files/clean_two.rb +0 -7
- data/spec/samples/two_smelly_files/dirty_one.rb +0 -8
- data/spec/samples/two_smelly_files/dirty_two.rb +0 -8
|
@@ -3,8 +3,8 @@ Feature: Report smells using simple JSON layout
|
|
|
3
3
|
output a list of smells in JSON.
|
|
4
4
|
|
|
5
5
|
Scenario: output is empty when there are no smells
|
|
6
|
-
Given a directory called '
|
|
7
|
-
When I run reek --format json
|
|
6
|
+
Given a directory called 'clean' containing two clean files
|
|
7
|
+
When I run reek --format json clean
|
|
8
8
|
Then it succeeds
|
|
9
9
|
And it reports this JSON:
|
|
10
10
|
"""
|
|
@@ -12,40 +12,29 @@ Feature: Report smells using simple JSON layout
|
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
14
|
Scenario: Indicate smells and print them as JSON when using files
|
|
15
|
-
Given
|
|
15
|
+
Given the smelly file 'smelly.rb'
|
|
16
16
|
When I run reek --format json smelly.rb
|
|
17
17
|
Then the exit status indicates smells
|
|
18
18
|
And it reports this JSON:
|
|
19
19
|
"""
|
|
20
20
|
[
|
|
21
21
|
{
|
|
22
|
-
"smell_type": "
|
|
23
|
-
"source": "smelly.rb",
|
|
24
|
-
"context": "Smelly#m",
|
|
25
|
-
"lines": [ 4, 5 ],
|
|
26
|
-
"message": "calls @foo.bar 2 times",
|
|
27
|
-
"name": "@foo.bar",
|
|
28
|
-
"wiki_link": "https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md",
|
|
29
|
-
"count": 2
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"smell_type": "DuplicateMethodCall",
|
|
22
|
+
"smell_type": "UncommunicativeMethodName",
|
|
33
23
|
"source": "smelly.rb",
|
|
34
|
-
"context": "Smelly#
|
|
35
|
-
"lines": [ 4
|
|
36
|
-
"message": "
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"count": 2
|
|
24
|
+
"context": "Smelly#x",
|
|
25
|
+
"lines": [ 4 ],
|
|
26
|
+
"message": "has the name 'x'",
|
|
27
|
+
"wiki_link": "https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md",
|
|
28
|
+
"name": "x"
|
|
40
29
|
},
|
|
41
30
|
{
|
|
42
|
-
"smell_type": "
|
|
31
|
+
"smell_type": "UncommunicativeVariableName",
|
|
43
32
|
"source": "smelly.rb",
|
|
44
|
-
"context": "Smelly#
|
|
45
|
-
"lines": [
|
|
46
|
-
"message": "has the name '
|
|
47
|
-
"wiki_link": "https://github.com/troessner/reek/blob/master/docs/Uncommunicative-
|
|
48
|
-
"name": "
|
|
33
|
+
"context": "Smelly#x",
|
|
34
|
+
"lines": [ 5 ],
|
|
35
|
+
"message": "has the variable name 'y'",
|
|
36
|
+
"wiki_link": "https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md",
|
|
37
|
+
"name": "y"
|
|
49
38
|
}
|
|
50
39
|
]
|
|
51
40
|
"""
|
|
@@ -64,8 +53,7 @@ Feature: Report smells using simple JSON layout
|
|
|
64
53
|
1
|
|
65
54
|
],
|
|
66
55
|
"message": "has no descriptive comment",
|
|
67
|
-
"wiki_link": "https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md"
|
|
68
|
-
"name": "Turn"
|
|
56
|
+
"wiki_link": "https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md"
|
|
69
57
|
}
|
|
70
58
|
]
|
|
71
59
|
"""
|
|
@@ -10,13 +10,12 @@ Feature: Correctly formatted reports
|
|
|
10
10
|
And it reports:
|
|
11
11
|
"""
|
|
12
12
|
smelly/dirty_one.rb -- 2 warnings:
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
smelly/dirty_two.rb --
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
|
|
19
|
-
5 total warnings
|
|
13
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
14
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
|
15
|
+
smelly/dirty_two.rb -- 2 warnings:
|
|
16
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
17
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
|
18
|
+
4 total warnings
|
|
20
19
|
"""
|
|
21
20
|
|
|
22
21
|
Examples:
|
|
@@ -31,13 +30,12 @@ Feature: Correctly formatted reports
|
|
|
31
30
|
And it reports:
|
|
32
31
|
"""
|
|
33
32
|
smelly/dirty_one.rb -- 2 warnings:
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
smelly/dirty_two.rb --
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
-
|
|
40
|
-
5 total warnings
|
|
33
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
34
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
|
35
|
+
smelly/dirty_two.rb -- 2 warnings:
|
|
36
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
37
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
|
38
|
+
4 total warnings
|
|
41
39
|
"""
|
|
42
40
|
|
|
43
41
|
Examples:
|
|
@@ -52,14 +50,13 @@ Feature: Correctly formatted reports
|
|
|
52
50
|
Then the exit status indicates smells
|
|
53
51
|
And it reports:
|
|
54
52
|
"""
|
|
55
|
-
smelly/dirty_two.rb --
|
|
56
|
-
[
|
|
57
|
-
[
|
|
58
|
-
[3]:UncommunicativeMethodName: Dirty#b has the name 'b' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
53
|
+
smelly/dirty_two.rb -- 2 warnings:
|
|
54
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
55
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
|
59
56
|
smelly/dirty_one.rb -- 2 warnings:
|
|
60
|
-
[
|
|
61
|
-
[
|
|
62
|
-
|
|
57
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
58
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
|
59
|
+
4 total warnings
|
|
63
60
|
"""
|
|
64
61
|
|
|
65
62
|
Examples:
|
|
@@ -68,8 +65,8 @@ Feature: Correctly formatted reports
|
|
|
68
65
|
| --sort-by s |
|
|
69
66
|
|
|
70
67
|
Scenario: good files show no headings by default
|
|
71
|
-
Given a directory called '
|
|
72
|
-
When I run reek
|
|
68
|
+
Given a directory called 'clean' containing two clean files
|
|
69
|
+
When I run reek clean
|
|
73
70
|
Then it succeeds
|
|
74
71
|
And it reports:
|
|
75
72
|
"""
|
|
@@ -77,14 +74,13 @@ Feature: Correctly formatted reports
|
|
|
77
74
|
"""
|
|
78
75
|
|
|
79
76
|
Scenario Outline: --empty-headings turns on headings for fragrant files
|
|
80
|
-
Given a directory called '
|
|
81
|
-
When I run reek <option>
|
|
77
|
+
Given a directory called 'clean' containing two clean files
|
|
78
|
+
When I run reek <option> clean
|
|
82
79
|
Then it succeeds
|
|
83
80
|
And it reports:
|
|
84
81
|
"""
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
clean_files/clean_two.rb -- 0 warnings
|
|
82
|
+
clean/clean_one.rb -- 0 warnings
|
|
83
|
+
clean/clean_two.rb -- 0 warnings
|
|
88
84
|
0 total warnings
|
|
89
85
|
"""
|
|
90
86
|
|
|
@@ -94,8 +90,8 @@ Feature: Correctly formatted reports
|
|
|
94
90
|
| -V |
|
|
95
91
|
|
|
96
92
|
Scenario Outline: --no-empty-headings turns off headings for fragrant files
|
|
97
|
-
Given a directory called '
|
|
98
|
-
When I run reek <option>
|
|
93
|
+
Given a directory called 'clean' containing two clean files
|
|
94
|
+
When I run reek <option> clean
|
|
99
95
|
Then it succeeds
|
|
100
96
|
And it reports:
|
|
101
97
|
"""
|
|
@@ -108,15 +104,14 @@ Feature: Correctly formatted reports
|
|
|
108
104
|
| -V --no-empty-headings |
|
|
109
105
|
|
|
110
106
|
Scenario Outline: --no-line-numbers turns off line numbers
|
|
111
|
-
Given
|
|
107
|
+
Given the smelly file 'smelly.rb'
|
|
112
108
|
When I run reek <option> smelly.rb
|
|
113
109
|
Then the exit status indicates smells
|
|
114
110
|
And it reports:
|
|
115
111
|
"""
|
|
116
|
-
smelly.rb --
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
112
|
+
smelly.rb -- 2 warnings:
|
|
113
|
+
UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
114
|
+
UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
|
120
115
|
"""
|
|
121
116
|
|
|
122
117
|
Examples:
|
|
@@ -126,15 +121,14 @@ Feature: Correctly formatted reports
|
|
|
126
121
|
| -V --no-line-numbers |
|
|
127
122
|
|
|
128
123
|
Scenario Outline: --line-numbers turns on line numbers
|
|
129
|
-
Given
|
|
124
|
+
Given the smelly file 'smelly.rb'
|
|
130
125
|
When I run reek <option> smelly.rb
|
|
131
126
|
Then the exit status indicates smells
|
|
132
127
|
And it reports:
|
|
133
128
|
"""
|
|
134
|
-
smelly.rb --
|
|
135
|
-
[4
|
|
136
|
-
[
|
|
137
|
-
[3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
129
|
+
smelly.rb -- 2 warnings:
|
|
130
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
131
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
|
138
132
|
"""
|
|
139
133
|
|
|
140
134
|
Examples:
|
|
@@ -144,15 +138,14 @@ Feature: Correctly formatted reports
|
|
|
144
138
|
| --no-line-numbers -n |
|
|
145
139
|
|
|
146
140
|
Scenario Outline: --single-line shows filename and one line number
|
|
147
|
-
Given
|
|
141
|
+
Given the smelly file 'smelly.rb'
|
|
148
142
|
When I run reek <option> smelly.rb
|
|
149
143
|
Then the exit status indicates smells
|
|
150
144
|
And it reports:
|
|
151
145
|
"""
|
|
152
|
-
smelly.rb --
|
|
153
|
-
smelly.rb:4:
|
|
154
|
-
smelly.rb:
|
|
155
|
-
smelly.rb:3: UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
146
|
+
smelly.rb -- 2 warnings:
|
|
147
|
+
smelly.rb:4: UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
148
|
+
smelly.rb:5: UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
|
156
149
|
"""
|
|
157
150
|
|
|
158
151
|
Examples:
|
|
@@ -169,13 +162,12 @@ Feature: Correctly formatted reports
|
|
|
169
162
|
And it reports:
|
|
170
163
|
"""
|
|
171
164
|
smelly/dirty_one.rb -- 2 warnings:
|
|
172
|
-
[
|
|
173
|
-
[
|
|
174
|
-
smelly/dirty_two.rb --
|
|
175
|
-
[
|
|
176
|
-
[
|
|
177
|
-
|
|
178
|
-
5 total warnings
|
|
165
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
166
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
|
167
|
+
smelly/dirty_two.rb -- 2 warnings:
|
|
168
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
169
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
|
170
|
+
4 total warnings
|
|
179
171
|
"""
|
|
180
172
|
|
|
181
173
|
Examples:
|
|
@@ -184,15 +176,14 @@ Feature: Correctly formatted reports
|
|
|
184
176
|
| smelly |
|
|
185
177
|
|
|
186
178
|
Scenario Outline: -U or --wiki-links adds helpful links to smell warnings
|
|
187
|
-
Given
|
|
179
|
+
Given the smelly file 'smelly.rb'
|
|
188
180
|
When I run reek <option> smelly.rb
|
|
189
181
|
Then the exit status indicates smells
|
|
190
182
|
And it reports:
|
|
191
183
|
"""
|
|
192
|
-
smelly.rb --
|
|
193
|
-
[4
|
|
194
|
-
[
|
|
195
|
-
[3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
184
|
+
smelly.rb -- 2 warnings:
|
|
185
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
186
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
|
196
187
|
"""
|
|
197
188
|
|
|
198
189
|
Examples:
|
|
@@ -201,27 +192,25 @@ Feature: Correctly formatted reports
|
|
|
201
192
|
| --wiki-links |
|
|
202
193
|
|
|
203
194
|
Scenario: --no-wiki-links drops links from smell warnings
|
|
204
|
-
Given
|
|
195
|
+
Given the smelly file 'smelly.rb'
|
|
205
196
|
When I run reek --no-wiki-links smelly.rb
|
|
206
197
|
Then the exit status indicates smells
|
|
207
198
|
And it reports:
|
|
208
199
|
"""
|
|
209
|
-
smelly.rb --
|
|
210
|
-
[4
|
|
211
|
-
[
|
|
212
|
-
[3]:UncommunicativeMethodName: Smelly#m has the name 'm'
|
|
200
|
+
smelly.rb -- 2 warnings:
|
|
201
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x'
|
|
202
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
|
|
213
203
|
"""
|
|
214
204
|
|
|
215
205
|
Scenario Outline: --wiki-links is independent of --line-numbers
|
|
216
|
-
Given
|
|
206
|
+
Given the smelly file 'smelly.rb'
|
|
217
207
|
When I run reek <option> smelly.rb
|
|
218
208
|
Then the exit status indicates smells
|
|
219
209
|
And it reports:
|
|
220
210
|
"""
|
|
221
|
-
smelly.rb --
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
211
|
+
smelly.rb -- 2 warnings:
|
|
212
|
+
UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
|
|
213
|
+
UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
|
|
225
214
|
"""
|
|
226
215
|
|
|
227
216
|
Examples:
|
|
@@ -3,8 +3,8 @@ Feature: Report smells using simple YAML layout
|
|
|
3
3
|
output a list of smells in Yaml.
|
|
4
4
|
|
|
5
5
|
Scenario: output is empty when there are no smells
|
|
6
|
-
Given a directory called '
|
|
7
|
-
When I run reek --format yaml
|
|
6
|
+
Given a directory called 'clean' containing two clean files
|
|
7
|
+
When I run reek --format yaml clean
|
|
8
8
|
Then it succeeds
|
|
9
9
|
And it reports this yaml:
|
|
10
10
|
"""
|
|
@@ -12,40 +12,28 @@ Feature: Report smells using simple YAML layout
|
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
14
|
Scenario: Indicate smells and print them as yaml when using files
|
|
15
|
-
Given
|
|
15
|
+
Given the smelly file 'smelly.rb'
|
|
16
16
|
When I run reek --format yaml smelly.rb
|
|
17
17
|
Then the exit status indicates smells
|
|
18
18
|
And it reports this yaml:
|
|
19
19
|
"""
|
|
20
20
|
---
|
|
21
|
-
-
|
|
22
|
-
source: smelly.rb
|
|
23
|
-
context: Smelly#m
|
|
21
|
+
- context: Smelly#x
|
|
24
22
|
lines:
|
|
25
23
|
- 4
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
name: "@foo.bar"
|
|
29
|
-
count: 2
|
|
30
|
-
wiki_link: https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md
|
|
31
|
-
- smell_type: DuplicateMethodCall
|
|
24
|
+
message: has the name 'x'
|
|
25
|
+
smell_type: UncommunicativeMethodName
|
|
32
26
|
source: smelly.rb
|
|
33
|
-
|
|
27
|
+
name: x
|
|
28
|
+
wiki_link: https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md
|
|
29
|
+
- context: Smelly#x
|
|
34
30
|
lines:
|
|
35
|
-
- 4
|
|
36
31
|
- 5
|
|
37
|
-
message:
|
|
38
|
-
|
|
39
|
-
count: 2
|
|
40
|
-
wiki_link: https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md
|
|
41
|
-
- smell_type: UncommunicativeMethodName
|
|
32
|
+
message: has the variable name 'y'
|
|
33
|
+
smell_type: UncommunicativeVariableName
|
|
42
34
|
source: smelly.rb
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
- 3
|
|
46
|
-
message: has the name 'm'
|
|
47
|
-
name: m
|
|
48
|
-
wiki_link: https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md
|
|
35
|
+
name: y
|
|
36
|
+
wiki_link: https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md
|
|
49
37
|
"""
|
|
50
38
|
|
|
51
39
|
Scenario: Indicate smells and print them as yaml when using STDIN
|
|
@@ -60,6 +48,5 @@ Feature: Report smells using simple YAML layout
|
|
|
60
48
|
lines:
|
|
61
49
|
- 1
|
|
62
50
|
message: has no descriptive comment
|
|
63
|
-
name: Turn
|
|
64
51
|
wiki_link: https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md
|
|
65
52
|
"""
|
data/features/samples.feature
CHANGED
|
@@ -4,9 +4,9 @@ Feature: Basic smell detection
|
|
|
4
4
|
I want to detect the smells in my Ruby code
|
|
5
5
|
|
|
6
6
|
Scenario: Correct smells from inline.rb
|
|
7
|
-
Given the
|
|
8
|
-
And the
|
|
9
|
-
And the
|
|
7
|
+
Given the smelly file 'inline.rb'
|
|
8
|
+
And the smelly file 'optparse.rb'
|
|
9
|
+
And the smelly file 'redcloth.rb'
|
|
10
10
|
When I run reek --no-line-numbers inline.rb optparse.rb redcloth.rb
|
|
11
11
|
Then the exit status indicates smells
|
|
12
12
|
And it reports:
|
|
@@ -1,181 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
end
|
|
6
|
-
EOS
|
|
7
|
-
write_file('smelly.rb', contents)
|
|
1
|
+
require_relative '../../samples/paths'
|
|
2
|
+
|
|
3
|
+
Given(/^the smelly file '(.+)'$/) do |filename|
|
|
4
|
+
write_file(filename, SAMPLES_PATH.join(filename).read)
|
|
8
5
|
end
|
|
9
6
|
|
|
10
7
|
Given(/^the clean file 'clean.rb'$/) do
|
|
11
|
-
|
|
12
|
-
# Explanatory comment
|
|
13
|
-
class Clean
|
|
14
|
-
def foo; end
|
|
15
|
-
end
|
|
16
|
-
EOS
|
|
17
|
-
write_file('clean.rb', contents)
|
|
8
|
+
write_file('clean.rb', CLEAN_FILE.read)
|
|
18
9
|
end
|
|
19
10
|
|
|
20
|
-
Given(/^
|
|
21
|
-
contents =
|
|
22
|
-
class Dirty
|
|
23
|
-
# This method smells of :reek:NestedIterators but ignores them
|
|
24
|
-
def awful(x, y, offset = 0, log = false)
|
|
25
|
-
puts @screen.title
|
|
26
|
-
@screen = widgets.map {|w| w.each {|key| key += 3 * x}}
|
|
27
|
-
puts @screen.contents
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
EOS
|
|
31
|
-
write_file('demo.rb', contents)
|
|
32
|
-
end
|
|
11
|
+
Given(/^a directory called 'clean' containing two clean files$/) do
|
|
12
|
+
contents = CLEAN_FILE.read
|
|
33
13
|
|
|
34
|
-
|
|
35
|
-
write_file
|
|
36
|
-
# smells of :reek:NestedIterators but ignores them
|
|
37
|
-
class Dirty
|
|
38
|
-
def a
|
|
39
|
-
puts @s.title
|
|
40
|
-
@s = foo.map {|x| x.each {|key| key += 3}}
|
|
41
|
-
puts @s.title
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
EOS
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
Given(/^the "(.*?)" sample file exists$/) do |file_name|
|
|
48
|
-
full_path = Pathname.new("#{__dir__}/../../spec/samples/#{file_name}")
|
|
49
|
-
cd('.') { FileUtils.cp full_path, file_name }
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
Given(/^a directory called 'clean_files' containing some clean files$/) do
|
|
53
|
-
contents = <<-EOS.strip_heredoc
|
|
54
|
-
# clean class for testing purposes
|
|
55
|
-
class Clean
|
|
56
|
-
def assign
|
|
57
|
-
puts @sub.title
|
|
58
|
-
@sub.map {|para| para.name }
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
EOS
|
|
62
|
-
write_file 'clean_files/clean_one.rb', contents
|
|
63
|
-
write_file 'clean_files/clean_two.rb', contents
|
|
64
|
-
write_file 'clean_files/clean_three.rb', contents
|
|
14
|
+
write_file('clean/clean_one.rb', contents)
|
|
15
|
+
write_file('clean/clean_two.rb', contents)
|
|
65
16
|
end
|
|
66
17
|
|
|
67
18
|
Given(/^a directory called 'smelly' containing two smelly files$/) do
|
|
68
|
-
|
|
69
|
-
class Dirty
|
|
70
|
-
def a; end
|
|
71
|
-
end
|
|
72
|
-
EOS
|
|
73
|
-
write_file('smelly/dirty_two.rb', <<-EOS.strip_heredoc)
|
|
74
|
-
class Dirty
|
|
75
|
-
def a; end
|
|
76
|
-
def b; end
|
|
77
|
-
end
|
|
78
|
-
EOS
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
Given(/^a smelly file called 'smelly.rb'( in a subdirectory)?$/) do |in_subdir|
|
|
82
|
-
file_name = in_subdir ? 'subdir/smelly.rb' : 'smelly.rb'
|
|
83
|
-
write_file file_name, <<-EOS.strip_heredoc
|
|
84
|
-
# smelly class for testing purposes
|
|
85
|
-
class Smelly
|
|
86
|
-
def m
|
|
87
|
-
puts @foo.bar
|
|
88
|
-
puts @foo.bar
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
EOS
|
|
92
|
-
end
|
|
19
|
+
contents = SMELLY_FILE.read
|
|
93
20
|
|
|
94
|
-
|
|
95
|
-
write_file('
|
|
21
|
+
write_file('smelly/dirty_one.rb', contents)
|
|
22
|
+
write_file('smelly/dirty_two.rb', contents)
|
|
96
23
|
end
|
|
97
24
|
|
|
98
|
-
Given(/^
|
|
99
|
-
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
Given(/^a masking configuration file called 'config.reek'$/) do
|
|
103
|
-
write_file('config.reek', <<-EOS.strip_heredoc)
|
|
104
|
-
---
|
|
105
|
-
DuplicateMethodCall:
|
|
106
|
-
enabled: false
|
|
107
|
-
UncommunicativeMethodName:
|
|
108
|
-
enabled: false
|
|
109
|
-
EOS
|
|
110
|
-
end
|
|
25
|
+
Given(/^the smelly file '(.+)' in a subdirectory$/) do |filename|
|
|
26
|
+
contents = SAMPLES_PATH.join(filename).read
|
|
111
27
|
|
|
112
|
-
|
|
113
|
-
write_file('config.reek', <<-EOS.strip_heredoc)
|
|
114
|
-
---
|
|
115
|
-
DuplicateMethodCall:
|
|
116
|
-
allow_calls:
|
|
117
|
-
- puts @foo.bar
|
|
118
|
-
EOS
|
|
28
|
+
write_file("subdir/#{filename}", contents)
|
|
119
29
|
end
|
|
120
30
|
|
|
121
|
-
Given(/^a configuration file
|
|
122
|
-
write_file(
|
|
123
|
-
---
|
|
124
|
-
DuplicateMethodCall:
|
|
125
|
-
enabled: false
|
|
126
|
-
EOS
|
|
31
|
+
Given(/^a configuration file '(.+)'$/) do |filename|
|
|
32
|
+
write_file(filename, CONFIG_PATH.join(filename).read)
|
|
127
33
|
end
|
|
128
34
|
|
|
129
|
-
When(/^I run "reek (.*?)" in
|
|
35
|
+
When(/^I run "reek (.*?)" in a subdirectory$/) do |args|
|
|
130
36
|
cd 'subdir'
|
|
131
|
-
reek(args)
|
|
132
|
-
end
|
|
133
37
|
|
|
134
|
-
|
|
135
|
-
set_environment_variable 'HOME', Pathname.new("#{expand_path('.')}/home")
|
|
136
|
-
write_file('home/config.reek', <<-EOS.strip_heredoc)
|
|
137
|
-
---
|
|
138
|
-
DuplicateMethodCall:
|
|
139
|
-
enabled: false
|
|
140
|
-
UncommunicativeMethodName:
|
|
141
|
-
enabled: false
|
|
142
|
-
EOS
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
Given(/^an enabling configuration file in the subdirectory$/) do
|
|
146
|
-
write_file('subdir/config.reek', <<-EOS.strip_heredoc)
|
|
147
|
-
---
|
|
148
|
-
IrresponsibleModule:
|
|
149
|
-
enabled: true
|
|
150
|
-
UncommunicativeModuleName:
|
|
151
|
-
enabled: true
|
|
152
|
-
UncommunicativeMethodName:
|
|
153
|
-
enabled: true
|
|
154
|
-
EOS
|
|
38
|
+
reek(args)
|
|
155
39
|
end
|
|
156
40
|
|
|
157
|
-
Given(/^a
|
|
158
|
-
|
|
159
|
-
# smelly class for testing purposes
|
|
160
|
-
class Klass
|
|
161
|
-
def public_method(arg) arg.to_s; end
|
|
162
|
-
protected
|
|
163
|
-
def protected_method(arg) arg.to_s; end
|
|
164
|
-
private
|
|
165
|
-
def private_method(arg) arg.to_s; end
|
|
166
|
-
end
|
|
167
|
-
EOS
|
|
168
|
-
end
|
|
41
|
+
Given(/^a configuration file '(.+)' in a subdirectory$/) do |filename|
|
|
42
|
+
contents = CONFIG_PATH.join(filename).read
|
|
169
43
|
|
|
170
|
-
|
|
171
|
-
write_file('config.reek', <<-EOS.strip_heredoc)
|
|
172
|
-
---
|
|
173
|
-
UtilityFunction:
|
|
174
|
-
public_methods_only: true
|
|
175
|
-
# Not necessary for the feature per se but for removing distracting output.
|
|
176
|
-
UnusedPrivateMethod:
|
|
177
|
-
enabled: false
|
|
178
|
-
EOS
|
|
44
|
+
write_file("subdir/#{filename}", contents)
|
|
179
45
|
end
|
|
180
46
|
|
|
181
47
|
Then(/^it does not report private or protected methods$/) do
|