cookstyle 7.4.0 → 7.5.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
  SHA256:
3
- metadata.gz: afe67bc1be4b70753843d22598cd29dd7edded20c3762230d4cbfb08ba2ed240
4
- data.tar.gz: f4f3c739c446a6560b8f9319c63b87dc48c2d338ad45316369a1ed848d40222a
3
+ metadata.gz: '01118e6811d695f00d05bc6ff6fbadffdc7180cc0488ff23967fa2e2477d630a'
4
+ data.tar.gz: e1fb1c02d972c9412189868c2d8f8938c8b3b8bcf38884b3043005b2ffc704f8
5
5
  SHA512:
6
- metadata.gz: 64ec5f89be1438ba7e29f1e19e9f8b6ebbac1320550f5b32d2a5d58b7ea1994ed4fe08f1243a1328beb46acca4da67608d6ba4b0f3944487adc8af90f9e8fc5e
7
- data.tar.gz: 7b6118d966b9585555db7cd3d7b61114e5229a792d9bd9ee23e71a0330ca004187f8ca11cda4b6922c57007ddd0d8e57d30e925f957517dce27ee24532da7cfa
6
+ metadata.gz: e81aaa04919a2e4d2f00b60beb00d4641d6f2290434d36a7cee05e444fb79df7173492597fea7349000afe76571f690ab3dd2576d9f5c9a960f6e3a25a621f07
7
+ data.tar.gz: 0a799de7b53c5708542e00e92501b7cab4c92eb4dc9ee2d33b6990229f6a60bca3adaf12527275dd3f92bf3134411ee570cd39ad39ec1a08a07d75c7d48bf8b5
@@ -169,6 +169,8 @@ Layout/SpaceAroundOperators:
169
169
  Enabled: false
170
170
  Layout/SpaceBeforeBlockBraces:
171
171
  Enabled: false
172
+ Layout/SpaceBeforeBrackets:
173
+ Enabled: false
172
174
  Layout/SpaceBeforeComma:
173
175
  Enabled: false
174
176
  Layout/SpaceBeforeComment:
@@ -201,6 +203,8 @@ Layout/TrailingEmptyLines:
201
203
  Enabled: false
202
204
  Layout/TrailingWhitespace:
203
205
  Enabled: false
206
+ Lint/AmbiguousAssignment:
207
+ Enabled: false
204
208
  Lint/AmbiguousBlockAssociation:
205
209
  Enabled: false
206
210
  Lint/AmbiguousOperator:
@@ -613,6 +617,8 @@ Style/HashAsLastArrayItem:
613
617
  Enabled: false
614
618
  Style/HashEachMethods:
615
619
  Enabled: false
620
+ Style/HashExcept:
621
+ Enabled: false
616
622
  Style/HashLikeCase:
617
623
  Enabled: false
618
624
  Style/HashSyntax:
@@ -473,7 +473,7 @@ Layout/EmptyLineBetweenDefs:
473
473
  StyleGuide: '#empty-lines-between-methods'
474
474
  Enabled: true
475
475
  VersionAdded: '0.49'
476
- VersionChanged: '1.4'
476
+ VersionChanged: '1.7'
477
477
  EmptyLineBetweenMethodDefs: true
478
478
  EmptyLineBetweenClassDefs: true
479
479
  EmptyLineBetweenModuleDefs: true
@@ -1192,6 +1192,13 @@ Layout/SpaceBeforeBlockBraces:
1192
1192
  - no_space
1193
1193
  VersionChanged: '0.52'
1194
1194
 
1195
+ Layout/SpaceBeforeBrackets:
1196
+ Description: 'Checks for receiver with a space before the opening brackets.'
1197
+ StyleGuide: '#space-in-brackets-access'
1198
+ Enabled: pending
1199
+ VersionAdded: '1.7'
1200
+ Safe: false
1201
+
1195
1202
  Layout/SpaceBeforeComma:
1196
1203
  Description: 'No spaces before commas.'
1197
1204
  Enabled: true
@@ -1354,6 +1361,11 @@ Layout/TrailingWhitespace:
1354
1361
  #################### Lint ##################################
1355
1362
  ### Warnings
1356
1363
 
1364
+ Lint/AmbiguousAssignment:
1365
+ Description: 'Checks for mistyped shorthand assignments.'
1366
+ Enabled: pending
1367
+ VersionAdded: '1.7'
1368
+
1357
1369
  Lint/AmbiguousBlockAssociation:
1358
1370
  Description: >-
1359
1371
  Checks for ambiguous block association with method when param passed without
@@ -1396,6 +1408,7 @@ Lint/BinaryOperatorWithIdenticalOperands:
1396
1408
  Enabled: true
1397
1409
  Safe: false
1398
1410
  VersionAdded: '0.89'
1411
+ VersionChanged: '1.7'
1399
1412
 
1400
1413
  Lint/BooleanSymbol:
