cookstyle 0.0.1 → 1.0.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: 0d68e913afdc2adcf81d98ed36954f87171d8dd3
4
- data.tar.gz: db9c077caec8243cce4db32259ff0eaac1532fe2
3
+ metadata.gz: 252eecc60f7e535245ffbba0cff391f8f7bf8f35
4
+ data.tar.gz: c13360ce493a065f60914070f60e0b08803dc36c
5
5
  SHA512:
6
- metadata.gz: 9f96d13059329d2c744198ac738c181c1543eb4f2e6f35e6442440452639313d7b6878abe54a587060088a85ff02a8111537f50fa84798ceff2ce30bd0fc27bf
7
- data.tar.gz: 9e151506eb24ae9689f1a13aec5be62949764a393fa4f39e175cb355bf9e6ab3f9a5a1ee13cc29636045a7b312e1d72b6de0fc26adb83613b3ee72e086ccc3df
6
+ metadata.gz: f5743882a78a21c9c956b04aaa71bd2b01be4fba89a924220834be7839b15af0acb0d81ede63e6e96bf919acca6bdfb89f500a19dff1229fcb2843a2be8311e6
7
+ data.tar.gz: acb1272ba9a18dff31f05c28ad0423d4c15f105bb2a44d68f3374e75f79aed3775b1597ceb5eb80c3aef64f6b06216838d6bf07a9d75d8f57c7a1c0ca44df7ed
@@ -1,4 +1,11 @@
1
1
  language: ruby
2
+ cache: bundler
3
+
4
+ sudo: false
5
+
6
+ branches:
7
+ only:
8
+ - master
2
9
  rvm:
3
- - 2.2.1
4
- before_install: gem install bundler -v 1.10.6
10
+ - 2.2.5
11
+ - 2.3.1
data/README.md CHANGED
@@ -1,21 +1,31 @@
1
1
  # Cookstyle - Version Pinned rubocop and sane defaults for Chef Cookbooks
2
2
 
