reek 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afd9361841a4f7ae194b659bbc70c06e4bef20f2
4
- data.tar.gz: 52e321f176aca45a3c424aff60749ad3bc11f695
3
+ metadata.gz: 988f551b421341be717b93689070ad4d8b809a2a
4
+ data.tar.gz: 2089735509323d24ea39425e5aa3a67ba888cb40
5
5
  SHA512:
6
- metadata.gz: 87df16e382177e9a3a2f0f6465fb3eaed25ccebf274f9ebb8f3918ba81a860f93895a780c48ee12ddcae529ac544dda89715e132880ddbeee5b001a165c38003
7
- data.tar.gz: 82b2b6aa9cde0da91999aff5ddcf8f2b6a7096b1766294023ddc3c58b0162f3e5bb27cdc653d8d0a2521f844c5580f2459d0ea2b6d66df7c31b4d7f29ab50f87
6
+ metadata.gz: 38f11b564b3ae5f11d53849ece35b2ea544f83c4ced89e4e344a8a4b7a2d76470f614fd51890f2379faeac35860cc01fca62c643c8a864786ac15a3640c8aa16
7
+ data.tar.gz: c24c9b966287c29db29073c5aad19e4890d1949d9d49c0d38478d4ed48f45818d4665b302704a98a58867f99156ee0865cccff71ebb18fbda90bd34eeca9e2c1
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 2.2.1
2
+
3
+ * (mvz) Support methods using array decomposition arguments
4
+
1
5
  == 2.2.0
2
6
 
3
7
  * (sauliusgrigaitis) Add support for XML reports
@@ -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 Ruby 2.0 specific syntax
283
- Given the "ruby20_syntax.rb" sample file exists
284
- When I run reek ruby20_syntax.rb
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
- ruby20_syntax.rb -- 1 warning:
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.children
228
+ argslist.components
207
229
  end
208
230
 
209
231
  def parameter_names
@@ -3,6 +3,6 @@ module Reek
3
3
  # This module holds the Reek version informations
4
4
  #
5
5
  module Version
6
- STRING = '2.2.0'
6
+ STRING = '2.2.1'
7
7
  end
8
8
  end
@@ -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
 
@@ -10,4 +10,12 @@ class SomeClass
10
10
  def make_other_symbol_list
11
11
  %I(foo bar baz)
12
12
  end
13
+
14
+ def method_with_required_keyword_arguments(foo:)
15
+ puts foo
16
+ end
17
+
18
+ def method_with_array_decomposition((a, b))
19
+ puts "#{a}, #{b}"
20
+ end
13
21
  end
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.0
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-09 00:00:00.000000000 Z
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.5
453
+ rubygems_version: 2.4.6
455
454
  signing_key:
456
455
  specification_version: 4
457
456
  summary: Code smell detector for Ruby
@@ -1,5 +0,0 @@
1
- class SomeClass
2
- def method_with_required_keyword_arguments(foo:)
3
- puts foo
4
- end
5
- end