1401
1414
  Description: 'Check for `:true` and `:false` symbols.'
@@ -1472,6 +1485,9 @@ Lint/DuplicateBranch:
1472
1485
  Description: Checks that there are no repeated bodies within `if/unless`, `case-when` and `rescue` constructs.
1473
1486
  Enabled: pending
1474
1487
  VersionAdded: '1.3'
1488
+ VersionChanged: '1.7'
1489
+ IgnoreLiteralBranches: false
1490
+ IgnoreConstantBranches: false
1475
1491
 
1476
1492
  Lint/DuplicateCaseCondition:
1477
1493
  Description: 'Do not repeat values in case conditionals.'
@@ -1842,6 +1858,8 @@ Lint/RedundantSplatExpansion:
1842
1858
  Description: 'Checks for splat unnecessarily being called on literals.'
1843
1859
  Enabled: true
1844
1860
  VersionAdded: '0.76'
1861
+ VersionChanged: '1.7'
1862
+ AllowPercentLiteralArrayArgument: true
1845
1863
 
1846
1864
  Lint/RedundantStringCoercion:
1847
1865
  Description: 'Checks for Object#to_s usage in string interpolation.'
@@ -2045,6 +2063,11 @@ Lint/UnreachableLoop:
2045
2063
  Description: 'This cop checks for loops that will have at most one iteration.'
2046
2064
  Enabled: true
2047
2065
  VersionAdded: '0.89'
2066
+ VersionChanged: '1.7'
2067
+ IgnoredPatterns:
2068
+ # RSpec uses `times` in its message expectations
2069
+ # eg. `exactly(2).times`
2070
+ - !ruby/regexp /(exactly|at_least|at_most)\(\d+\)\.times/
2048
2071
 
2049
2072
  Lint/UnusedBlockArgument:
2050
2073
  Description: 'Checks for unused block arguments.'
@@ -2895,7 +2918,7 @@ Style/CollectionMethods:
2895
2918
  StyleGuide: '#map-find-select-reduce-include-size'
2896
2919
  Enabled: false
2897
2920
  VersionAdded: '0.9'
2898
- VersionChanged: '0.27'
2921
+ VersionChanged: '1.7'
2899
2922
  Safe: false
2900
2923
  # Mapping from undesired method to desired method
2901
2924
  # e.g. to use `detect` over `find`:
@@ -2910,6 +2933,11 @@ Style/CollectionMethods:
2910
2933
  detect: 'find'
2911
2934
  find_all: 'select'
2912
2935
  member?: 'include?'
2936
+ # Methods in this array accept a final symbol as an implicit block
2937
+ # eg. `inject(:+)`
2938
+ MethodsAcceptingSymbol:
2939
+ - inject
2940
+ - reduce
2913
2941
 
2914
2942
  Style/ColonMethodCall:
2915
2943
  Description: 'Do not use :: for method call.'
@@ -2969,6 +2997,7 @@ Style/CommentedKeyword:
2969
2997
  Description: 'Do not place comments on the same line as certain keywords.'
2970
2998
  Enabled: true
2971
2999
  VersionAdded: '0.51'
3000
+ VersionChanged: '1.7'
2972
3001
 
2973
3002
  Style/ConditionalAssignment:
2974
3003
  Description: >-
@@ -3328,6 +3357,13 @@ Style/HashEachMethods:
3328
3357
  VersionAdded: '0.80'
3329
3358
  Safe: false
3330
3359
 
3360
+ Style/HashExcept:
3361
+ Description: >-
3362
+ Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
3363
+ that can be replaced with `Hash#except` method.
3364
+ Enabled: pending
3365
+ VersionAdded: '1.7'
3366
+
3331
3367
  Style/HashLikeCase:
3332
3368
  Description: >-
3333
3369
  Checks for places where `case-when` represents a simple 1:1
@@ -3482,6 +3518,7 @@ Style/KeywordParametersOrder:
3482
3518
  StyleGuide: '#keyword-parameters-order'
3483
3519
  Enabled: true
3484
3520
  VersionAdded: '0.90'
3521
+ VersionChanged: '1.7'
3485
3522
 
3486
3523
  Style/Lambda:
3487
3524
  Description: 'Use the new lambda literal syntax for single-line blocks.'
@@ -3520,7 +3557,7 @@ Style/MethodCallWithArgsParentheses:
3520
3557
  StyleGuide: '#method-invocation-parens'
3521
3558
  Enabled: false
3522
3559
  VersionAdded: '0.47'
3523
- VersionChanged: '0.61'
3560
+ VersionChanged: '1.7'
3524
3561
  IgnoreMacros: true
3525
3562
  IgnoredMethods: []
3526
3563
  IgnoredPatterns: []
@@ -3554,7 +3591,7 @@ Style/MethodDefParentheses:
3554
3591
  StyleGuide: '#method-parens'
3555
3592
  Enabled: true
