cookstyle 1.2.0 → 1.3.0

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: 8c56119ca74e509ed6974159f8d803695e5a1386
4
- data.tar.gz: 01c8f3aef8e2ae28dbe378e8c9113e058afb3bca
3
+ metadata.gz: 75b32711348d3f0b5891a824438bd01b37ce7fd6
4
+ data.tar.gz: f5d36c386380ec83f1451fcd8febc76465daef7a
5
5
  SHA512:
6
- metadata.gz: 331fcfe4d7e8be43448f841451b05e4745c6d3e91e8fc05e0f11fe5989ad889e30f52b10eb4ea58d0fcb13adb6ff6e6c99ae607adaefd0b76802c7ee7a7b0c5c
7
- data.tar.gz: e9a0775ab1793a1608f276e4dae1abcafa1cb6870eb40e2689d7128dddf96f0ab168399593c8b01a0b080a9d58ad977d7dd62f0cb14da56d3254179d48a651e0
6
+ metadata.gz: b24c45f4629433a677a32d2b0da198d9c4553118979868e63f99ec3a6834de6b71c69bda1b3bc08dbfa5e8887ecd083bd3388dcbf37d93db005d0cc62621caf9
7
+ data.tar.gz: 462d275f1fae9a901196afdbe0fc7fd10870843dc9bd5f7be4b40437ecee2355ebeb17aa401ca6b5e118ac7590a9c820ad4bc2e48cda47e1608db42774537208
data/.travis.yml CHANGED
@@ -6,6 +6,12 @@ sudo: false
6
6
  branches:
7
7
  only:
8
8
  - master
9
+
10
+ # Early warning system to catch if Rubygems breaks something
11
+ before_install:
12
+ - gem update --system
13
+
9
14
  rvm:
10
- - 2.2.5
11
- - 2.3.1
15
+ - 2.2.6
16
+ - 2.3.3
17
+ - 2.4.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Cookstyle Changelog
2
2
 
3
+ ## 1.3.0 (2017-02-13)
4
+
5
+ - Upgraded the Rubocop engine from 0.46 -> 0.47.1, but disabled all new cops. This aligns cookstyle with the Rubocop in Chefstyle and also resolves multiple bugs in Rubocop 0.46\. If you previously disabled the Lint/Eval cop in your own Rubocop config you'll need to update that with the new cop name of Security/Eval.
6
+
3
7
  ## 1.2.0 (2017-01-19)
4
8
 
5
9
  - Change Style/NumericPredicate to use comparisons. We found that cookstyle autocorrecting code from foo == 0 to foo.zero? was breaking a lot of cookbooks. Additionally .zero? is significantly slower than just using foo == 0.