3
- Pull requests to this repo will not be accepted without corresponding
4
- PRs into at least the chef-client and ohai codebases to clean the
5
- code up. PRs will not be accepted that assume unfunded mandates for
6
- other people to finish the work. Do not open PRs offering opinions
7
- or suggestions without offering to do the work.
8
-
9
- The project itself is a derivative of
10
- [finstyle](https://github.com/fnichol/finstyle), but starts with all
11
- rules disabled. The active ruleset is in the
12
- [config/cookstyle.yml](https://github.com/chef/cookstyle/blob/master/config/cookstyle.yml)
13
- file.
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
+
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.
6
+
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.
14
8
 
15
9
  ## How It Works
16
10
 
17
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.
18
12
 
13
+ ## NOTE CAREFULLY ABOUT UPDATING COOKSTYLE
14
+
15
+ This is designed to allow bumping the rubocop engine while keeping backwards compatibility with the config and not requiring all the cookbooks to update.
16
+
17
+ The [cookstyle_base.yml](https://github.com/chef/cookstyle/blob/master/config/cookstyle_base.yml) file is (essentially) the enabled.yml file from 0.37.2 (as of this writing) which is applied on top of 0.46.0 with all the rules disabled. It pins the default enabled set to 0.37.2 compatibility while running under the 0.46.0 engine.
18
+
19
+ There is no rake task for updating the `cookstyle_base.yml` file. It was generated by hand -- the Description and other fields need to be dropped out of it.
20
+
21
+ It may be necessary to edit that file (again by hand) to resolve issues with later rubocop engines changing cop names (renaming, splitting up, etc).
22
+
23
+ Occasionally the `cookstyle_base.yml` file should be updated, which will generate a lot of work to fix every cookbook that cookstyle runs against.
24
+
25
+ When updating to a new engine the `rake vendor` task should still always be run in order to update the base set of cops and generate the default disabled.yml ruleset.
26
+
27
+ When editing the `cookstyle_base.yml` becomes too much of a PITA, it may be time to bump the engine, run `rake vendor` and then drop the new `enabled.yml` into `cookstyle_base.yml`, fix it up, and ship it and then deal with the fallout of all the new cops...
28
+
19
29
  ## Installation
20
30
 
21
31
  Add this line to your application's Gemfile:
@@ -26,11 +36,15 @@ gem 'cookstyle'
26
36
 
27
37
  And then execute:
28
38
 
29
- $ bundle
39
+ ```
40
+ $ bundle
41
+ ```
30
42
 
31
43
  Or install it yourself as:
32
44
 
33
- $ gem install cookstyle
45
+ ```
46
+ $ gem install cookstyle
47
+ ```
34
48
 
35
49
  ## Usage
36
50
 
@@ -44,8 +58,7 @@ rubocop -r cookstyle -D --format offenses
44
58
 
45
59
  ### cookstyle Command
46
60
 
47
- Use this tool just as you would RuboCop, but invoke the `cookstyle` binary
48
- instead which patches RuboCop to load rules from the cookstyle gem. For example:
61
+ Use this tool just as you would RuboCop, but invoke the `cookstyle` binary instead which patches RuboCop to load rules from the cookstyle gem. For example:
49
62
 
50
63
  ```sh
51
64
  cookstyle -D --format offenses
@@ -53,8 +66,7 @@ cookstyle -D --format offenses
53
66
 
54
67
  ### Rake
55
68
 
56
- In a Rakefile, the setup is exactly the same, except you need to require the
57
- cookstyle library first:
69
+ In a Rakefile, the setup is exactly the same, except you need to require the cookstyle library first:
58
70
 
59
71
  ```ruby
60
72
  require "cookstyle"
data/Rakefile CHANGED
@@ -26,3 +26,5 @@ require "rubocop/rake_task"
26
26
  RuboCop::RakeTask.new(:style) do |task|
27
27
  task.options << "--display-cop-names"
28
28
  end
29
+
30
+ task default: [:build, :install]
@@ -5,10 +5,6 @@ AllCops:
5
5
 
6
6
  AlignParameters:
7
7
  Enabled: false
8
- ClassLength:
9
- Enabled: false
10
- CyclomaticComplexity:
11
- Enabled: false
12
8
  Documentation:
13
9
  Enabled: false
14
10
  Encoding:
@@ -27,7 +23,87 @@ Metrics/AbcSize:
27
23
  Enabled: false
28
24
  Metrics/ModuleLength:
29
25
  Enabled: false
26
+ Metrics/CyclomaticComplexity:
27
+ Enabled: false
30
28
  PerceivedComplexity:
31
29
  Enabled: false
32
30
  Style/ClassAndModuleChildren:
33
31
  Enabled: false
32
+
33
+ # https://github.com/chef/cookstyle/pull/5
34
+ Style/TrailingCommaInLiteral:
35
+ Enabled: true
36
+ EnforcedStyleForMultiline: comma
37
+
38
+ # Underscores in numbers are unnecessary, especially for port numbers where they are unexpected
39
+ Style/NumericLiterals:
40
+ Enabled: false
41
+
42
+ # regex rules often trigger no matter what you do with inspec/serverspec matchers
43
+ Style/RegexpLiteral:
44
+ Exclude:
45
+ - 'test/**/*'
46
+
47
+ # some names are not ascii and this prevents copyright comments
48
+ Style/AsciiComments:
49
+ Enabled: false
50
+
51
+ # avoid case statements where the 2nd 'when' would never fire
52
+ Lint/DuplicateCaseCondition:
53
+ Enabled: true
54
+
55
+ # empty expressions serve no purpose
56
+ Lint/EmptyExpression:
57
+ Enabled: true
58
+
59
+ # when in a case statement should always do something
60
+ Lint/EmptyWhen:
61
+ Enabled: true
62
+
63
+ # %w('something') is almost always a typo
64
+ Lint/PercentStringArray:
65
+ Enabled: true
66
+
67
+ # %w(:something) should be a string not a symbol
68
+ Lint/PercentSymbolArray:
69
+ Enabled: true
70
+
71
+ # if you rescue Exception, then rescue say StandardError you're gonna have a bad time
72
+ Lint/ShadowedException:
73
+ Enabled: false
74
+
75
+ # We're on modern ruby so let's assume Integer everywhere
76
+ Lint/UnifiedInteger:
77
+ Enabled: true
78
+
79
+ # consistent hash key/value checks
80
+ Style/PreferredHashMethods:
81
+ Enabled: true
82
+
83
+ # when iterating a fixed number of times this is much easier to read
84
+ Style/EachForSimpleLoop:
85
+ Enabled: true
86
+
87
+ # a case statement without a condition is just an if statement
88
+ Style/EmptyCaseCondition:
89
+ Enabled: true
90
+
91
+ # helpers are easiest to read
92
+ Style/NumericPredicate:
93
+ Enabled: true
94
+
95
+ # this is bad %w(something another_thing one_more)
96
+ Style/SpaceInsideArrayPercentLiteral:
97
+ Enabled: true
98
+
99
+ # ( true ) ? 'bob' : 'bill' is unnecessary
100
+ Style/TernaryParentheses:
101
+ Enabled: true
102
+
103
+ # disable this until there's an autocorrect
104
+ Bundler/OrderedGems:
105
+ Enabled: false
106
+
107
+ # There's no reason to have a gem listed twice
108
+ Bundler/DuplicatedGem:
109
+ Enabled: true
@@ -17,6 +17,8 @@ Lint/DefEndAlignment:
17
17
  Enabled: false
18
18
  Lint/DeprecatedClassMethods:
19
19
  Enabled: false
20
+ Lint/DuplicateCaseCondition:
21
+ Enabled: false
20
22
  Lint/DuplicateMethods:
21
23
  Enabled: false
22
24
  Lint/DuplicatedKey:
@@ -27,8 +29,12 @@ Lint/ElseLayout:
27
29
  Enabled: false
28
30
  Lint/EmptyEnsure:
29
31
  Enabled: false
32
+ Lint/EmptyExpression:
33
+ Enabled: false
30
34
  Lint/EmptyInterpolation:
31
35
  Enabled: false
36
+ Lint/EmptyWhen:
37
+ Enabled: false
32
38
  Lint/EndAlignment:
33
39
  Enabled: false
34
40
  Lint/EndInMethod:
@@ -45,6 +51,8 @@ Lint/HandleExceptions:
45
51
  Enabled: false
46
52
  Lint/ImplicitStringConcatenation:
47
53
  Enabled: false
54
+ Lint/InheritException:
55
+ Enabled: false
48
56
  Lint/IneffectiveAccessModifier:
49
57
  Enabled: false
50
58
  Lint/InvalidCharacterLiteral:
@@ -63,20 +71,30 @@ Lint/NonLocalExitFromIterator:
63
71
  Enabled: false
64
72
  Lint/ParenthesesAsGroupedExpression:
65
73
  Enabled: false
74
+ Lint/PercentStringArray:
75
+ Enabled: false
76
+ Lint/PercentSymbolArray:
77
+ Enabled: false
66
78
  Lint/RandOne:
67
79
  Enabled: false
68
80
  Lint/RequireParentheses:
69
81
  Enabled: false
70
82
  Lint/RescueException:
71
83
  Enabled: false
84
+ Lint/ShadowedException:
85
+ Enabled: false
72
86
  Lint/ShadowingOuterLocalVariable:
73
87
  Enabled: false
74
88
  Lint/StringConversionInInterpolation:
75
89
  Enabled: false
76
90
  Lint/UnderscorePrefixedVariableName:
77
91
  Enabled: false
92
+ Lint/UnifiedInteger:
93
+ Enabled: false
78
94
  Lint/UnneededDisable:
79
95
  Enabled: false
96
+ Lint/UnneededSplatExpansion:
97
+ Enabled: false
80
98
  Lint/UnreachableCode:
81
99
  Enabled: false
82
100
  Lint/UnusedBlockArgument:
@@ -99,6 +117,8 @@ Metrics/CyclomaticComplexity:
99
117
  Enabled: false
100
118
  Metrics/AbcSize:
101
119
  Enabled: false
120
+ Metrics/BlockLength:
121
+ Enabled: false
102
122
  Metrics/BlockNesting:
103
123
  Enabled: false
104
124
  Metrics/ClassLength:
@@ -149,6 +169,8 @@ Performance/Sample:
149
169
  Enabled: false
150
170
  Performance/Size:
151
171
  Enabled: false
172
+ Performance/SortWithBlock:
173
+ Enabled: false
152
174
  Performance/StartWith:
153
175
  Enabled: false
154
176
  Performance/StringReplacement:
@@ -227,7 +249,9 @@ Style/Copyright:
227
249
  Enabled: false
228
250
  Style/DefWithParentheses:
229
251
  Enabled: false
230
- Style/DeprecatedHashMethods:
252
+ Style/PreferredHashMethods:
253
+ Enabled: false
254
+ Style/DocumentationMethod:
231
255
  Enabled: false
232
256
  Style/Documentation:
233
257
  Enabled: false
@@ -235,10 +259,14 @@ Style/DotPosition:
235
259
  Enabled: false
236
260
  Style/DoubleNegation:
237
261
  Enabled: false
262
+ Style/EachForSimpleLoop:
263
+ Enabled: false
238
264
  Style/EachWithObject:
239
265
  Enabled: false
240
266
  Style/ElseAlignment:
241
267
  Enabled: false
268
+ Style/EmptyCaseCondition:
269
+ Enabled: false
242
270
  Style/EmptyElse:
243
271
  Enabled: false
244
272
  Style/EmptyLineBetweenDefs:
@@ -303,6 +331,8 @@ Style/IfUnlessModifierOfIfUnless:
303
331
  Enabled: false
304
332
  Style/IfWithSemicolon:
305
333
  Enabled: false
334
+ Style/ImplicitRuntimeError:
335
+ Enabled: false
306
336
  Style/IndentArray:
307
337
  Enabled: false
308
338
  Style/IndentAssignment:
@@ -335,6 +365,8 @@ Style/MethodDefParentheses:
335
365
  Enabled: false
336
366
  Style/MethodName:
337
367
  Enabled: false
368
+ Style/MethodMissing:
369
+ Enabled: false
338
370
  Style/MissingElse:
339
371
  Enabled: false
340
372
  Style/ModuleFunction:
@@ -351,6 +383,10 @@ Style/MultilineHashBraceLayout:
351
383
  Enabled: false
352
384
  Style/MultilineIfThen:
353
385
  Enabled: false
386
+ Style/MultilineIfModifier:
387
+ Enabled: false
388
+ Style/MultilineMemoization:
389
+ Enabled: false
354
390
  Style/MultilineMethodCallBraceLayout:
355
391
  Enabled: false
356
392
  Style/MultilineMethodCallIndentation:
@@ -383,6 +419,10 @@ Style/Not:
383
419
  Enabled: false
384
420
  Style/NumericLiterals:
385
421
  Enabled: false
422
+ Style/NumericLiteralPrefix:
423
+ Enabled: false
424
+ Style/NumericPredicate:
425
+ Enabled: false
386
426
  Style/OneLineConditional:
387
427
  Enabled: false
388
428
  Style/OpMethod:
@@ -425,6 +465,8 @@ Style/RescueEnsureAlignment:
425
465
  Enabled: false
426
466
  Style/RescueModifier:
427
467
  Enabled: false
468
+ Style/SafeNavigation:
469
+ Enabled: false
428
470
  Style/SelfAssignment:
429
471
  Enabled: false
430
472
  Style/Semicolon:
@@ -465,6 +507,10 @@ Style/SpaceBeforeFirstArg:
465
507
  Enabled: false
466
508
  Style/SpaceBeforeSemicolon:
467
509
  Enabled: false
510
+ Style/SpaceInLambdaLiteral:
511
+ Enabled: false
512
+ Style/SpaceInsideArrayPercentLiteral:
513
+ Enabled: false
468
514
  Style/SpaceInsideBlockBraces:
469
515
  Enabled: false
470
516
  Style/SpaceInsideBrackets:
@@ -473,6 +519,8 @@ Style/SpaceInsideHashLiteralBraces:
473
519
  Enabled: false
474
520
  Style/SpaceInsideParens:
475
521
  Enabled: false
522
+ Style/SpaceInsidePercentLiteralDelimiters:
523
+ Enabled: false
476
524
  Style/SpaceInsideRangeLiteral:
477
525
  Enabled: false
478
526
  Style/SpaceInsideStringInterpolation:
@@ -497,6 +545,8 @@ Style/SymbolProc:
497
545
  Enabled: false
498
546
  Style/Tab:
499
547
  Enabled: false
548
+ Style/TernaryParentheses:
549
+ Enabled: false
500
550
  Style/TrailingBlankLines:
501
551
  Enabled: false
502
552
  Style/TrailingCommaInArguments:
@@ -521,6 +571,8 @@ Style/VariableInterpolation:
521
571
  Enabled: false
522
572
  Style/VariableName:
523
573
  Enabled: false
574
+ Style/VariableNumber:
575
+ Enabled: false
524
576
  Style/WhenThen:
525
577
  Enabled: false
526
578
  Style/WhileUntilDo:
@@ -535,23 +587,45 @@ Rails/ActionFilter:
535
587
  Enabled: false
536
588
  Rails/Date:
537
589
  Enabled: false
590
+ Rails/DynamicFindBy:
591
+ Enabled: false
538
592
  Rails/Delegate:
539
593
  Enabled: false
594
+ Rails/DelegateAllowBlank:
595
+ Enabled: false
596
+ Rails/Exit:
597
+ Enabled: false
540
598
  Rails/FindBy:
541
599
  Enabled: false
542
600
  Rails/FindEach:
543
601
  Enabled: false
544
602
  Rails/HasAndBelongsToMany:
545
603
  Enabled: false
604
+ Rails/HttpPositionalArguments:
605
+ Enabled: false
606
+ Rails/NotNullColumn:
607
+ Enabled: false
608
+ Rails/OutputSafety:
609
+ Enabled: false
546
610
  Rails/Output:
547
611
  Enabled: false
548
612
  Rails/PluralizationGrammar:
549
613
  Enabled: false
550
614
  Rails/ReadWriteAttribute:
551
615
  Enabled: false
616
+ Rails/RequestReferer:
617
+ Enabled: false
618
+ Rails/SafeNavigation:
619
+ Enabled: false
620
+ Rails/SaveBang:
621
+ Enabled: false
552
622
  Rails/ScopeArgs:
553
623
  Enabled: false
554
624
  Rails/TimeZone:
555
625
  Enabled: false
626
+ Rails/UniqBeforePluck:
627
+ Enabled: false
556
628
  Rails/Validation:
557
629
  Enabled: false
630
+ Security/JSONLoad:
631
+ Enabled: false
@@ -5,22 +5,34 @@
5
5
  Rails:
6
6
  Enabled: false
7
7
 
8
+ Rails/SaveBang:
9
+ Description: 'Identifies possible cases where Active Record save! or related should be used.'
10
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#save-bang'
11
+ Enabled: false
12
+
8
13
  Style/AutoResourceCleanup:
9
14
  Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
10
15
  Enabled: false
11
16
 
12
17
  Style/CollectionMethods:
13
18
  Description: 'Preferred collection methods.'
14
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size'
19
+ StyleGuide: '#map-find-select-reduce-size'
15
20
  Enabled: false
16
21
 
17
22
  Style/Copyright:
18
23
  Description: 'Include a copyright notice in each file before any code.'
19
24
  Enabled: false
20
25
 
26
+ Style/DocumentationMethod:
27
+ Description: 'Public methods.'
28
+ Enabled: false
29
+ Exclude:
30
+ - 'spec/**/*'
31
+ - 'test/**/*'
32
+
21
33
  Style/Encoding:
22
34
  Description: 'Use UTF-8 as the source file encoding.'
23
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#utf-8'
35
+ StyleGuide: '#utf-8'
24
36
  Enabled: false
25
37
 
26
38
  Style/FirstArrayElementLineBreak:
@@ -47,13 +59,19 @@ Style/FirstMethodParameterLineBreak:
47
59
  multi-line method parameter definition.
48
60
  Enabled: false
49
61
 
62
+ Style/ImplicitRuntimeError:
63
+ Description: >-
64
+ Use `raise` or `fail` with an explicit exception class and
65
+ message, rather than just a message.
66
+ Enabled: false
67
+
50
68
  Style/InlineComment:
51
- Description: 'Avoid inline comments.'
69
+ Description: 'Avoid trailing inline comments.'
52
70
  Enabled: false
53
71
 
54
72
  Style/MethodCalledOnDoEndBlock:
55
73
  Description: 'Avoid chaining a method call on a do...end block.'
56
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
74
+ StyleGuide: '#single-line-blocks'
57
75
  Enabled: false
58
76
 
59
77
  Style/MissingElse:
@@ -73,37 +91,9 @@ Style/MissingElse:
73
91
  - case
74
92
  - both
75
93
 
76
- Style/MultilineArrayBraceLayout:
77
- Description: >-
78
- Checks that the closing brace in an array literal is
79
- symmetrical with respect to the opening brace and the
80
- array elements.
81
- Enabled: false
82
-
83
94
  Style/MultilineAssignmentLayout:
84
95
  Description: 'Check for a newline after the assignment operator in multi-line assignments.'
85
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#indent-conditional-assignment'
86
- Enabled: false
87
-
88
- Style/MultilineHashBraceLayout:
89
- Description: >-
90
- Checks that the closing brace in a hash literal is
91
- symmetrical with respect to the opening brace and the
92
- hash elements.
93
- Enabled: false
94
-
95
- Style/MultilineMethodCallBraceLayout:
96
- Description: >-
97
- Checks that the closing brace in a method call is
98
- symmetrical with respect to the opening brace and the
99
- method arguments.
100
- Enabled: false
101
-
102
- Style/MultilineMethodDefinitionBraceLayout:
103
- Description: >-
104
- Checks that the closing brace in a method definition is
105
- symmetrical with respect to the opening brace and the
106
- method parameters.
96
+ StyleGuide: '#indent-conditional-assignment'
107
97
  Enabled: false
108
98
 
109
99
  Style/OptionHash:
@@ -112,7 +102,7 @@ Style/OptionHash:
112
102
 
113
103
  Style/Send:
114
104
  Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.'
115
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#prefer-public-send'
105
+ StyleGuide: '#prefer-public-send'
116
106
  Enabled: false
117
107
 
118
108
  Style/StringMethods:
@@ -121,5 +111,5 @@ Style/StringMethods:
121
111
 
122
112
  Style/SymbolArray:
123
113
  Description: 'Use %i or %I for arrays of symbols.'
124
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-i'
114
+ StyleGuide: '#percent-i'
125
115
  Enabled: false