3556
3593
  VersionAdded: '0.16'
3557
- VersionChanged: '0.35'
3594
+ VersionChanged: '1.7'
3558
3595
  EnforcedStyle: require_parentheses
3559
3596
  SupportedStyles:
3560
3597
  - require_parentheses
@@ -3660,6 +3697,7 @@ Style/MultilineMethodSignature:
3660
3697
  Description: 'Avoid multi-line method signatures.'
3661
3698
  Enabled: false
3662
3699
  VersionAdded: '0.59'
3700
+ VersionChanged: '1.7'
3663
3701
 
3664
3702
  Style/MultilineTernaryOperator:
3665
3703
  Description: >-
@@ -4026,12 +4064,16 @@ Style/RedundantArgument:
4026
4064
  Enabled: pending
4027
4065
  Safe: false
4028
4066
  VersionAdded: '1.4'
4029
- VersionChanged: '1.6'
4067
+ VersionChanged: '1.7'
4030
4068
  Methods:
4031
4069
  # Array#join
4032
4070
  join: ''
4033
4071
  # String#split
4034
4072
  split: ' '
4073
+ # String#chomp
4074
+ chomp: "\n"
4075
+ # String#chomp!
4076
+ chomp!: "\n"
4035
4077
 
4036
4078
  Style/RedundantAssignment:
4037
4079
  Description: 'Checks for redundant assignment before returning.'
@@ -4288,7 +4330,7 @@ Style/SingleLineMethods:
4288
4330
  StyleGuide: '#no-single-line-methods'
4289
4331
  Enabled: true
4290
4332
  VersionAdded: '0.9'
4291
- VersionChanged: '0.19'
4333
+ VersionChanged: '1.7'
4292
4334
  AllowIfMethodIsEmpty: true
4293
4335
 
4294
4336
  Style/SlicingWithRange:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Cookstyle
3
- VERSION = "7.4.0" # rubocop: disable Style/StringLiterals
4
- RUBOCOP_VERSION = '1.6.1'
3
+ VERSION = "7.5.1" # rubocop: disable Style/StringLiterals
4
+ RUBOCOP_VERSION = '1.7.0'
5
5
  end
@@ -28,6 +28,7 @@ module RuboCop
28
28
  # property :name, String, name_property: true
29
29
  # attribute :name, kind_of: String
30
30
  # attribute :name, kind_of: String, name_attribute: true
31
+ # attribute :name, name_attribute: true, kind_of: String
31
32
  #
32
33
  class UnnecessaryNameProperty < Base
33
34
  extend AutoCorrector
@@ -35,36 +36,25 @@ module RuboCop
35
36
  MSG = 'There is no need to define a property or attribute named :name in a resource as Chef Infra defines this on all resources by default.'
36
37
  RESTRICT_ON_SEND = [:property, :attribute].freeze
37
38
 
38
- def_node_matcher :name_attribute?, <<-PATTERN
39
- (send nil? :attribute
40
- (sym :name)
41
- (hash
42
- (pair
43
- (sym :kind_of)
44
- (const nil? :String))
45
- (pair
46
- (sym :name_attribute)
47
- (true))?))
48
- PATTERN
49
-
50
39
  def_node_matcher :name_property?, <<-PATTERN
51
- (send nil? :property
52
- (sym :name)
53
- (const nil? :String)
54
- (hash
55
- (pair
56
- (sym :name_property)
57
- (true)))?)
40
+ (send nil? {:attribute :property}
41
+ (sym :name)
42
+ (const nil? :String)?
43
+ (hash $...)?
44
+ )
58
45
  PATTERN
59
46
 
60
47
  def on_send(node)
61
- name_property?(node) do
62
- add_offense(node, message: MSG, severity: :refactor) do |corrector|
63
- corrector.remove(node.source_range)
48
+ name_property?(node) do |hash_vals|
49
+ # It's perfectly valid to redefine the name property if you give it non-default values
50
+ # We do this in a few of our core resources where we give it a default value of "" for nameless resources
51
+ # If there are hash vals in this attribute/property compare them with the default keys and if there's anything
52
+ # else return so we don't alert
53
+ unless hash_vals.empty?
54
+ hash_keys = hash_vals.first.map { |x| x.key.value }
55
+ return unless (hash_keys - [:kind_of, :name_attribute, :name_property]).empty?
64
56
  end
65
- end
66
57
 
67
- name_attribute?(node) do
68
58
  add_offense(node, message: MSG, severity: :refactor) do |corrector|
69
59
  corrector.remove(node.source_range)
70
60
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookstyle
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.4.0
4
+ version: 7.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-12-21 00:00:00.000000000 Z
12
+ date: 2020-12-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubocop
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 1.6.1
20
+ version: 1.7.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 1.6.1
27
+ version: 1.7.0
28
28
  description:
29
29
  email:
30
30
  - thom@chef.io