reek 5.3.1 → 5.3.2
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 +5 -5
- data/.rubocop.yml +0 -9
- data/.travis.yml +1 -2
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/docs/API.md +4 -4
- data/docs/Duplicate-Method-Call.md +68 -1
- data/docs/How-To-Write-New-Detectors.md +4 -4
- data/docs/Reek-Driven-Development.md +19 -12
- data/features/command_line_interface/options.feature +2 -2
- data/features/reports/json.feature +3 -3
- data/features/reports/reports.feature +4 -4
- data/features/reports/yaml.feature +3 -3
- data/lib/reek/source/source_code.rb +2 -2
- data/lib/reek/version.rb +1 -1
- data/spec/reek/ast/node_spec.rb +2 -2
- data/spec/reek/code_comment_spec.rb +6 -6
- data/spec/reek/context/code_context_spec.rb +2 -2
- data/spec/reek/context_builder_spec.rb +30 -30
- data/spec/reek/examiner_spec.rb +6 -6
- data/spec/reek/report/json_report_spec.rb +2 -2
- data/spec/reek/smell_detectors/attribute_spec.rb +32 -32
- data/spec/reek/smell_detectors/boolean_parameter_spec.rb +4 -4
- data/spec/reek/smell_detectors/class_variable_spec.rb +16 -16
- data/spec/reek/smell_detectors/control_parameter_spec.rb +18 -18
- data/spec/reek/smell_detectors/data_clump_spec.rb +16 -16
- data/spec/reek/smell_detectors/duplicate_method_call_spec.rb +20 -20
- data/spec/reek/smell_detectors/feature_envy_spec.rb +32 -32
- data/spec/reek/smell_detectors/instance_variable_assumption_spec.rb +12 -12
- data/spec/reek/smell_detectors/irresponsible_module_spec.rb +36 -36
- data/spec/reek/smell_detectors/long_parameter_list_spec.rb +6 -6
- data/spec/reek/smell_detectors/long_yield_list_spec.rb +6 -6
- data/spec/reek/smell_detectors/manual_dispatch_spec.rb +10 -10
- data/spec/reek/smell_detectors/missing_safe_method_spec.rb +8 -8
- data/spec/reek/smell_detectors/module_initialize_spec.rb +12 -12
- data/spec/reek/smell_detectors/nested_iterators_spec.rb +48 -48
- data/spec/reek/smell_detectors/nil_check_spec.rb +16 -16
- data/spec/reek/smell_detectors/repeated_conditional_spec.rb +8 -8
- data/spec/reek/smell_detectors/subclassed_from_core_class_spec.rb +10 -10
- data/spec/reek/smell_detectors/too_many_constants_spec.rb +22 -22
- data/spec/reek/smell_detectors/too_many_instance_variables_spec.rb +16 -16
- data/spec/reek/smell_detectors/too_many_methods_spec.rb +6 -6
- data/spec/reek/smell_detectors/too_many_statements_spec.rb +10 -10
- data/spec/reek/smell_detectors/uncommunicative_method_name_spec.rb +2 -2
- data/spec/reek/smell_detectors/uncommunicative_module_name_spec.rb +2 -2
- data/spec/reek/smell_detectors/uncommunicative_parameter_name_spec.rb +4 -4
- data/spec/reek/smell_detectors/uncommunicative_variable_name_spec.rb +18 -18
- data/spec/reek/smell_detectors/unused_parameters_spec.rb +4 -4
- data/spec/reek/smell_detectors/unused_private_method_spec.rb +24 -24
- data/spec/reek/smell_detectors/utility_function_spec.rb +30 -30
- metadata +3 -3
@@ -3,13 +3,13 @@ require_lib 'reek/smell_detectors/feature_envy'
|
|
3
3
|
|
4
4
|
RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
5
5
|
it 'reports the right values' do
|
6
|
-
src = <<-
|
6
|
+
src = <<-RUBY
|
7
7
|
class Alfa
|
8
8
|
def bravo(charlie)
|
9
9
|
(charlie.delta - charlie.echo) * foxtrot
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
RUBY
|
13
13
|
|
14
14
|
expect(src).to reek_of(:FeatureEnvy,
|
15
15
|
lines: [3, 3],
|
@@ -20,7 +20,7 @@ RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'does count all occurences' do
|
23
|
-
src = <<-
|
23
|
+
src = <<-RUBY
|
24
24
|
class Alfa
|
25
25
|
def bravo(charlie)
|
26
26
|
(charlie.delta - charlie.echo) * foxtrot
|
@@ -30,7 +30,7 @@ RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
|
30
30
|
(hotel.india + hotel.juliett) * kilo
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
33
|
+
RUBY
|
34
34
|
|
35
35
|
expect(src).
|
36
36
|
to reek_of(:FeatureEnvy, lines: [3, 3], name: 'charlie').
|
@@ -108,7 +108,7 @@ RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'ignores multiple ivars' do
|
111
|
-
src = <<-
|
111
|
+
src = <<-RUBY
|
112
112
|
def func
|
113
113
|
@alfa.charlie
|
114
114
|
@alfa.delta
|
@@ -116,13 +116,13 @@ RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
|
116
116
|
@bravo.echo
|
117
117
|
@bravo.foxtrot
|
118
118
|
end
|
119
|
-
|
119
|
+
RUBY
|
120
120
|
|
121
121
|
expect(src).not_to reek_of(:FeatureEnvy)
|
122
122
|
end
|
123
123
|
|
124
124
|
it 'report highest affinity' do
|
125
|
-
src = <<-
|
125
|
+
src = <<-RUBY
|
126
126
|
def alfa
|
127
127
|
bravo = @charlie
|
128
128
|
delta = 0
|
@@ -130,7 +130,7 @@ RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
|
130
130
|
delta += bravo.foxtrot
|
131
131
|
delta *= 1.15
|
132
132
|
end
|
133
|
-
|
133
|
+
RUBY
|
134
134
|
|
135
135
|
expect(src).
|
136
136
|
to reek_of(:FeatureEnvy, name: 'delta').
|
@@ -138,14 +138,14 @@ RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
|
138
138
|
end
|
139
139
|
|
140
140
|
it 'reports multiple affinities' do
|
141
|
-
src = <<-
|
141
|
+
src = <<-RUBY
|
142
142
|
def alfa
|
143
143
|
bravo = @charlie
|
144
144
|
delta = 0
|
145
145
|
delta += bravo.echo
|
146
146
|
delta += bravo.foxtrot
|
147
147
|
end
|
148
|
-
|
148
|
+
RUBY
|
149
149
|
|
150
150
|
expect(src).
|
151
151
|
to reek_of(:FeatureEnvy, name: 'delta').
|
@@ -153,75 +153,75 @@ RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
|
153
153
|
end
|
154
154
|
|
155
155
|
it 'is not fooled by duplication' do
|
156
|
-
src = <<-
|
156
|
+
src = <<-RUBY
|
157
157
|
def alfa(bravo)
|
158
158
|
@charlie.delta(bravo.echo)
|
159
159
|
@foxtrot.delta(bravo.echo)
|
160
160
|
end
|
161
|
-
|
161
|
+
RUBY
|
162
162
|
|
163
163
|
expect(src).to reek_only_of(:DuplicateMethodCall, name: 'bravo.echo')
|
164
164
|
end
|
165
165
|
|
166
166
|
it 'counts local calls' do
|
167
|
-
src = <<-
|
167
|
+
src = <<-RUBY
|
168
168
|
def alfa(bravo)
|
169
169
|
charlie.delta(bravo.echo)
|
170
170
|
foxtrot.delta(bravo.echo)
|
171
171
|
end
|
172
|
-
|
172
|
+
RUBY
|
173
173
|
|
174
174
|
expect(src).to reek_only_of(:DuplicateMethodCall, name: 'bravo.echo')
|
175
175
|
end
|
176
176
|
|
177
177
|
it 'reports many calls to lvar' do
|
178
|
-
src = <<-
|
178
|
+
src = <<-RUBY
|
179
179
|
def alfa
|
180
180
|
bravo = @charlie
|
181
181
|
bravo.delta + bravo.echo
|
182
182
|
end
|
183
|
-
|
183
|
+
RUBY
|
184
184
|
|
185
185
|
expect(src).to reek_only_of(:FeatureEnvy)
|
186
186
|
end
|
187
187
|
|
188
188
|
it 'counts =~ as a call' do
|
189
|
-
src = <<-
|
189
|
+
src = <<-RUBY
|
190
190
|
def alfa(bravo)
|
191
191
|
charlie(bravo.delta)
|
192
192
|
bravo =~ /charlie/
|
193
193
|
end
|
194
|
-
|
194
|
+
RUBY
|
195
195
|
|
196
196
|
expect(src).to reek_of :FeatureEnvy
|
197
197
|
end
|
198
198
|
|
199
199
|
it 'counts += as a call' do
|
200
|
-
src = <<-
|
200
|
+
src = <<-RUBY
|
201
201
|
def alfa(bravo)
|
202
202
|
charlie(bravo.delta)
|
203
203
|
bravo += 1
|
204
204
|
end
|
205
|
-
|
205
|
+
RUBY
|
206
206
|
|
207
207
|
expect(src).to reek_of :FeatureEnvy
|
208
208
|
end
|
209
209
|
|
210
210
|
it 'counts ivar assignment as call to self' do
|
211
|
-
src = <<-
|
211
|
+
src = <<-RUBY
|
212
212
|
def foo
|
213
213
|
bravo = charlie(1, 2)
|
214
214
|
|
215
215
|
@delta = bravo.echo
|
216
216
|
@foxtrot = bravo.golf
|
217
217
|
end
|
218
|
-
|
218
|
+
RUBY
|
219
219
|
|
220
220
|
expect(src).not_to reek_of :FeatureEnvy
|
221
221
|
end
|
222
222
|
|
223
223
|
it 'counts self references correctly' do
|
224
|
-
src = <<-
|
224
|
+
src = <<-RUBY
|
225
225
|
def alfa(bravo)
|
226
226
|
bravo.keys.each do |charlie|
|
227
227
|
self[charlie] += 3
|
@@ -229,13 +229,13 @@ RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
|
229
229
|
end
|
230
230
|
self
|
231
231
|
end
|
232
|
-
|
232
|
+
RUBY
|
233
233
|
|
234
234
|
expect(src).not_to reek_of(:FeatureEnvy)
|
235
235
|
end
|
236
236
|
|
237
237
|
it 'interprets << correctly' do
|
238
|
-
src = <<-
|
238
|
+
src = <<-RUBY
|
239
239
|
def alfa(bravo)
|
240
240
|
if @charlie
|
241
241
|
bravo.delta(self)
|
@@ -243,13 +243,13 @@ RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
|
243
243
|
bravo << self
|
244
244
|
end
|
245
245
|
end
|
246
|
-
|
246
|
+
RUBY
|
247
247
|
|
248
248
|
expect(src).not_to reek_of(:FeatureEnvy)
|
249
249
|
end
|
250
250
|
|
251
251
|
it 'does not report on class methods defined by opening the metaclass' do
|
252
|
-
src = <<-
|
252
|
+
src = <<-RUBY
|
253
253
|
class Alfa
|
254
254
|
class << self
|
255
255
|
def bravo(charlie)
|
@@ -259,13 +259,13 @@ RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
|
259
259
|
end
|
260
260
|
end
|
261
261
|
end
|
262
|
-
|
262
|
+
RUBY
|
263
263
|
|
264
264
|
expect(src).not_to reek_of(:FeatureEnvy)
|
265
265
|
end
|
266
266
|
|
267
267
|
it 'does not report on class methods defined with an explicit receiver' do
|
268
|
-
src = <<-
|
268
|
+
src = <<-RUBY
|
269
269
|
class Alfa
|
270
270
|
def self.bravo(charlie)
|
271
271
|
delta = new(charlie)
|
@@ -273,13 +273,13 @@ RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
|
273
273
|
delta.echo
|
274
274
|
end
|
275
275
|
end
|
276
|
-
|
276
|
+
RUBY
|
277
277
|
|
278
278
|
expect(src).not_to reek_of(:FeatureEnvy)
|
279
279
|
end
|
280
280
|
|
281
281
|
it 'does not report module functions' do
|
282
|
-
src = <<-
|
282
|
+
src = <<-RUBY
|
283
283
|
module Alfa
|
284
284
|
module_function
|
285
285
|
def bravo(charlie)
|
@@ -288,7 +288,7 @@ RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
|
288
288
|
echo.foxtrot
|
289
289
|
end
|
290
290
|
end
|
291
|
-
|
291
|
+
RUBY
|
292
292
|
|
293
293
|
expect(src).not_to reek_of(:FeatureEnvy)
|
294
294
|
end
|
@@ -4,13 +4,13 @@ require_lib 'reek/smell_detectors/instance_variable_assumption'
|
|
4
4
|
|
5
5
|
RSpec.describe Reek::SmellDetectors::InstanceVariableAssumption do
|
6
6
|
it 'reports the right values' do
|
7
|
-
src = <<-
|
7
|
+
src = <<-RUBY
|
8
8
|
class Alfa
|
9
9
|
def bravo
|
10
10
|
@charlie
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
13
|
+
RUBY
|
14
14
|
|
15
15
|
expect(src).to reek_of(:InstanceVariableAssumption,
|
16
16
|
lines: [1],
|
@@ -21,7 +21,7 @@ RSpec.describe Reek::SmellDetectors::InstanceVariableAssumption do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'does count all occurences' do
|
24
|
-
src = <<-
|
24
|
+
src = <<-RUBY
|
25
25
|
class Alfa
|
26
26
|
def bravo
|
27
27
|
@charlie
|
@@ -32,7 +32,7 @@ RSpec.describe Reek::SmellDetectors::InstanceVariableAssumption do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
RUBY
|
36
36
|
|
37
37
|
expect(src).
|
38
38
|
to reek_of(:InstanceVariableAssumption, lines: [1], assumption: '@charlie').
|
@@ -40,28 +40,28 @@ RSpec.describe Reek::SmellDetectors::InstanceVariableAssumption do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'does not report an empty class' do
|
43
|
-
src = <<-
|
43
|
+
src = <<-RUBY
|
44
44
|
class Alfa
|
45
45
|
end
|
46
|
-
|
46
|
+
RUBY
|
47
47
|
|
48
48
|
expect(src).not_to reek_of(:InstanceVariableAssumption)
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'does not report when lazy initializing' do
|
52
|
-
src = <<-
|
52
|
+
src = <<-RUBY
|
53
53
|
class Alfa
|
54
54
|
def bravo
|
55
55
|
@charlie ||= 1
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
58
|
+
RUBY
|
59
59
|
|
60
60
|
expect(src).not_to reek_of(:InstanceVariableAssumption)
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'reports variable even if others are initialized' do
|
64
|
-
src = <<-
|
64
|
+
src = <<-RUBY
|
65
65
|
class Alfa
|
66
66
|
def initialize
|
67
67
|
@bravo = 1
|
@@ -71,13 +71,13 @@ RSpec.describe Reek::SmellDetectors::InstanceVariableAssumption do
|
|
71
71
|
[@bravo, @delta]
|
72
72
|
end
|
73
73
|
end
|
74
|
-
|
74
|
+
RUBY
|
75
75
|
|
76
76
|
expect(src).to reek_of(:InstanceVariableAssumption, assumption: '@delta')
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'reports inner class even if outer class initializes the variable' do
|
80
|
-
src = <<-
|
80
|
+
src = <<-RUBY
|
81
81
|
class Alfa
|
82
82
|
def initialize
|
83
83
|
@bravo = 1
|
@@ -89,7 +89,7 @@ RSpec.describe Reek::SmellDetectors::InstanceVariableAssumption do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
92
|
-
|
92
|
+
RUBY
|
93
93
|
|
94
94
|
expect(src).to reek_of(:InstanceVariableAssumption, context: 'Alfa::Charlie')
|
95
95
|
end
|
@@ -3,10 +3,10 @@ require_lib 'reek/smell_detectors/irresponsible_module'
|
|
3
3
|
|
4
4
|
RSpec.describe Reek::SmellDetectors::IrresponsibleModule do
|
5
5
|
it 'reports the right values' do
|
6
|
-
src = <<-
|
6
|
+
src = <<-RUBY
|
7
7
|
class Alfa
|
8
8
|
end
|
9
|
-
|
9
|
+
RUBY
|
10
10
|
|
11
11
|
expect(src).to reek_of(:IrresponsibleModule,
|
12
12
|
lines: [1],
|
@@ -16,14 +16,14 @@ RSpec.describe Reek::SmellDetectors::IrresponsibleModule do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'does count all occurences' do
|
19
|
-
src = <<-
|
19
|
+
src = <<-RUBY
|
20
20
|
class Alfa
|
21
21
|
# Method is necessary because we don't count namespace classes.
|
22
22
|
def bravo; end
|
23
23
|
class Charlie
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
RUBY
|
27
27
|
|
28
28
|
expect(src).
|
29
29
|
to reek_of(:IrresponsibleModule, lines: [1], context: 'Alfa').
|
@@ -32,58 +32,58 @@ RSpec.describe Reek::SmellDetectors::IrresponsibleModule do
|
|
32
32
|
|
33
33
|
%w(class module).each do |scope|
|
34
34
|
it "reports a #{scope} without a comment" do
|
35
|
-
src = <<-
|
35
|
+
src = <<-RUBY
|
36
36
|
#{scope} Alfa
|
37
37
|
end
|
38
|
-
|
38
|
+
RUBY
|
39
39
|
|
40
40
|
expect(src).to reek_of(:IrresponsibleModule)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "does not report a #{scope} having a comment" do
|
44
|
-
src = <<-
|
44
|
+
src = <<-RUBY
|
45
45
|
# Do not report me, I'm responsible!
|
46
46
|
#{scope} Alfa; end
|
47
|
-
|
47
|
+
RUBY
|
48
48
|
|
49
49
|
expect(src).not_to reek_of(:IrresponsibleModule)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "reports a #{scope} with an empty comment" do
|
53
|
-
src = <<-
|
53
|
+
src = <<-RUBY
|
54
54
|
#
|
55
55
|
#
|
56
56
|
#
|
57
57
|
#{scope} Alfa; end
|
58
|
-
|
58
|
+
RUBY
|
59
59
|
|
60
60
|
expect(src).to reek_of(:IrresponsibleModule)
|
61
61
|
end
|
62
62
|
|
63
63
|
it "reports a #{scope} with a preceding comment with intermittent material" do
|
64
|
-
src = <<-
|
64
|
+
src = <<-RUBY
|
65
65
|
# This is a comment that should not be related to Bravo
|
66
66
|
|
67
67
|
require 'alfa'
|
68
68
|
|
69
69
|
#{scope} Bravo
|
70
70
|
end
|
71
|
-
|
71
|
+
RUBY
|
72
72
|
|
73
73
|
expect(src).to reek_of(:IrresponsibleModule)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "reports a #{scope} with only a trailing comment" do
|
77
|
-
src = <<-
|
77
|
+
src = <<-RUBY
|
78
78
|
#{scope} Alfa
|
79
79
|
end # This belongs to Alfa but doesn't count
|
80
|
-
|
80
|
+
RUBY
|
81
81
|
|
82
82
|
expect(src).to reek_of(:IrresponsibleModule)
|
83
83
|
end
|
84
84
|
|
85
85
|
it "does not report #{scope} used only as a namespace" do
|
86
|
-
src = <<-
|
86
|
+
src = <<-RUBY
|
87
87
|
#{scope} Alfa
|
88
88
|
# Describes Bravo
|
89
89
|
#{scope} Bravo
|
@@ -91,13 +91,13 @@ RSpec.describe Reek::SmellDetectors::IrresponsibleModule do
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
94
|
-
|
94
|
+
RUBY
|
95
95
|
|
96
96
|
expect(src).not_to reek_of(:IrresponsibleModule, context: 'Alfa')
|
97
97
|
end
|
98
98
|
|
99
99
|
it "does not report #{scope} used only as a namespace for several nested moduless" do
|
100
|
-
src = <<-
|
100
|
+
src = <<-RUBY
|
101
101
|
#{scope} Alfa
|
102
102
|
# Describes Bravo
|
103
103
|
class Bravo
|
@@ -109,13 +109,13 @@ RSpec.describe Reek::SmellDetectors::IrresponsibleModule do
|
|
109
109
|
module Delta
|
110
110
|
end
|
111
111
|
end
|
112
|
-
|
112
|
+
RUBY
|
113
113
|
|
114
114
|
expect(src).not_to reek_of(:IrresponsibleModule, context: 'Alfa')
|
115
115
|
end
|
116
116
|
|
117
117
|
it "reports #{scope} that is used as a namespace but also has methods" do
|
118
|
-
src = <<-
|
118
|
+
src = <<-RUBY
|
119
119
|
#{scope} Alfa
|
120
120
|
def bravo
|
121
121
|
end
|
@@ -124,13 +124,13 @@ RSpec.describe Reek::SmellDetectors::IrresponsibleModule do
|
|
124
124
|
#{scope} Charlie
|
125
125
|
end
|
126
126
|
end
|
127
|
-
|
127
|
+
RUBY
|
128
128
|
|
129
129
|
expect(src).to reek_of(:IrresponsibleModule, context: 'Alfa')
|
130
130
|
end
|
131
131
|
|
132
132
|
it "reports #{scope} that is used as a namespace but also has singleton methods" do
|
133
|
-
src = <<-
|
133
|
+
src = <<-RUBY
|
134
134
|
#{scope} Alfa
|
135
135
|
def self.bravo
|
136
136
|
end
|
@@ -139,78 +139,78 @@ RSpec.describe Reek::SmellDetectors::IrresponsibleModule do
|
|
139
139
|
#{scope} Charlie
|
140
140
|
end
|
141
141
|
end
|
142
|
-
|
142
|
+
RUBY
|
143
143
|
|
144
144
|
expect(src).to reek_of(:IrresponsibleModule, context: 'Alfa')
|
145
145
|
end
|
146
146
|
|
147
147
|
it "does not report a namespace #{scope} that has a nested class through assignment" do
|
148
|
-
src = <<-
|
148
|
+
src = <<-RUBY
|
149
149
|
#{scope} Alfa
|
150
150
|
# Bravo is responsible
|
151
151
|
Bravo = Class.new Charlie do
|
152
152
|
def delta; end
|
153
153
|
end
|
154
154
|
end
|
155
|
-
|
155
|
+
RUBY
|
156
156
|
|
157
157
|
expect(src).not_to reek_of(:IrresponsibleModule, context: 'Alfa')
|
158
158
|
end
|
159
159
|
|
160
160
|
it "does not report #{scope} only containing constants" do
|
161
|
-
src = <<-
|
161
|
+
src = <<-RUBY
|
162
162
|
#{scope} Alfa
|
163
163
|
Bravo = 23
|
164
164
|
end
|
165
|
-
|
165
|
+
RUBY
|
166
166
|
|
167
167
|
expect(src).not_to reek_of(:IrresponsibleModule, context: 'Alfa')
|
168
168
|
end
|
169
169
|
|
170
170
|
it "reports #{scope} that contains method calls" do
|
171
|
-
src = <<-
|
171
|
+
src = <<-RUBY
|
172
172
|
#{scope} Alfa
|
173
173
|
bravo :charlie
|
174
174
|
end
|
175
|
-
|
175
|
+
RUBY
|
176
176
|
|
177
177
|
expect(src).to reek_of(:IrresponsibleModule, context: 'Alfa')
|
178
178
|
end
|
179
179
|
|
180
180
|
it "reports #{scope} that contains non-constant assignments" do
|
181
|
-
src = <<-
|
181
|
+
src = <<-RUBY
|
182
182
|
#{scope} Alfa
|
183
183
|
bravo = charlie
|
184
184
|
end
|
185
|
-
|
185
|
+
RUBY
|
186
186
|
|
187
187
|
expect(src).to reek_of(:IrresponsibleModule, context: 'Alfa')
|
188
188
|
end
|
189
189
|
|
190
190
|
it "reports an irresponsible #{scope} defined through assignment" do
|
191
|
-
src = <<-
|
191
|
+
src = <<-RUBY
|
192
192
|
# Alfa is responsible, but Bravo is not
|
193
193
|
#{scope} Alfa
|
194
194
|
Bravo = Class.new Charlie # Only "class" is supposed to reek here.
|
195
195
|
end
|
196
|
-
|
196
|
+
RUBY
|
197
197
|
|
198
198
|
expect(src).to reek_of(:IrresponsibleModule, context: 'Alfa::Bravo')
|
199
199
|
end
|
200
200
|
|
201
201
|
it 'reports structs defined through assignment' do
|
202
|
-
src = <<-
|
202
|
+
src = <<-RUBY
|
203
203
|
# Alfa is responsible, but Bravo is not
|
204
204
|
#{scope} Alfa
|
205
205
|
Bravo = Struct.new(:charlie)
|
206
206
|
end
|
207
|
-
|
207
|
+
RUBY
|
208
208
|
|
209
209
|
expect(src).to reek_of(:IrresponsibleModule, context: 'Alfa::Bravo')
|
210
210
|
end
|
211
211
|
|
212
212
|
it 'does not report constants that are not classes' do
|
213
|
-
src = <<-
|
213
|
+
src = <<-RUBY
|
214
214
|
# Alfa is responsible
|
215
215
|
#{scope} Alfa
|
216
216
|
Bravo = 23
|
@@ -218,7 +218,7 @@ RSpec.describe Reek::SmellDetectors::IrresponsibleModule do
|
|
218
218
|
Delta = ''.freeze
|
219
219
|
Echo = Class.new.new
|
220
220
|
end
|
221
|
-
|
221
|
+
RUBY
|
222
222
|
|
223
223
|
expect(src).not_to reek_of(:IrresponsibleModule)
|
224
224
|
end
|