data/README.md CHANGED
@@ -1,14 +1,20 @@
1
- # Cookstyle - Version Pinned rubocop and sane defaults for Chef Cookbooks
1
+ # Cookstyle - Sane rubocop defaults for Chef Cookbooks
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/cookstyle.svg)](https://badge.fury.io/rb/cookstyle) [![Build Status](https://travis-ci.org/chef/cookstyle.svg?branch=master)](https://travis-ci.org/chef/cookstyle)
4
4
 
5
- Pull Requests will not be accepted that assume unfunded mandates for other people to finish the work cleaning up various Chef owned cookbooks. Do not open PRs offering opinions or suggestions without offering to do the work.
5
+ Cookstyle is a set of opinions about ruby code that are specific to
6
+ cookbooks. Running both cookstyle and rubocop on the same codebase will
7
+ result, by design, in changes being applied and then removed. Needless
8
+ to say you should *not* use both tools on the same cookbook.
6
9
 
7
- The project itself is a derivative of [finstyle](https://github.com/fnichol/finstyle), but starts with all rules disabled. The active ruleset is in the [config/cookstyle.yml](https://github.com/chef/cookstyle/blob/master/config/cookstyle.yml) file.
10
+ Cookstyle is included in the ChefDK, and can be used from the command
11
+ line by running `cookstyle`.
12
+
13
+ The active ruleset is in the [config/cookstyle.yml](https://github.com/chef/cookstyle/blob/master/config/cookstyle.yml) file. Changes to the rule set must be accompanied by arguments and code demonstrating why the change should be made, and in most cases we would expect the author of the change to help with updating the core community cookbooks.
8
14
 
9
15
  ## How It Works
10
16
 
11
- This library has a direct dependency on one specific version of RuboCop (at a time), and [patches it][patch] to load the [upstream configuration][upstream] and [custom set][config] of rule updates. When a new RuboCop release comes out, this library can rev its pinned version dependency and [re-vendor][rakefile] the upstream configuration to determine if any breaking style or lint rules were added/dropped/reversed/etc.
17
+ The project itself is a derivative of [finstyle](https://github.com/fnichol/finstyle), but starts with all rules disabled. Cookstyle has a direct dependency on one specific version of RuboCop (at a time), and [patches it][patch] to load the [upstream configuration][upstream] and [custom set][config] of rule updates. When a new RuboCop release comes out, this library can rev its pinned version dependency and [re-vendor][rakefile] the upstream configuration to determine if any breaking style or lint rules were added/dropped/reversed/etc.
12
18
 
13
19
  ## NOTE CAREFULLY ABOUT UPDATING COOKSTYLE
14
20
 
@@ -28,6 +34,9 @@ When editing the `cookstyle_base.yml` becomes too much of a PITA, it may be time
28
34
 
29
35
  ## Installation
30
36
 
37
+ Cookstyle is included in the [ChefDK](https://downloads.chef.io/chefdk). If you choose not to use ChefDK,
38
+ you can still install Cookstyle manually using the instructions below.
39
+
31
40
  Add this line to your application's Gemfile:
32
41
 
33
42
  ```ruby
data/config/cookstyle.yml CHANGED
@@ -15,6 +15,10 @@ Style/Alias:
15
15
  Enabled: false
16
16
  Style/SpaceBeforeFirstArg:
17
17
  Enabled: false
18
+ Style/ClassAndModuleChildren:
19
+ Enabled: false
20
+
21
+ # disable all the length cops as they're not appropriate for cookbooks
18
22
  LineLength:
19
23
  Enabled: false
20
24
  MethodLength:
@@ -29,8 +33,6 @@ Metrics/CyclomaticComplexity:
29
33
  Enabled: false
30
34
  PerceivedComplexity:
31
35
  Enabled: false
32
- Style/ClassAndModuleChildren:
33
- Enabled: false
34
36
 
35
37
  # https://github.com/chef/cookstyle/pull/5
36
38
  Style/TrailingCommaInLiteral:
@@ -376,7 +376,7 @@ Lint/EndInMethod:
376
376
  Enabled: true
377
377
  Lint/EnsureReturn:
378
378
  Enabled: true
379
- Lint/Eval:
379
+ Security/Eval:
380
380
  Enabled: true
381
381
  Lint/FloatOutOfRange:
382
382
  Enabled: true
@@ -1,4 +1,8 @@
1
1
  ---
2
+ Bundler/DuplicatedGem:
3
+ Enabled: false
4
+ Bundler/OrderedGems:
5
+ Enabled: false
2
6
  Lint/AmbiguousOperator:
3
7
  Enabled: false
4
8
  Lint/AmbiguousRegexpLiteral:
@@ -41,8 +45,6 @@ Lint/EndInMethod:
41
45
  Enabled: false
42
46
  Lint/EnsureReturn:
43
47
  Enabled: false
44
- Lint/Eval:
45
- Enabled: false
46
48
  Lint/FloatOutOfRange:
47
49
  Enabled: false
48
50
  Lint/FormatParameterMismatch:
@@ -63,6 +65,8 @@ Lint/LiteralInInterpolation:
63
65
  Enabled: false
64
66
  Lint/Loop:
65
67
  Enabled: false
68
+ Lint/MultipleCompare:
69
+ Enabled: false
66
70
  Lint/NestedMethodDefinition:
67
71
  Enabled: false
68
72
  Lint/NextWithoutAccumulator:
@@ -81,6 +85,8 @@ Lint/RequireParentheses:
81
85
  Enabled: false
82
86
  Lint/RescueException:
83
87
  Enabled: false
88
+ Lint/SafeNavigationChain:
89
+ Enabled: false
84
90
  Lint/ShadowedException:
85
91
  Enabled: false
86
92
  Lint/ShadowingOuterLocalVariable:
@@ -163,13 +169,15 @@ Performance/RedundantMerge:
163
169
  Enabled: false
164
170
  Performance/RedundantSortBy:
165
171
  Enabled: false
172
+ Performance/RegexpMatch:
173
+ Enabled: false
166
174
  Performance/ReverseEach:
167
175
  Enabled: false
168
176
  Performance/Sample:
169
177
  Enabled: false
170
178
  Performance/Size:
171
179
  Enabled: false
172
- Performance/SortWithBlock:
180
+ Performance/CompareWithBlock:
173
181
  Enabled: false
174
182
  Performance/StartWith:
175
183
  Enabled: false
@@ -285,6 +293,8 @@ Style/EmptyLinesAroundModuleBody:
285
293
  Enabled: false
286
294
  Style/EmptyLiteral:
287
295
  Enabled: false
296
+ Style/EmptyMethod:
297
+ Enabled: false
288
298
  Style/Encoding:
289
299
  Enabled: false
290
300
  Style/EndBlock:
@@ -357,7 +367,9 @@ Style/LeadingCommentSpace:
357
367
  Enabled: false
358
368
  Style/LineEndConcatenation:
359
369
  Enabled: false
360
- Style/MethodCallParentheses:
370
+ Style/MethodCallWithoutArgsParentheses:
371
+ Enabled: false
372
+ Style/MethodCallWithArgsParentheses:
361
373
  Enabled: false
362
374
  Style/MethodCalledOnDoEndBlock:
363
375
  Enabled: false
@@ -593,8 +605,12 @@ Rails/Delegate:
593
605
  Enabled: false
594
606
  Rails/DelegateAllowBlank:
595
607
  Enabled: false
608
+ Rails/EnumUniqueness:
609
+ Enabled: false
596
610
  Rails/Exit:
597
611
  Enabled: false
612
+ Rails/FilePath:
613
+ Enabled: false
598
614
  Rails/FindBy:
599
615
  Enabled: false
600
616
  Rails/FindEach:
@@ -615,17 +631,27 @@ Rails/ReadWriteAttribute:
615
631
  Enabled: false
616
632
  Rails/RequestReferer:
617
633
  Enabled: false
634
+ Rails/ReversibleMigration:
635
+ Enabled: false
618
636
  Rails/SafeNavigation:
619
637
  Enabled: false
620
638
  Rails/SaveBang:
621
639
  Enabled: false
622
640
  Rails/ScopeArgs:
623
641
  Enabled: false
642
+ Rails/SkipsModelValidations:
643
+ Enabled: false
624
644
  Rails/TimeZone:
625
645
  Enabled: false
626
646
  Rails/UniqBeforePluck:
627
647
  Enabled: false
628
648
  Rails/Validation:
629
649
  Enabled: false
650
+ Security/Eval:
651
+ Enabled: false
630
652
  Security/JSONLoad:
631
653
  Enabled: false
654
+ Security/MarshalLoad:
655
+ Enabled: false
656
+ Security/YAMLLoad:
657
+ Enabled: false
data/config/disabled.yml CHANGED
@@ -69,6 +69,11 @@ Style/InlineComment:
69
69
  Description: 'Avoid trailing inline comments.'
70
70
  Enabled: false
71
71
 
72
+ Style/MethodCallWithArgsParentheses:
73
+ Description: 'Use parentheses for method calls with arguments.'
74
+ StyleGuide: '#method-invocation-parens'
75
+ Enabled: false
76
+
72
77
  Style/MethodCalledOnDoEndBlock:
73
78
  Description: 'Avoid chaining a method call on a do...end block.'
74
79
  StyleGuide: '#single-line-blocks'
@@ -113,3 +118,7 @@ Style/SymbolArray:
113
118
  Description: 'Use %i or %I for arrays of symbols.'
114
119
  StyleGuide: '#percent-i'
115
120
  Enabled: false
121
+
122
+ Style/SingleLineBlockParams:
123
+ Description: 'Enforces the names of some block params.'
124
+ Enabled: false
data/config/enabled.yml CHANGED
@@ -404,7 +404,7 @@ Style/LineEndConcatenation:
404
404
  line end.
405
405
  Enabled: true
406
406
 
407
- Style/MethodCallParentheses:
407
+ Style/MethodCallWithoutArgsParentheses:
408
408
  Description: 'Do not use parentheses for method calls with no arguments.'
409
409
  StyleGuide: '#method-invocation-parens'
410
410
  Enabled: true
@@ -710,10 +710,6 @@ Style/SignalException:
710
710
  StyleGuide: '#prefer-raise-over-fail'
711
711
  Enabled: true
712
712
 
713
- Style/SingleLineBlockParams:
714
- Description: 'Enforces the names of some block params.'
715
- Enabled: true
716
-
717
713
  Style/SingleLineMethods:
718
714
  Description: 'Avoid single-line methods.'
719
715
  StyleGuide: '#no-single-line-methods'
@@ -1120,10 +1116,6 @@ Lint/EnsureReturn:
1120
1116
  StyleGuide: '#no-return-ensure'
1121
1117
  Enabled: true
1122
1118
 
1123
- Lint/Eval:
1124
- Description: 'The use of eval represents a serious security risk.'
1125
- Enabled: true
1126
-
1127
1119
  Lint/FloatOutOfRange:
1128
1120
  Description: >-
1129
1121
  Catches floating-point literals too large or small for Ruby to
@@ -1176,6 +1168,10 @@ Lint/Loop:
1176
1168
  StyleGuide: '#loop-with-break'
1177
1169
  Enabled: true
1178
1170
 
1171
+ Lint/MultipleCompare:
1172
+ Description: "Use `&&` operator to compare multiple value."
1173
+ Enabled: true
1174
+
1179
1175
  Lint/NestedMethodDefinition:
1180
1176
  Description: 'Do not use nested method definitions.'
1181
1177
  StyleGuide: '#no-nested-methods'
@@ -1225,6 +1221,10 @@ Lint/RescueException:
1225
1221
  StyleGuide: '#no-blind-rescues'
1226
1222
  Enabled: true
1227
1223
 
1224
+ Lint/SafeNavigationChain:
1225
+ Description: 'Do not chain ordinary method call after safe navigation operator.'
1226
+ Enabled: true
1227
+
1228
1228
  Lint/ShadowedException:
1229
1229
  Description: >-
1230
1230
  Avoid rescuing a higher level exception
@@ -1279,6 +1279,7 @@ Lint/UselessAccessModifier:
1279
1279
  Description: 'Checks for useless access modifiers.'
1280
1280
  Enabled: true
1281
1281
  ContextCreatingMethods: []
1282
+ MethodCreatingMethods: []
1282
1283
 
1283
1284
  Lint/UselessAssignment:
1284
1285
  Description: 'Checks for useless assignment to a local variable.'
@@ -1408,6 +1409,10 @@ Performance/RedundantSortBy:
1408
1409
  Description: 'Use `sort` instead of `sort_by { |x| x }`.'
1409
1410
  Enabled: true
1410
1411
 
1412
+ Performance/RegexpMatch:
1413
+ Description: 'Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`, `Regexp#===` or `=~` when `MatchData` is not used.'
1414
+ Enabled: true
1415
+
1411
1416
  Performance/ReverseEach:
1412
1417
  Description: 'Use `reverse_each` instead of `reverse.each`.'
1413
1418
  Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
@@ -1488,6 +1493,10 @@ Rails/Exit:
1488
1493
  exits during unit testing or running in production.
1489
1494
  Enabled: true
1490
1495
 
1496
+ Rails/FilePath:
1497
+ Description: 'Use `Rails.root.join` for file path joining.'
1498
+ Enabled: true
1499
+
1491
1500
  Rails/FindBy:
1492
1501
  Description: 'Prefer find_by over where.first.'
1493
1502
  StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find_by'
@@ -1537,6 +1546,12 @@ Rails/RequestReferer:
1537
1546
  Description: 'Use consistent syntax for request.referer.'
1538
1547
  Enabled: true
1539
1548
 
1549
+ Rails/ReversibleMigration:
1550
+ Description: 'Checks whether the change method of the migration file is reversible.'
1551
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#reversible-migration'
1552
+ Reference: 'http://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
1553
+ Enabled: true
1554
+
1540
1555
  Rails/SafeNavigation:
1541
1556
  Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
1542
1557
  Enabled: true
@@ -1555,10 +1570,21 @@ Rails/UniqBeforePluck:
1555
1570
  Description: 'Prefer the use of uniq or distinct before pluck.'
1556
1571
  Enabled: true
1557
1572
 
1573
+ Rails/SkipsModelValidations:
1574
+ Description: >-
1575
+ Use methods that skips model validations with caution.
1576
+ See reference for more information.
1577
+ Reference: 'http://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
1578
+ Enabled: true
1579
+
1558
1580
  Rails/Validation:
1559
1581
  Description: 'Use validates :attribute, hash of validations.'
1560
1582
  Enabled: true
1561
1583
 
1584
+ Security/Eval:
1585
+ Description: 'The use of eval represents a serious security risk.'
1586
+ Enabled: true
1587
+
1562
1588
  Security/JSONLoad:
1563
1589
  Description: >-
1564
1590
  Prefer usage of `JSON.parse` over `JSON.load` due to potential
@@ -1569,6 +1595,20 @@ Security/JSONLoad:
1569
1595
  # on the value of the argument.
1570
1596
  AutoCorrect: false
1571
1597
 
1598
+ Security/MarshalLoad:
1599
+ Description: >-
1600
+ Avoid using of `Marshal.load` or `Marshal.restore` due to potential
1601
+ security issues. See reference for more information.
1602
+ Reference: 'http://ruby-doc.org/core-2.3.3/Marshal.html#module-Marshal-label-Security+considerations'
1603
+ Enabled: true
1604
+
1605
+ Security/YAMLLoad:
1606
+ Description: >-
1607
+ Prefer usage of `YAML.safe_load` over `YAML.load` due to potential
1608
+ security issues. See reference for more information.
1609
+ Reference: 'https://ruby-doc.org/stdlib-2.3.3/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
1610
+ Enabled: true
1611
+
1572
1612
  ##################### Bundler #############################
1573
1613
 
1574
1614
  Bundler/DuplicatedGem:
data/config/upstream.yml CHANGED
@@ -29,35 +29,35 @@ AllCops:
29
29
  - '**/*Fastfile'
30
30
  Exclude:
31
31
  - 'vendor/**/*'
32
- # Default formatter will be used if no -f/--format option is given.
32
+ # Default formatter will be used if no `-f/--format` option is given.
33
33
  DefaultFormatter: progress
34
34
  # Cop names are not displayed in offense messages by default. Change behavior
35
- # by overriding DisplayCopNames, or by giving the -D/--display-cop-names
35
+ # by overriding DisplayCopNames, or by giving the `-D/--display-cop-names`
36
36
  # option.
37
37
  DisplayCopNames: false
38
38
  # Style guide URLs are not displayed in offense messages by default. Change
39
- # behavior by overriding DisplayStyleGuide, or by giving the
40
- # -S/--display-style-guide option.
39
+ # behavior by overriding `DisplayStyleGuide`, or by giving the
40
+ # `-S/--display-style-guide` option.
41
41
  DisplayStyleGuide: false
42
42
  # When specifying style guide URLs, any paths and/or fragments will be
43
43
  # evaluated relative to the base URL.
44
44
  StyleGuideBaseURL: https://github.com/bbatsov/ruby-style-guide
45
45
  # Extra details are not displayed in offense messages by default. Change
46
46
  # behavior by overriding ExtraDetails, or by giving the
47
- # -E/--extra-details option.
47
+ # `-E/--extra-details` option.
48
48
  ExtraDetails: false
49
49
  # Additional cops that do not reference a style guide rule may be enabled by
50
- # default. Change behavior by overriding StyleGuideCopsOnly, or by giving
51
- # the --only-guide-cops option.
50
+ # default. Change behavior by overriding `StyleGuideCopsOnly`, or by giving
51
+ # the `--only-guide-cops` option.
52
52
  StyleGuideCopsOnly: false
53
53
  # All cops except the ones in disabled.yml are enabled by default. Change
54
- # this behavior by overriding DisabledByDefault. When DisabledByDefault is
55
- # true, all cops in the default configuration are disabled, and and only cops
54
+ # this behavior by overriding `DisabledByDefault`. When `DisabledByDefault` is
55
+ # `true`, all cops in the default configuration are disabled, and only cops
56
56
  # in user configuration are enabled. This makes cops opt-in instead of
57
- # opt-out. Note that when DisabledByDefault is true, cops in user
57
+ # opt-out. Note that when `DisabledByDefault` is `true`, cops in user
58
58
  # configuration will be enabled even if they don't set the Enabled parameter.
59
59
  DisabledByDefault: false
60
- # Enables the result cache if true. Can be overridden by the --cache command
60
+ # Enables the result cache if `true`. Can be overridden by the `--cache` command
61
61
  # line option.
62
62
  UseCache: true
63
63
  # Threshold for how many files can be stored in the result cache before some
@@ -113,6 +113,10 @@ Style/AlignHash:
113
113
  # 'a' => 2
114
114
  # 'bb' => 3
115
115
  EnforcedHashRocketStyle: key
116
+ SupportedHashRocketStyles:
117
+ - key
118
+ - separator
119
+ - table
116
120
  # Alignment of entries using colon as separator. Valid values are:
117
121
  #
118
122
  # key - left alignment of keys
@@ -125,6 +129,10 @@ Style/AlignHash:
125
129
  # a: 0
126
130
  # bb: 1
127
131
  EnforcedColonStyle: key
132
+ SupportedColonStyles:
133
+ - key
134
+ - separator
135
+ - table
128
136
  # Select whether hashes that are the last argument in a method call should be
129
137
  # inspected? Valid values are:
130
138
  #
@@ -194,7 +202,7 @@ Style/AndOr:
194
202
  - conditionals
195
203
 
196
204
 
197
- # Checks if usage of %() or %Q() matches configuration.
205
+ # Checks if usage of `%()` or `%Q()` matches configuration.
198
206
  Style/BarePercentLiterals:
199
207
  EnforcedStyle: bare_percent
200
208
  SupportedStyles:
@@ -288,14 +296,14 @@ Style/BracesAroundHashParameters:
288
296
 
289
297
  # Indentation of `when`.
290
298
  Style/CaseIndentation:
291
- IndentWhenRelativeTo: case
299
+ EnforcedStyle: case
292
300
  SupportedStyles:
293
301
  - case
294
302
  - end
295
303
  IndentOneStep: false
296
- # By default, the indentation width from Style/IndentationWidth is used
297
- # But it can be overridden by setting this parameter
298
- # This only matters if IndentOneStep is true
304
+ # By default, the indentation width from `Style/IndentationWidth` is used.
305
+ # But it can be overridden by setting this parameter.
306
+ # This only matters if `IndentOneStep` is `true`
299
307
  IndentationWidth: ~
300
308
 
301
309
  Style/ClassAndModuleChildren:
@@ -313,7 +321,7 @@ Style/ClassAndModuleChildren:
313
321
  # class Foo::Bar
314
322
  # end
315
323
  #
316
- # The compact style is only forced, for classes / modules with one child.
324
+ # The compact style is only forced, for classes or modules with one child.
317
325
  EnforcedStyle: nested
318
326
  SupportedStyles:
319
327
  - nested
@@ -340,17 +348,17 @@ Style/CollectionMethods:
340
348
  detect: 'find'
341
349
  find_all: 'select'
342
350
 
343
- # Use ` or %x around command literals.
351
+ # Use '`' or '%x' around command literals.
344
352
  Style/CommandLiteral:
345
353
  EnforcedStyle: backticks
346
354
  # backticks: Always use backticks.
347
- # percent_x: Always use %x.
348
- # mixed: Use backticks on single-line commands, and %x on multi-line commands.
355
+ # percent_x: Always use `%x`.
356
+ # mixed: Use backticks on single-line commands, and `%x` on multi-line commands.
349
357
  SupportedStyles:
350
358
  - backticks
351
359
  - percent_x
352
360
  - mixed
353
- # If false, the cop will always recommend using %x if one or more backticks
361
+ # If `false`, the cop will always recommend using `%x` if one or more backticks
354
362
  # are found in the command string.
355
363
  AllowInnerBackticks: false
356
364
 
@@ -375,14 +383,15 @@ Style/ConditionalAssignment:
375
383
  # will only register an offense for assignment to a condition that has
376
384
  # at least one multiline branch.
377
385
  SingleLineConditionsOnly: true
386
+ IncludeTernaryExpressions: true
378
387
 
379
388
  # Checks that you have put a copyright in a comment before any code.
380
389
  #
381
390
  # You can override the default Notice in your .rubocop.yml file.
382
391
  #
383
392
  # In order to use autocorrect, you must supply a value for the
384
- # AutocorrectNotice key that matches the regexp Notice. A blank
385
- # AutocorrectNotice will cause an error during autocorrect.
393
+ # `AutocorrectNotice` key that matches the regexp Notice. A blank
394
+ # `AutocorrectNotice` will cause an error during autocorrect.
386
395
  #
387
396
  # Autocorrect will add a copyright notice in a comment at the top
388
397
  # of the file immediately after any shebang or encoding comments.
@@ -409,9 +418,9 @@ Style/DotPosition:
409
418
  - trailing
410
419
 
411
420
  # Warn on empty else statements
412
- # empty - warn only on empty else
413
- # nil - warn on else with nil in it
414
- # both - warn on empty else and else with nil in it
421
+ # empty - warn only on empty `else`
422
+ # nil - warn on `else` with nil in it
423
+ # both - warn on empty `else` and `else` with nil in it
415
424
  Style/EmptyElse:
416
425
  EnforcedStyle: both
417
426
  SupportedStyles:
@@ -421,7 +430,7 @@ Style/EmptyElse:
421
430
 
422
431
  # Use empty lines between defs.
423
432
  Style/EmptyLineBetweenDefs:
424
- # If true, this parameter means that single line method definitions don't
433
+ # If `true`, this parameter means that single line method definitions don't
425
434
  # need an empty line between them.
426
435
  AllowAdjacentOneLineDefs: false
427
436
 
@@ -469,19 +478,19 @@ Style/ExtraSpacing:
469
478
  # things with the previous or next line, not counting empty lines or comment
470
479
  # lines.
471
480
  AllowForAlignment: true
472
- # When true, forces the alignment of = in assignments on consecutive lines.
481
+ # When true, forces the alignment of `=` in assignments on consecutive lines.
473
482
  ForceEqualSignAlignment: false
474
483
 
475
484
  Style/FileName:
476
- # File names listed in AllCops:Include are excluded by default. Add extra
485
+ # File names listed in `AllCops:Include` are excluded by default. Add extra
477
486
  # excludes here.
478
487
  Exclude: []
479
- # When true, requires that each source file should define a class or module
488
+ # When `true`, requires that each source file should define a class or module
480
489
  # with a name which matches the file name (converted to ... case).
481
490
  # It further expects it to be nested inside modules which match the names
482
491
  # of subdirectories in its path.
483
492
  ExpectMatchingDefinition: false
484
- # If non-nil, expect all source file names to match the following regex.
493
+ # If non-`nil`, expect all source file names to match the following regex.
485
494
  # Only the file name itself is matched, not the entire file path.
486
495
  # Use anchors as necessary if you want to match the entire name rather than
487
496
  # just a part of it.
@@ -490,6 +499,47 @@ Style/FileName:
490
499
  # report offending filenames for executable scripts (i.e. source
491
500
  # files with a shebang in the first line).
492
501
  IgnoreExecutableScripts: true
502
+ AllowedAcronyms:
503
+ - CLI
504
+ - DSL
505
+ - ACL
506
+ - API
507
+ - ASCII
508
+ - CPU
509
+ - CSS
510
+ - DNS
511
+ - EOF
512
+ - GUID
513
+ - HTML
514
+ - HTTP
515
+ - HTTPS
516
+ - ID
517
+ - IP
518
+ - JSON
519
+ - LHS
520
+ - QPS
521
+ - RAM
522
+ - RHS
523
+ - RPC
524
+ - SLA
525
+ - SMTP
526
+ - SQL
527
+ - SSH
528
+ - TCP
529
+ - TLS
530
+ - TTL
531
+ - UDP
532
+ - UI
533
+ - UID
534
+ - UUID
535
+ - URI
536
+ - URL
537
+ - UTF8
538
+ - VM
539
+ - XML
540
+ - XMPP
541
+ - XSRF
542
+ - XSS
493
543
 
494
544
  Style/FirstParameterIndentation:
495
545
  EnforcedStyle: special_for_inner_method_call_in_parentheses
@@ -502,10 +552,10 @@ Style/FirstParameterIndentation:
502
552
  # a parameter in a method call, then the inner parameter should be indented
503
553
  # relative to the inner method.
504
554
  - special_for_inner_method_call
505
- # Same as special_for_inner_method_call except that the special rule only
555
+ # Same as `special_for_inner_method_call` except that the special rule only
506
556
  # applies if the outer method call encloses its arguments in parentheses.
507
557
  - special_for_inner_method_call_in_parentheses
508
- # By default, the indentation width from Style/IndentationWidth is used
558
+ # By default, the indentation width from `Style/IndentationWidth` is used
509
559
  # But it can be overridden by setting this parameter
510
560
  IndentationWidth: ~
511
561
 
@@ -535,12 +585,15 @@ Style/FrozenStringLiteralComment:
535
585
  # string literal. If you run code against multiple versions of Ruby, it is
536
586
  # possible that this will create errors in Ruby 2.3.0+.
537
587
  - always
588
+ # `never` will enforce that the frozen string literal comment does not
589
+ # exist in a file.
590
+ - never
538
591
 
539
592
  # Built-in global variables are allowed by default.
540
593
  Style/GlobalVars:
541
594
  AllowedVariables: []
542
595
 
543
- # `MinBodyLength` defines the number of lines of the a body of an if / unless
596
+ # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
544
597
  # needs to have to trigger this cop
545
598
  Style/GuardClause:
546
599
  MinBodyLength: 1
@@ -598,13 +651,13 @@ Style/IndentArray:
598
651
  - special_inside_parentheses
599
652
  - consistent
600
653
  - align_brackets
601
- # By default, the indentation width from Style/IndentationWidth is used
654
+ # By default, the indentation width from `Style/IndentationWidth` is used
602
655
  # But it can be overridden by setting this parameter
603
656
  IndentationWidth: ~
604
657
 
605
658
  # Checks the indentation of assignment RHS, when on a different line from LHS
606
659
  Style/IndentAssignment:
607
- # By default, the indentation width from Style/IndentationWidth is used
660
+ # By default, the indentation width from `Style/IndentationWidth` is used
608
661
  # But it can be overridden by setting this parameter
609
662
  IndentationWidth: ~
610
663
 
@@ -626,7 +679,7 @@ Style/IndentHash:
626
679
  - special_inside_parentheses
627
680
  - consistent
628
681
  - align_braces
629
- # By default, the indentation width from Style/IndentationWidth is used
682
+ # By default, the indentation width from `Style/IndentationWidth` is used
630
683
  # But it can be overridden by setting this parameter
631
684
  IndentationWidth: ~
632
685
 
@@ -654,7 +707,7 @@ Style/Next:
654
707
  # replaced by next - with `skip_modifier_ifs` the modifier if like this one
655
708
  # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
656
709
  EnforcedStyle: skip_modifier_ifs
657
- # `MinBodyLength` defines the number of lines of the a body of an if / unless
710
+ # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
658
711
  # needs to have to trigger this cop
659
712
  MinBodyLength: 3
660
713
  SupportedStyles:
@@ -687,6 +740,9 @@ Style/MethodDefParentheses:
687
740
  - require_no_parentheses
688
741
  - require_no_parentheses_except_multiline
689
742
 
743
+ Style/MethodCallWithArgsParentheses:
744
+ IgnoredMethods: []
745
+
690
746
  Style/MethodName:
691
747
  EnforcedStyle: snake_case
692
748
  SupportedStyles:
@@ -772,7 +828,7 @@ Style/MultilineOperationIndentation:
772
828
  SupportedStyles:
773
829
  - aligned
774
830
  - indented
775
- # By default, the indentation width from Style/IndentationWidth is used
831
+ # By default, the indentation width from `Style/IndentationWidth` is used
776
832
  # But it can be overridden by setting this parameter
777
833
  IndentationWidth: ~
778
834
 
@@ -814,8 +870,8 @@ Style/PercentLiteralDelimiters:
814
870
  Style/PercentQLiterals:
815
871
  EnforcedStyle: lower_case_q
816
872
  SupportedStyles:
817
- - lower_case_q # Use %q when possible, %Q when necessary
818
- - upper_case_q # Always use %Q
873
+ - lower_case_q # Use `%q` when possible, `%Q` when necessary
874
+ - upper_case_q # Always use `%Q`
819
875
 
820
876
  Style/PredicateName:
821
877
  # Predicate name prefixes.
@@ -828,7 +884,7 @@ Style/PredicateName:
828
884
  - is_
829
885
  - has_
830
886
  - have_
831
- # Predicate names which, despite having a blacklisted prefix, or no ?,
887
+ # Predicate names which, despite having a blacklisted prefix, or no `?`,
832
888
  # should still be accepted
833
889
  NameWhitelist:
834
890
  - is_a?
@@ -850,20 +906,20 @@ Style/RaiseArgs:
850
906
  - exploded # raise Exception, msg
851
907
 
852
908
  Style/RedundantReturn:
853
- # When true allows code like `return x, y`.
909
+ # When `true` allows code like `return x, y`.
854
910
  AllowMultipleReturnValues: false
855
911
 
856
- # Use / or %r around regular expressions.
912
+ # Use `/` or `%r` around regular expressions.
857
913
  Style/RegexpLiteral:
858
914
  EnforcedStyle: slashes
859
915
  # slashes: Always use slashes.
860
- # percent_r: Always use %r.
861
- # mixed: Use slashes on single-line regexes, and %r on multi-line regexes.
916
+ # percent_r: Always use `%r`.
917
+ # mixed: Use slashes on single-line regexes, and `%r` on multi-line regexes.
862
918
  SupportedStyles:
863
919
  - slashes
864
920
  - percent_r
865
921
  - mixed
866
- # If false, the cop will always recommend using %r if one or more slashes
922
+ # If `false`, the cop will always recommend using `%r` if one or more slashes
867
923
  # are found in the regexp string.
868
924
  AllowInnerSlashes: false
869
925
 
@@ -873,7 +929,7 @@ Style/SafeNavigation:
873
929
  ConvertCodeThatCanStartToReturnNil: false
874
930
 
875
931
  Style/Semicolon:
876
- # Allow ; to separate several expressions on the same line.
932
+ # Allow `;` to separate several expressions on the same line.
877
933
  AllowAsExpressionSeparator: false
878
934
 
879
935
  Style/SignalException:
@@ -896,7 +952,7 @@ Style/SingleLineMethods:
896
952
  AllowIfMethodIsEmpty: true
897
953
 
898
954
  Style/SpaceBeforeFirstArg:
899
- # When true, allows most uses of extra spacing if the intent is to align
955
+ # When `true`, allows most uses of extra spacing if the intent is to align
900
956
  # things with the previous or next line, not counting empty lines or comment
901
957
  # lines.
902
958
  AllowForAlignment: true
@@ -918,7 +974,7 @@ Style/StringLiterals:
918
974
  SupportedStyles:
919
975
  - single_quotes
920
976
  - double_quotes
921
- # If true, strings which span multiple lines using \ for continuation must
977
+ # If `true`, strings which span multiple lines using `\` for continuation must
922
978
  # use the same type of quotes on each line.
923
979
  ConsistentQuotesInMultiline: false
924
980
 
@@ -940,7 +996,7 @@ Style/StringMethods:
940
996
 
941
997
  Style/SpaceAroundBlockParameters:
942
998
  EnforcedStyleInsidePipes: no_space
943
- SupportedStyles:
999
+ SupportedStylesInsidePipes:
944
1000
  - space
945
1001
  - no_space
946
1002
 
@@ -951,7 +1007,7 @@ Style/SpaceAroundEqualsInParameterDefault:
951
1007
  - no_space
952
1008
 
953
1009
  Style/SpaceAroundOperators:
954
- # When true, allows most uses of extra spacing if the intent is to align
1010
+ # When `true`, allows most uses of extra spacing if the intent is to align
955
1011
  # with an operator on the previous or next line, not counting empty lines
956
1012
  # or comment lines.
957
1013
  AllowForAlignment: true
@@ -967,20 +1023,25 @@ Style/SpaceInsideBlockBraces:
967
1023
  SupportedStyles:
968
1024
  - space
969
1025
  - no_space
970
- # Valid values are: space, no_space
971
1026
  EnforcedStyleForEmptyBraces: no_space
1027
+ SupportedStylesForEmptyBraces:
1028
+ - space
1029
+ - no_space
972
1030
  # Space between { and |. Overrides EnforcedStyle if there is a conflict.
973
1031
  SpaceBeforeBlockParameters: true
974
1032
 
975
1033
  Style/SpaceInsideHashLiteralBraces:
976
1034
  EnforcedStyle: space
977
- EnforcedStyleForEmptyBraces: no_space
978
1035
  SupportedStyles:
979
1036
  - space
980
1037
  - no_space
981
1038
  # 'compact' normally requires a space inside hash braces, with the exception
982
1039
  # that successive left braces or right braces are collapsed together
983
1040
  - compact
1041
+ EnforcedStyleForEmptyBraces: no_space
1042
+ SupportedStylesForEmptyBraces:
1043
+ - space
1044
+ - no_space
984
1045
 
985
1046
  Style/SpaceInsideStringInterpolation:
986
1047
  EnforcedStyle: no_space
@@ -1021,7 +1082,7 @@ Style/TrailingCommaInArguments:
1021
1082
  # If `consistent_comma`, the cop requires a comma after the last argument,
1022
1083
  # for all parenthesized method calls with arguments.
1023
1084
  EnforcedStyleForMultiline: no_comma
1024
- SupportedStyles:
1085
+ SupportedStylesForMultiline:
1025
1086
  - comma
1026
1087
  - consistent_comma
1027
1088
  - no_comma
@@ -1032,7 +1093,7 @@ Style/TrailingCommaInLiteral:
1032
1093
  # If `consistent_comma`, the cop requires a comma after the last item of all
1033
1094
  # non-empty array and hash literals.
1034
1095
  EnforcedStyleForMultiline: no_comma
1035
- SupportedStyles:
1096
+ SupportedStylesForMultiline:
1036
1097
  - comma
1037
1098
  - consistent_comma
1038
1099
  - no_comma
@@ -1040,7 +1101,7 @@ Style/TrailingCommaInLiteral:
1040
1101
  # TrivialAccessors requires exact name matches and doesn't allow
1041
1102
  # predicated methods by default.
1042
1103
  Style/TrivialAccessors:
1043
- # When set to false the cop will suggest the use of accessor methods
1104
+ # When set to `false` the cop will suggest the use of accessor methods
1044
1105
  # in situations like:
1045
1106
  #
1046
1107
  # def name
@@ -1095,7 +1156,7 @@ Style/VariableNumber:
1095
1156
  Style/WhileUntilModifier:
1096
1157
  MaxLineLength: 80
1097
1158
 
1098
- # WordArray enforces how array literals of word-like strings should be expressed.
1159
+ # `WordArray` enforces how array literals of word-like strings should be expressed.
1099
1160
  Style/WordArray:
1100
1161
  EnforcedStyle: percent
1101
1162
  SupportedStyles:
@@ -1103,11 +1164,11 @@ Style/WordArray:
1103
1164
  - percent
1104
1165
  # bracket style: ['word1', 'word2']
1105
1166
  - brackets
1106
- # The MinSize option causes the WordArray rule to be ignored for arrays
1167
+ # The `MinSize` option causes the `WordArray` rule to be ignored for arrays
1107
1168
  # smaller than a certain size. The rule is only applied to arrays
1108
- # whose element count is greater than or equal to MinSize.
1169
+ # whose element count is greater than or equal to `MinSize`.
1109
1170
  MinSize: 0
1110
- # The regular expression WordRegex decides what is considered a word.
1171
+ # The regular expression `WordRegex` decides what is considered a word.
1111
1172
  WordRegex: !ruby/regexp '/\A[\p{Word}\n\t]+\z/'
1112
1173
 
1113
1174
  ##################### Metrics ##################################
@@ -1118,6 +1179,7 @@ Metrics/AbcSize:
1118
1179
  Max: 15
1119
1180
 
1120
1181
  Metrics/BlockNesting:
1182
+ CountBlocks: false
1121
1183
  Max: 3
1122
1184
 
1123
1185
  Metrics/ClassLength:
@@ -1156,10 +1218,7 @@ Metrics/MethodLength:
1156
1218
  Metrics/BlockLength:
1157
1219
  CountComments: false # count full line comments?
1158
1220
  Max: 25
1159
- Exclude:
1160
- - 'Rakefile'
1161
- - '**/*.rake'
1162
- - 'spec/**/*.rb'
1221
+ ExcludedMethods: []
1163
1222
 
1164
1223
  Metrics/ParameterLists:
1165
1224
  Max: 5
@@ -1181,8 +1240,8 @@ Lint/BlockAlignment:
1181
1240
  # The value `start_of_line` means it should be aligned with the whole
1182
1241
  # expression's starting line.
1183
1242
  # The value `either` means both are allowed.
1184
- AlignWith: either
1185
- SupportedStyles:
1243
+ EnforcedStyleAlignWith: either
1244
+ SupportedStylesAlignWith:
1186
1245
  - either
1187
1246
  - start_of_block
1188
1247
  - start_of_line
@@ -1190,14 +1249,14 @@ Lint/BlockAlignment:
1190
1249
  # Align ends correctly.
1191
1250
  Lint/EndAlignment:
1192
1251
  # The value `keyword` means that `end` should be aligned with the matching
1193
- # keyword (if, while, etc.).
1252
+ # keyword (`if`, `while`, etc.).
1194
1253
  # The value `variable` means that in assignments, `end` should be aligned
1195
1254
  # with the start of the variable on the left hand side of `=`. In all other
1196
1255
  # situations, `end` should still be aligned with the keyword.
1197
1256
  # The value `start_of_line` means that `end` should be aligned with the start
1198
1257
  # of the line which the matching keyword appears on.
1199
- AlignWith: keyword
1200
- SupportedStyles:
1258
+ EnforcedStyleAlignWith: keyword
1259
+ SupportedStylesAlignWith:
1201
1260
  - keyword
1202
1261
  - variable
1203
1262
  - start_of_line
@@ -1208,8 +1267,8 @@ Lint/DefEndAlignment:
1208
1267
  # The value `start_of_line` means that `end` should be aligned with method
1209
1268
  # calls like `private`, `public`, etc, if present in front of the `def`
1210
1269
  # keyword on the same line.
1211
- AlignWith: start_of_line
1212
- SupportedStyles:
1270
+ EnforcedStyleAlignWith: start_of_line
1271
+ SupportedStylesAlignWith:
1213
1272
  - start_of_line
1214
1273
  - def
1215
1274
  AutoCorrect: false
@@ -1307,6 +1366,10 @@ Rails/RequestReferer:
1307
1366
  - referer
1308
1367
  - referrer
1309
1368
 
1369
+ Rails/ReversibleMigration:
1370
+ Include:
1371
+ - db/migrate/*.rb
1372
+
1310
1373
  Rails/SafeNavigation:
1311
1374
  # This will convert usages of `try` to use safe navigation as well as `try!`.
1312
1375
  # `try` and `try!` work slighly differently. `try!` and safe navigation will
@@ -1327,12 +1390,26 @@ Rails/TimeZone:
1327
1390
  - flexible
1328
1391
 
1329
1392
  Rails/UniqBeforePluck:
1330
- EnforcedMode: conservative
1331
- SupportedModes:
1393
+ EnforcedStyle: conservative
1394
+ SupportedStyles:
1332
1395
  - conservative
1333
1396
  - aggressive
1334
1397
  AutoCorrect: false
1335
1398
 
1399
+ Rails/SkipsModelValidations:
1400
+ Blacklist:
1401
+ - decrement!
1402
+ - decrement_counter
1403
+ - increment!
1404
+ - increment_counter
1405
+ - toggle!
1406
+ - touch
1407
+ - update_all
1408
+ - update_attribute
1409
+ - update_column
1410
+ - update_columns
1411
+ - update_counters
1412
+
1336
1413
  Rails/Validation:
1337
1414
  Include:
1338
1415
  - app/models/**/*.rb
data/cookstyle.gemspec CHANGED
@@ -12,14 +12,14 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{Rubocop configuration for Chef cookbooks}
13
13
  spec.homepage = "https://github.com/chef/cookstyle"
14
14
  spec.license = "Apache-2.0"
15
- spec.required_ruby_version = ">= 2.0.0"
15
+ spec.required_ruby_version = ">= 2.1"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
18
  spec.executables = %w[cookstyle]
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.10"
22
- spec.add_development_dependency "rake", "~> 11.0"
22
+ spec.add_development_dependency "rake", "~> 12.0"
23
23
  spec.add_development_dependency "rspec"
24
24
  spec.add_dependency("rubocop", Cookstyle::RUBOCOP_VERSION)
25
25
  end
@@ -1,4 +1,4 @@
1
1
  module Cookstyle
2
- VERSION = "1.2.0".freeze
3
- RUBOCOP_VERSION = "0.46.0".freeze
2
+ VERSION = "1.3.0".freeze
3
+ RUBOCOP_VERSION = "0.47.1".freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookstyle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-19 00:00:00.000000000 Z
11
+ date: 2017-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '11.0'
33
+ version: '12.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '11.0'
40
+ version: '12.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.46.0
61
+ version: 0.47.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.46.0
68
+ version: 0.47.1
69
69
  description:
70
70
  email:
71
71
  - thom@chef.io
@@ -105,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
- version: 2.0.0
108
+ version: '2.1'
109
109
  required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
111
  - - ">="