reek 2.2.0 → 2.2.1
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/CHANGELOG +4 -0
- data/features/samples.feature +6 -14
- data/lib/reek/sexp/sexp_extensions.rb +23 -1
- data/lib/reek/version.rb +1 -1
- data/spec/reek/smells/boolean_parameter_spec.rb +26 -0
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +12 -0
- data/spec/samples/{ruby20_syntax.rb → unusual_syntax.rb} +8 -0
- metadata +4 -5
- data/spec/samples/ruby21_syntax.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 988f551b421341be717b93689070ad4d8b809a2a
|
4
|
+
data.tar.gz: 2089735509323d24ea39425e5aa3a67ba888cb40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38f11b564b3ae5f11d53849ece35b2ea544f83c4ced89e4e344a8a4b7a2d76470f614fd51890f2379faeac35860cc01fca62c643c8a864786ac15a3640c8aa16
|
7
|
+
data.tar.gz: c24c9b966287c29db29073c5aad19e4890d1949d9d49c0d38478d4ed48f45818d4665b302704a98a58867f99156ee0865cccff71ebb18fbda90bd34eeca9e2c1
|
data/CHANGELOG
CHANGED
data/features/samples.feature
CHANGED
@@ -279,22 +279,14 @@ Feature: Basic smell detection
|
|
279
279
|
RedCloth#v_align doesn't depend on instance state (UtilityFunction)
|
280
280
|
"""
|
281
281
|
|
282
|
-
Scenario: Correct smells from a source file with
|
283
|
-
Given the "
|
284
|
-
When I run reek
|
282
|
+
Scenario: Correct smells from a source file with unusual syntax samples
|
283
|
+
Given the "unusual_syntax.rb" sample file exists
|
284
|
+
When I run reek unusual_syntax.rb
|
285
285
|
Then the exit status indicates smells
|
286
286
|
And it reports:
|
287
287
|
"""
|
288
|
-
|
289
|
-
[1]:SomeClass has no descriptive comment (IrresponsibleModule)
|
290
|
-
"""
|
291
|
-
|
292
|
-
Scenario: Correct smells from a source file with Ruby 2.1 specific syntax
|
293
|
-
Given the "ruby21_syntax.rb" sample file exists
|
294
|
-
When I run reek ruby21_syntax.rb
|
295
|
-
Then the exit status indicates smells
|
296
|
-
And it reports:
|
297
|
-
"""
|
298
|
-
ruby21_syntax.rb -- 1 warning:
|
288
|
+
unusual_syntax.rb -- 3 warnings:
|
299
289
|
[1]:SomeClass has no descriptive comment (IrresponsibleModule)
|
290
|
+
[18]:SomeClass#method_with_array_decomposition has the parameter name 'a' (UncommunicativeParameterName)
|
291
|
+
[18]:SomeClass#method_with_array_decomposition has the parameter name 'b' (UncommunicativeParameterName)
|
300
292
|
"""
|
@@ -38,6 +38,10 @@ module Reek
|
|
38
38
|
def anonymous_splat?
|
39
39
|
false
|
40
40
|
end
|
41
|
+
|
42
|
+
def components
|
43
|
+
[self]
|
44
|
+
end
|
41
45
|
end
|
42
46
|
|
43
47
|
# Utility methods for :arg nodes.
|
@@ -97,6 +101,24 @@ module Reek
|
|
97
101
|
include ArgNodeBase
|
98
102
|
end
|
99
103
|
|
104
|
+
# Base module for utility methods for nodes that can contain argument
|
105
|
+
# nodes nested through :mlhs nodes.
|
106
|
+
module NestedAssignables
|
107
|
+
def components
|
108
|
+
children.flat_map(&:components)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Utility methods for :args nodes.
|
113
|
+
module ArgsNode
|
114
|
+
include NestedAssignables
|
115
|
+
end
|
116
|
+
|
117
|
+
# Utility methods for :mlhs nodes.
|
118
|
+
module MlhsNode
|
119
|
+
include NestedAssignables
|
120
|
+
end
|
121
|
+
|
100
122
|
# Base module for utility methods for :and and :or nodes.
|
101
123
|
module LogicOperatorBase
|
102
124
|
def condition() self[1] end
|
@@ -203,7 +225,7 @@ module Reek
|
|
203
225
|
end
|
204
226
|
|
205
227
|
def parameters
|
206
|
-
argslist.
|
228
|
+
argslist.components
|
207
229
|
end
|
208
230
|
|
209
231
|
def parameter_names
|
data/lib/reek/version.rb
CHANGED
@@ -20,6 +20,32 @@ RSpec.describe Reek::Smells::BooleanParameter do
|
|
20
20
|
expect(src).to reek_of(:BooleanParameter, name: 'arga')
|
21
21
|
expect(src).to reek_of(:BooleanParameter, name: 'argb')
|
22
22
|
end
|
23
|
+
|
24
|
+
it 'reports keyword parameters defaulted to booleans' do
|
25
|
+
src = 'def cc(arga: true, argb: false) end'
|
26
|
+
expect(src).to reek_of(:BooleanParameter, name: 'arga')
|
27
|
+
expect(src).to reek_of(:BooleanParameter, name: 'argb')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'does not report regular parameters' do
|
31
|
+
src = 'def cc(a, b) end'
|
32
|
+
expect(src).not_to reek_of(:BooleanParameter)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'does not report array decomposition parameters' do
|
36
|
+
src = 'def cc((a, b)) end'
|
37
|
+
expect(src).not_to reek_of(:BooleanParameter)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'does not report keyword parameters with no default' do
|
41
|
+
src = 'def cc(a:, b:) end'
|
42
|
+
expect(src).not_to reek_of(:BooleanParameter)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'does not report keyword parameters with non-boolean default' do
|
46
|
+
src = 'def cc(a: 42, b: "32") end'
|
47
|
+
expect(src).not_to reek_of(:BooleanParameter)
|
48
|
+
end
|
23
49
|
end
|
24
50
|
|
25
51
|
context 'in a singleton method' do
|
@@ -63,6 +63,18 @@ RSpec.describe Reek::Smells::UncommunicativeParameterName do
|
|
63
63
|
expect("def #{host}help(_unused) basics(_unused) end").
|
64
64
|
to reek_of(:UncommunicativeParameterName)
|
65
65
|
end
|
66
|
+
|
67
|
+
it 'reports names inside array decomposition' do
|
68
|
+
src = "def #{host}help((b, nice)) basics(b, nice) end"
|
69
|
+
expect(src).to reek_of(:UncommunicativeParameterName,
|
70
|
+
name: 'b')
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'reports names inside nested array decomposition' do
|
74
|
+
src = "def #{host}help((foo, (bar, c))) basics(foo, c) end"
|
75
|
+
expect(src).to reek_of(:UncommunicativeParameterName,
|
76
|
+
name: 'c')
|
77
|
+
end
|
66
78
|
end
|
67
79
|
end
|
68
80
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reek
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Rutherford
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-05-
|
13
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parser
|
@@ -414,14 +414,13 @@ files:
|
|
414
414
|
- spec/samples/no_config_file/dirty.rb
|
415
415
|
- spec/samples/optparse.rb
|
416
416
|
- spec/samples/redcloth.rb
|
417
|
-
- spec/samples/ruby20_syntax.rb
|
418
|
-
- spec/samples/ruby21_syntax.rb
|
419
417
|
- spec/samples/simple_configuration.reek
|
420
418
|
- spec/samples/three_clean_files/clean_one.rb
|
421
419
|
- spec/samples/three_clean_files/clean_three.rb
|
422
420
|
- spec/samples/three_clean_files/clean_two.rb
|
423
421
|
- spec/samples/two_smelly_files/dirty_one.rb
|
424
422
|
- spec/samples/two_smelly_files/dirty_two.rb
|
423
|
+
- spec/samples/unusual_syntax.rb
|
425
424
|
- spec/spec_helper.rb
|
426
425
|
- tasks/develop.rake
|
427
426
|
- tasks/reek.rake
|
@@ -451,7 +450,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
451
450
|
version: '0'
|
452
451
|
requirements: []
|
453
452
|
rubyforge_project:
|
454
|
-
rubygems_version: 2.4.
|
453
|
+
rubygems_version: 2.4.6
|
455
454
|
signing_key:
|
456
455
|
specification_version: 4
|
457
456
|
summary: Code smell detector for Ruby
|