reek 4.4.1 → 4.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +46 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +5 -1
- data/docs/Duplicate-Method-Call.md +96 -0
- data/docs/How-To-Write-New-Detectors.md +16 -0
- data/docs/Large-Class.md +2 -1
- data/docs/Simulated-Polymorphism.md +1 -1
- data/features/configuration_via_source_comments/erroneous_source_comments.feature +39 -0
- data/lib/reek/ast/node.rb +4 -0
- data/lib/reek/code_comment.rb +11 -3
- data/lib/reek/context/code_context.rb +3 -1
- data/lib/reek/context/module_context.rb +1 -1
- data/lib/reek/errors.rb +32 -0
- data/lib/reek/examiner.rb +6 -1
- data/lib/reek/rake/task.rb +0 -2
- data/lib/reek/smells/boolean_parameter.rb +1 -1
- data/lib/reek/smells/class_variable.rb +2 -2
- data/lib/reek/smells/instance_variable_assumption.rb +1 -1
- data/lib/reek/smells/prima_donna_method.rb +18 -17
- data/lib/reek/smells/smell_detector.rb +19 -2
- data/lib/reek/smells/unused_private_method.rb +1 -1
- data/lib/reek/spec/should_reek_of.rb +2 -0
- data/lib/reek/version.rb +1 -1
- data/spec/factories/factories.rb +11 -0
- data/spec/quality/reek_source_spec.rb +1 -1
- data/spec/reek/ast/node_spec.rb +40 -0
- data/spec/reek/ast/object_refs_spec.rb +20 -59
- data/spec/reek/ast/sexp_extensions_spec.rb +16 -19
- data/spec/reek/cli/application_spec.rb +25 -25
- data/spec/reek/cli/command/report_command_spec.rb +1 -2
- data/spec/reek/cli/command/todo_list_command_spec.rb +1 -1
- data/spec/reek/cli/options_spec.rb +7 -5
- data/spec/reek/code_comment_spec.rb +74 -44
- data/spec/reek/configuration/default_directive_spec.rb +3 -3
- data/spec/reek/configuration/directory_directives_spec.rb +10 -10
- data/spec/reek/configuration/excluded_paths_spec.rb +2 -2
- data/spec/reek/context/code_context_spec.rb +22 -26
- data/spec/reek/context/ghost_context_spec.rb +1 -1
- data/spec/reek/context/method_context_spec.rb +13 -7
- data/spec/reek/context/module_context_spec.rb +4 -4
- data/spec/reek/context/root_context_spec.rb +1 -1
- data/spec/reek/context_builder_spec.rb +34 -38
- data/spec/reek/examiner_spec.rb +43 -22
- data/spec/reek/rake/task_spec.rb +3 -3
- data/spec/reek/report/code_climate_formatter_spec.rb +42 -40
- data/spec/reek/report/code_climate_report_spec.rb +1 -1
- data/spec/reek/report/html_report_spec.rb +1 -1
- data/spec/reek/report/json_report_spec.rb +1 -1
- data/spec/reek/report/location_formatter_spec.rb +18 -16
- data/spec/reek/report/text_report_spec.rb +12 -8
- data/spec/reek/report/xml_report_spec.rb +1 -1
- data/spec/reek/report/yaml_report_spec.rb +1 -1
- data/spec/reek/report_spec.rb +4 -4
- data/spec/reek/smells/attribute_spec.rb +7 -10
- data/spec/reek/smells/boolean_parameter_spec.rb +14 -20
- data/spec/reek/smells/class_variable_spec.rb +6 -5
- data/spec/reek/smells/control_parameter_spec.rb +3 -2
- data/spec/reek/smells/data_clump_spec.rb +3 -6
- data/spec/reek/smells/duplicate_method_call_spec.rb +10 -14
- data/spec/reek/smells/feature_envy_spec.rb +34 -25
- data/spec/reek/smells/instance_variable_assumption_spec.rb +6 -9
- data/spec/reek/smells/irresponsible_module_spec.rb +3 -6
- data/spec/reek/smells/long_parameter_list_spec.rb +5 -7
- data/spec/reek/smells/long_yield_list_spec.rb +3 -6
- data/spec/reek/smells/manual_dispatch_spec.rb +3 -6
- data/spec/reek/smells/nested_iterators_spec.rb +10 -8
- data/spec/reek/smells/nil_check_spec.rb +2 -1
- data/spec/reek/smells/prima_donna_method_spec.rb +5 -8
- data/spec/reek/smells/smell_configuration_spec.rb +3 -3
- data/spec/reek/smells/smell_detector_spec.rb +10 -0
- data/spec/reek/smells/smell_repository_spec.rb +6 -6
- data/spec/reek/smells/smell_warning_spec.rb +35 -39
- data/spec/reek/smells/subclassed_from_core_class_spec.rb +5 -5
- data/spec/reek/smells/too_many_constants_spec.rb +10 -10
- data/spec/reek/smells/too_many_instance_variables_spec.rb +1 -1
- data/spec/reek/smells/too_many_methods_spec.rb +1 -1
- data/spec/reek/smells/too_many_statements_spec.rb +3 -6
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +9 -6
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +3 -3
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +6 -9
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +20 -24
- data/spec/reek/smells/unused_parameters_spec.rb +35 -24
- data/spec/reek/smells/unused_private_method_spec.rb +25 -33
- data/spec/reek/smells/utility_function_spec.rb +27 -14
- data/spec/reek/source/source_code_spec.rb +6 -6
- data/spec/reek/source/source_locator_spec.rb +34 -17
- data/spec/reek/spec/should_reek_of_spec.rb +17 -12
- data/spec/reek/spec/should_reek_only_of_spec.rb +5 -5
- data/spec/reek/spec/should_reek_spec.rb +3 -3
- data/spec/reek/tree_dresser_spec.rb +6 -4
- data/spec/spec_helper.rb +3 -0
- data/tasks/rubocop.rake +9 -3
- metadata +4 -2
@@ -42,12 +42,9 @@ RSpec.describe Reek::Smells::TooManyStatements do
|
|
42
42
|
end
|
43
43
|
EOS
|
44
44
|
|
45
|
-
expect(src).
|
46
|
-
|
47
|
-
|
48
|
-
expect(src).to reek_of(:TooManyStatements,
|
49
|
-
lines: [8],
|
50
|
-
context: 'Alfa#foxtrot').with_config(config)
|
45
|
+
expect(src).
|
46
|
+
to reek_of(:TooManyStatements, lines: [2], context: 'Alfa#bravo').with_config(config).
|
47
|
+
and reek_of(:TooManyStatements, lines: [8], context: 'Alfa#foxtrot').with_config(config)
|
51
48
|
end
|
52
49
|
|
53
50
|
it 'does not report short methods' do
|
@@ -17,15 +17,18 @@ RSpec.describe Reek::Smells::UncommunicativeMethodName do
|
|
17
17
|
|
18
18
|
describe 'default configuration' do
|
19
19
|
it 'reports one-word names' do
|
20
|
-
|
20
|
+
src = 'def a; end'
|
21
|
+
expect(src).to reek_of(:UncommunicativeMethodName)
|
21
22
|
end
|
22
23
|
|
23
24
|
it 'reports names ending with a digit' do
|
24
|
-
|
25
|
+
src = 'def xyz1; end'
|
26
|
+
expect(src).to reek_of(:UncommunicativeMethodName)
|
25
27
|
end
|
26
28
|
|
27
29
|
it 'reports camelcased names' do
|
28
|
-
|
30
|
+
src = 'def aBBa; end'
|
31
|
+
expect(src).to reek_of(:UncommunicativeMethodName)
|
29
32
|
end
|
30
33
|
|
31
34
|
it 'does not report one-letter special characters' do
|
@@ -40,7 +43,7 @@ RSpec.describe Reek::Smells::UncommunicativeMethodName do
|
|
40
43
|
|
41
44
|
it 'make smelly names pass via regex / strings given by list / literal' do
|
42
45
|
[[/x/], /x/, ['x'], 'x'].each do |pattern|
|
43
|
-
expect(source).
|
46
|
+
expect(source).not_to reek_of(:UncommunicativeMethodName).with_config('accept' => pattern)
|
44
47
|
end
|
45
48
|
end
|
46
49
|
end
|
@@ -56,7 +59,7 @@ RSpec.describe Reek::Smells::UncommunicativeMethodName do
|
|
56
59
|
end
|
57
60
|
|
58
61
|
describe '.default_config' do
|
59
|
-
it '
|
62
|
+
it 'merges in the default accept and reject patterns' do
|
60
63
|
expected = {
|
61
64
|
'enabled' => true,
|
62
65
|
'exclude' => [],
|
@@ -68,7 +71,7 @@ RSpec.describe Reek::Smells::UncommunicativeMethodName do
|
|
68
71
|
end
|
69
72
|
|
70
73
|
describe '.contexts' do
|
71
|
-
it '
|
74
|
+
it 'is scoped to classes and modules' do
|
72
75
|
expect(described_class.contexts).to eq([:def, :defs])
|
73
76
|
end
|
74
77
|
end
|
@@ -41,7 +41,7 @@ RSpec.describe Reek::Smells::UncommunicativeModuleName do
|
|
41
41
|
|
42
42
|
it 'makes smelly names pass via regex / strings given by list / literal' do
|
43
43
|
[[/lfa/], /lfa/, ['lfa'], 'lfa'].each do |pattern|
|
44
|
-
expect(source).
|
44
|
+
expect(source).not_to reek_of(:UncommunicativeModuleName).with_config('accept' => pattern)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -57,7 +57,7 @@ RSpec.describe Reek::Smells::UncommunicativeModuleName do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
describe '.default_config' do
|
60
|
-
it '
|
60
|
+
it 'merges in the default accept and reject patterns' do
|
61
61
|
expected = {
|
62
62
|
'enabled' => true,
|
63
63
|
'exclude' => [],
|
@@ -69,7 +69,7 @@ RSpec.describe Reek::Smells::UncommunicativeModuleName do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
describe '.contexts' do
|
72
|
-
it '
|
72
|
+
it 'indicates that this smell is scoped to classes and modules' do
|
73
73
|
expect(described_class.contexts).to eq([:module, :class])
|
74
74
|
end
|
75
75
|
end
|
@@ -24,12 +24,9 @@ RSpec.describe Reek::Smells::UncommunicativeParameterName do
|
|
24
24
|
end
|
25
25
|
EOS
|
26
26
|
|
27
|
-
expect(src).
|
28
|
-
|
29
|
-
|
30
|
-
expect(src).to reek_of(:UncommunicativeParameterName,
|
31
|
-
lines: [1],
|
32
|
-
name: 'y')
|
27
|
+
expect(src).
|
28
|
+
to reek_of(:UncommunicativeParameterName, lines: [1], name: 'x').
|
29
|
+
and reek_of(:UncommunicativeParameterName, lines: [1], name: 'y')
|
33
30
|
end
|
34
31
|
|
35
32
|
{ 'alfa.' => 'with a receiver',
|
@@ -93,7 +90,7 @@ RSpec.describe Reek::Smells::UncommunicativeParameterName do
|
|
93
90
|
|
94
91
|
it 'make smelly names pass via regex / strings given by list / literal' do
|
95
92
|
[[/bar2/], /bar2/, ['bar2'], 'bar2'].each do |pattern|
|
96
|
-
expect(source).
|
93
|
+
expect(source).not_to reek_of(:UncommunicativeParameterName).with_config('accept' => pattern)
|
97
94
|
end
|
98
95
|
end
|
99
96
|
end
|
@@ -109,7 +106,7 @@ RSpec.describe Reek::Smells::UncommunicativeParameterName do
|
|
109
106
|
end
|
110
107
|
|
111
108
|
describe '.default_config' do
|
112
|
-
it '
|
109
|
+
it 'merges in the default accept and reject patterns' do
|
113
110
|
expected = {
|
114
111
|
'enabled' => true,
|
115
112
|
'exclude' => [],
|
@@ -122,7 +119,7 @@ RSpec.describe Reek::Smells::UncommunicativeParameterName do
|
|
122
119
|
end
|
123
120
|
|
124
121
|
describe '.contexts' do
|
125
|
-
it '
|
122
|
+
it 'indicates that this smell is scoped to method definitions' do
|
126
123
|
expect(described_class.contexts).to eq([:def, :defs])
|
127
124
|
end
|
128
125
|
end
|
@@ -25,12 +25,8 @@ RSpec.describe Reek::Smells::UncommunicativeVariableName do
|
|
25
25
|
end
|
26
26
|
EOS
|
27
27
|
|
28
|
-
expect(src).to reek_of(:UncommunicativeVariableName,
|
29
|
-
|
30
|
-
name: 'x')
|
31
|
-
expect(src).to reek_of(:UncommunicativeVariableName,
|
32
|
-
lines: [3],
|
33
|
-
name: 'y')
|
28
|
+
expect(src).to reek_of(:UncommunicativeVariableName, lines: [2], name: 'x').
|
29
|
+
and reek_of(:UncommunicativeVariableName, lines: [3], name: 'y')
|
34
30
|
end
|
35
31
|
|
36
32
|
context 'instance variables' do
|
@@ -90,8 +86,8 @@ RSpec.describe Reek::Smells::UncommunicativeVariableName do
|
|
90
86
|
end
|
91
87
|
EOS
|
92
88
|
|
93
|
-
expect(src).to reek_of(:UncommunicativeVariableName, name: 'x')
|
94
|
-
|
89
|
+
expect(src).to reek_of(:UncommunicativeVariableName, name: 'x').
|
90
|
+
and reek_of(:UncommunicativeVariableName, name: 'y')
|
95
91
|
end
|
96
92
|
|
97
93
|
it 'reports block parameters used outside of methods' do
|
@@ -121,8 +117,8 @@ RSpec.describe Reek::Smells::UncommunicativeVariableName do
|
|
121
117
|
end
|
122
118
|
EOS
|
123
119
|
|
124
|
-
expect(src).to reek_of(:UncommunicativeVariableName, name: 'x')
|
125
|
-
|
120
|
+
expect(src).to reek_of(:UncommunicativeVariableName, name: 'x').
|
121
|
+
and reek_of(:UncommunicativeVariableName, name: 'y')
|
126
122
|
end
|
127
123
|
|
128
124
|
it 'reports splatted nested block parameters' do
|
@@ -132,8 +128,8 @@ RSpec.describe Reek::Smells::UncommunicativeVariableName do
|
|
132
128
|
end
|
133
129
|
EOS
|
134
130
|
|
135
|
-
expect(src).to reek_of(:UncommunicativeVariableName, name: 'x')
|
136
|
-
|
131
|
+
expect(src).to reek_of(:UncommunicativeVariableName, name: 'x').
|
132
|
+
and reek_of(:UncommunicativeVariableName, name: 'y')
|
137
133
|
end
|
138
134
|
|
139
135
|
it 'reports deeply nested block parameters' do
|
@@ -143,9 +139,9 @@ RSpec.describe Reek::Smells::UncommunicativeVariableName do
|
|
143
139
|
end
|
144
140
|
EOS
|
145
141
|
|
146
|
-
expect(src).to reek_of(:UncommunicativeVariableName, name: 'x')
|
147
|
-
|
148
|
-
|
142
|
+
expect(src).to reek_of(:UncommunicativeVariableName, name: 'x').
|
143
|
+
and reek_of(:UncommunicativeVariableName, name: 'y').
|
144
|
+
and reek_of(:UncommunicativeVariableName, name: 'z')
|
149
145
|
end
|
150
146
|
|
151
147
|
it 'reports shadowed block parameters' do
|
@@ -155,19 +151,19 @@ RSpec.describe Reek::Smells::UncommunicativeVariableName do
|
|
155
151
|
end
|
156
152
|
EOS
|
157
153
|
|
158
|
-
expect(src).to reek_of(:UncommunicativeVariableName, name: 'x')
|
159
|
-
|
154
|
+
expect(src).to reek_of(:UncommunicativeVariableName, name: 'x').
|
155
|
+
and reek_of(:UncommunicativeVariableName, name: 'y')
|
160
156
|
end
|
161
157
|
end
|
162
158
|
|
163
159
|
describe '`accept` patterns' do
|
164
160
|
let(:src) { 'def alfa; bravo2 = 42; end' }
|
165
161
|
|
162
|
+
# FIXME: Move the loop out of the it?
|
166
163
|
it 'make smelly names pass via regex / strings given by list / literal' do
|
167
|
-
expect(src).to reek_of(:UncommunicativeVariableName)
|
168
|
-
|
169
164
|
[[/bravo2/], /bravo2/, ['bravo2'], 'bravo2'].each do |pattern|
|
170
|
-
expect(src).
|
165
|
+
expect(src).to reek_of(:UncommunicativeVariableName).
|
166
|
+
and not_reek_of(:UncommunicativeVariableName).with_config('accept' => pattern)
|
171
167
|
end
|
172
168
|
end
|
173
169
|
end
|
@@ -175,17 +171,17 @@ RSpec.describe Reek::Smells::UncommunicativeVariableName do
|
|
175
171
|
describe '`reject` patterns' do
|
176
172
|
let(:src) { 'def alfa; foobar = 42; end' }
|
177
173
|
|
174
|
+
# FIXME: Move the loop out of the it?
|
178
175
|
it 'reject smelly names via regex / strings given by list / literal' do
|
179
|
-
expect(src).not_to reek_of(:UncommunicativeVariableName)
|
180
|
-
|
181
176
|
[[/foobar/], /foobar/, ['foobar'], 'foobar'].each do |pattern|
|
182
|
-
expect(src).to
|
177
|
+
expect(src).to not_reek_of(:UncommunicativeVariableName).
|
178
|
+
and reek_of(:UncommunicativeVariableName).with_config('reject' => pattern)
|
183
179
|
end
|
184
180
|
end
|
185
181
|
end
|
186
182
|
|
187
183
|
describe '.default_config' do
|
188
|
-
it '
|
184
|
+
it 'merges in the default accept and reject patterns' do
|
189
185
|
expected = {
|
190
186
|
'enabled' => true,
|
191
187
|
'exclude' => [],
|
@@ -22,82 +22,93 @@ RSpec.describe Reek::Smells::UnusedParameters do
|
|
22
22
|
end
|
23
23
|
EOS
|
24
24
|
|
25
|
-
expect(src).
|
26
|
-
|
27
|
-
|
28
|
-
expect(src).to reek_of(:UnusedParameters,
|
29
|
-
lines: [1],
|
30
|
-
name: 'charlie')
|
25
|
+
expect(src).
|
26
|
+
to reek_of(:UnusedParameters, lines: [1], name: 'bravo').
|
27
|
+
and reek_of(:UnusedParameters, lines: [1], name: 'charlie')
|
31
28
|
end
|
32
29
|
|
33
30
|
it 'reports nothing for no parameters' do
|
34
|
-
|
31
|
+
src = 'def alfa; end'
|
32
|
+
expect(src).not_to reek_of(:UnusedParameters)
|
35
33
|
end
|
36
34
|
|
37
35
|
it 'reports nothing for used parameter' do
|
38
|
-
|
36
|
+
src = 'def alfa(bravo); bravo; end'
|
37
|
+
expect(src).not_to reek_of(:UnusedParameters)
|
39
38
|
end
|
40
39
|
|
41
40
|
it 'reports for 1 used and 2 unused parameter' do
|
42
41
|
src = 'def alfa(bravo, charlie, delta); bravo end'
|
43
42
|
|
44
|
-
expect(src).
|
45
|
-
|
46
|
-
|
43
|
+
expect(src).
|
44
|
+
to not_reek_of(:UnusedParameters, name: 'bravo').
|
45
|
+
and reek_of(:UnusedParameters, name: 'charlie').
|
46
|
+
and reek_of(:UnusedParameters, name: 'delta')
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'reports nothing for named parameters prefixed with _' do
|
50
|
-
|
50
|
+
src = 'def alfa(_bravo); end'
|
51
|
+
expect(src).not_to reek_of(:UnusedParameters)
|
51
52
|
end
|
52
53
|
|
53
54
|
it 'reports nothing when using a parameter via self assignment' do
|
54
|
-
|
55
|
+
src = 'def alfa(bravo); bravo += 1; end'
|
56
|
+
expect(src).not_to reek_of(:UnusedParameters)
|
55
57
|
end
|
56
58
|
|
57
59
|
it 'reports nothing when using a parameter on a rescue' do
|
58
|
-
|
59
|
-
|
60
|
+
src = 'def alfa(bravo = 3); puts "nothing"; rescue; retry if bravo -= 1 > 0; raise; end'
|
61
|
+
expect(src).not_to reek_of(:UnusedParameters)
|
60
62
|
end
|
61
63
|
|
62
64
|
context 'using super' do
|
63
65
|
it 'reports nothing with implicit arguments' do
|
64
|
-
|
66
|
+
src = 'def alfa(*bravo); super; end'
|
67
|
+
expect(src).not_to reek_of(:UnusedParameters)
|
65
68
|
end
|
66
69
|
|
67
70
|
it 'reports something when explicitely passing no arguments' do
|
68
|
-
|
71
|
+
src = 'def alfa(*bravo); super(); end'
|
72
|
+
expect(src).to reek_of(:UnusedParameters)
|
69
73
|
end
|
70
74
|
|
71
75
|
it 'reports nothing when explicitely passing all arguments' do
|
72
|
-
|
76
|
+
src = 'def alfa(*bravo); super(*bravo); end'
|
77
|
+
expect(src).not_to reek_of(:UnusedParameters)
|
73
78
|
end
|
74
79
|
|
75
80
|
it 'reports nothing in a nested context' do
|
76
|
-
|
81
|
+
src = 'def alfa(*bravo); charlie(super); end'
|
82
|
+
expect(src).not_to reek_of(:UnusedParameters)
|
77
83
|
end
|
78
84
|
end
|
79
85
|
|
80
86
|
context 'anonymous parameters' do
|
81
87
|
it 'reports nothing for unused anonymous parameter' do
|
82
|
-
|
88
|
+
src = 'def alfa(_); end'
|
89
|
+
expect(src).not_to reek_of(:UnusedParameters)
|
83
90
|
end
|
84
91
|
|
85
92
|
it 'reports nothing for unused anonymous splatted parameter' do
|
86
|
-
|
93
|
+
src = 'def alfa(*); end'
|
94
|
+
expect(src).not_to reek_of(:UnusedParameters)
|
87
95
|
end
|
88
96
|
end
|
89
97
|
|
90
98
|
context 'splatted parameters' do
|
91
99
|
it 'reports nothing for used splatted parameter' do
|
92
|
-
|
100
|
+
src = 'def alfa(*bravo); bravo; end'
|
101
|
+
expect(src).not_to reek_of(:UnusedParameters)
|
93
102
|
end
|
94
103
|
|
95
104
|
it 'reports something when not using a keyword argument with splat' do
|
96
|
-
|
105
|
+
src = 'def alfa(**bravo); end'
|
106
|
+
expect(src).to reek_of(:UnusedParameters)
|
97
107
|
end
|
98
108
|
|
99
109
|
it 'reports nothing when using a keyword argument with splat' do
|
100
|
-
|
110
|
+
src = 'def alfa(**bravo); bravo; end'
|
111
|
+
expect(src).not_to reek_of(:UnusedParameters)
|
101
112
|
end
|
102
113
|
end
|
103
114
|
end
|
@@ -17,7 +17,7 @@ RSpec.describe Reek::Smells::UnusedPrivateMethod do
|
|
17
17
|
context: 'Alfa',
|
18
18
|
message: "has the unused private instance method 'charlie'",
|
19
19
|
source: 'string',
|
20
|
-
name:
|
20
|
+
name: 'charlie')
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'does count all occurences' do
|
@@ -33,12 +33,9 @@ RSpec.describe Reek::Smells::UnusedPrivateMethod do
|
|
33
33
|
end
|
34
34
|
EOS
|
35
35
|
|
36
|
-
expect(src).
|
37
|
-
|
38
|
-
|
39
|
-
expect(src).to reek_of(:UnusedPrivateMethod,
|
40
|
-
lines: [7],
|
41
|
-
name: :charlie)
|
36
|
+
expect(src).
|
37
|
+
to reek_of(:UnusedPrivateMethod, lines: [4], name: 'charlie').
|
38
|
+
and reek_of(:UnusedPrivateMethod, lines: [7], name: 'charlie')
|
42
39
|
end
|
43
40
|
|
44
41
|
context 'unused private methods' do
|
@@ -51,8 +48,9 @@ RSpec.describe Reek::Smells::UnusedPrivateMethod do
|
|
51
48
|
end
|
52
49
|
EOF
|
53
50
|
|
54
|
-
expect(source).
|
55
|
-
|
51
|
+
expect(source).
|
52
|
+
to reek_of(:UnusedPrivateMethod, name: 'bravo').
|
53
|
+
and reek_of(:UnusedPrivateMethod, name: 'charlie')
|
56
54
|
end
|
57
55
|
|
58
56
|
it 'reports instance methods in the correct class' do
|
@@ -65,12 +63,9 @@ RSpec.describe Reek::Smells::UnusedPrivateMethod do
|
|
65
63
|
end
|
66
64
|
EOF
|
67
65
|
|
68
|
-
expect(source).
|
69
|
-
|
70
|
-
|
71
|
-
expect(source).not_to reek_of(:UnusedPrivateMethod,
|
72
|
-
context: 'Alfa',
|
73
|
-
name: :charlie)
|
66
|
+
expect(source).
|
67
|
+
to reek_of(:UnusedPrivateMethod, context: 'Alfa::Bravo', name: 'charlie').
|
68
|
+
and not_reek_of(:UnusedPrivateMethod, context: 'Alfa', name: 'charlie')
|
74
69
|
end
|
75
70
|
|
76
71
|
it 'discounts calls to identically named methods in nested classes' do
|
@@ -90,12 +85,9 @@ RSpec.describe Reek::Smells::UnusedPrivateMethod do
|
|
90
85
|
end
|
91
86
|
EOF
|
92
87
|
|
93
|
-
expect(source).
|
94
|
-
|
95
|
-
|
96
|
-
expect(source).to reek_of(:UnusedPrivateMethod,
|
97
|
-
context: 'Alfa',
|
98
|
-
name: :charlie)
|
88
|
+
expect(source).
|
89
|
+
to reek_of(:UnusedPrivateMethod, context: 'Alfa', name: 'charlie').
|
90
|
+
and not_reek_of(:UnusedPrivateMethod, context: 'Alfo::Bravo', name: 'charlie')
|
99
91
|
end
|
100
92
|
|
101
93
|
it 'creates warnings correctly' do
|
@@ -107,12 +99,9 @@ RSpec.describe Reek::Smells::UnusedPrivateMethod do
|
|
107
99
|
end
|
108
100
|
EOF
|
109
101
|
|
110
|
-
expect(source).
|
111
|
-
|
112
|
-
|
113
|
-
expect(source).to reek_of(:UnusedPrivateMethod,
|
114
|
-
name: :charlie,
|
115
|
-
lines: [4])
|
102
|
+
expect(source).
|
103
|
+
to reek_of(:UnusedPrivateMethod, name: 'bravo', lines: [3]).
|
104
|
+
and reek_of(:UnusedPrivateMethod, name: 'charlie', lines: [4])
|
116
105
|
end
|
117
106
|
end
|
118
107
|
|
@@ -127,8 +116,9 @@ RSpec.describe Reek::Smells::UnusedPrivateMethod do
|
|
127
116
|
end
|
128
117
|
EOF
|
129
118
|
|
130
|
-
expect(source).
|
131
|
-
|
119
|
+
expect(source).
|
120
|
+
to reek_of(:UnusedPrivateMethod, name: 'charlie').
|
121
|
+
and not_reek_of(:UnusedPrivateMethod, name: 'bravo')
|
132
122
|
end
|
133
123
|
end
|
134
124
|
|
@@ -188,15 +178,17 @@ RSpec.describe Reek::Smells::UnusedPrivateMethod do
|
|
188
178
|
it 'excludes them via direct match in the app configuration' do
|
189
179
|
config = { Reek::Smells::SmellDetector::EXCLUDE_KEY => ['Alfa#charlie'] }
|
190
180
|
|
191
|
-
expect(source).
|
192
|
-
|
181
|
+
expect(source).
|
182
|
+
to reek_of(:UnusedPrivateMethod, name: 'bravo').with_config(config).
|
183
|
+
and not_reek_of(:UnusedPrivateMethod, name: 'charlie').with_config(config)
|
193
184
|
end
|
194
185
|
|
195
186
|
it 'excludes them via regex in the app configuration' do
|
196
187
|
config = { Reek::Smells::SmellDetector::EXCLUDE_KEY => [/charlie/] }
|
197
188
|
|
198
|
-
expect(source).
|
199
|
-
|
189
|
+
expect(source).
|
190
|
+
to reek_of(:UnusedPrivateMethod, name: 'bravo').with_config(config).
|
191
|
+
and not_reek_of(:UnusedPrivateMethod, name: 'charlie').with_config(config)
|
200
192
|
end
|
201
193
|
end
|
202
194
|
end
|