govuk-lint 0.1.0
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 +7 -0
- data/bin/govuk-lint-ruby +10 -0
- data/configs/rubocop/all.yml +6 -0
- data/configs/rubocop/gds-ruby-styleguide.yml +318 -0
- data/configs/rubocop/other-lint.yml +131 -0
- data/configs/rubocop/other-metrics.yml +11 -0
- data/configs/rubocop/other-rails.yml +33 -0
- data/configs/rubocop/other-style.yml +381 -0
- data/lib/govuk/lint.rb +9 -0
- data/lib/govuk/lint/cli.rb +16 -0
- data/lib/govuk/lint/diff.rb +54 -0
- data/lib/govuk/lint/version.rb +5 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 601bc226ff1d94cefb7a28a277a41ac5bc480aa0
|
4
|
+
data.tar.gz: 8ceeef9992a92b8d4b888777e61d42c3c421a2c9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d72cf29292398a8ed146650dafea8ffe4e0af0ef46b5d865a85578c451b045a3e5d516e07751f6ee4a6cc139555c7cdef021a92eb359e6efdf533406b5794638
|
7
|
+
data.tar.gz: b1eaa941e439a5c8ba5b78cac85fcfc8f033a0b7ee0ce36326b2430f7320fcb6739985254bf07000b65f155e042e47d8d8479e9eb084cfacb88ac82f872ccde1
|
data/bin/govuk-lint-ruby
ADDED
@@ -0,0 +1,318 @@
|
|
1
|
+
############
|
2
|
+
## General
|
3
|
+
############
|
4
|
+
|
5
|
+
BlockAlignment:
|
6
|
+
Description: 'Align block ends correctly.'
|
7
|
+
Enabled: true
|
8
|
+
|
9
|
+
CaseIndentation:
|
10
|
+
Description: Indentation of when in a case/when/[else/]end.
|
11
|
+
Enabled: true
|
12
|
+
IndentWhenRelativeTo: case
|
13
|
+
SupportedStyles:
|
14
|
+
- case
|
15
|
+
- end
|
16
|
+
IndentOneStep: false
|
17
|
+
|
18
|
+
ElseLayout:
|
19
|
+
Description: 'Check for odd code arrangement in an else block.'
|
20
|
+
Enabled: true
|
21
|
+
|
22
|
+
# Supports --auto-correct
|
23
|
+
EmptyLineBetweenDefs:
|
24
|
+
Description: Use empty lines between defs.
|
25
|
+
Enabled: true
|
26
|
+
AllowAdjacentOneLineDefs: false
|
27
|
+
|
28
|
+
EmptyLines:
|
29
|
+
Description: "Don't use several empty lines in a row."
|
30
|
+
Enabled: true
|
31
|
+
|
32
|
+
EndAlignment:
|
33
|
+
Description: 'Align ends correctly.'
|
34
|
+
Enabled: true
|
35
|
+
|
36
|
+
EndOfLine:
|
37
|
+
Description: 'Use Unix-style line endings.'
|
38
|
+
Enabled: true
|
39
|
+
|
40
|
+
# Supports --auto-correct
|
41
|
+
IndentationWidth:
|
42
|
+
Description: Use 2 spaces for indentation.
|
43
|
+
Enabled: true
|
44
|
+
|
45
|
+
# Supports --auto-correct
|
46
|
+
IndentationConsistency:
|
47
|
+
Description: Keep indentation straight.
|
48
|
+
Enabled: true
|
49
|
+
|
50
|
+
LineLength:
|
51
|
+
Description: Limit lines to 80 characters.
|
52
|
+
Enabled: true
|
53
|
+
Max: 80
|
54
|
+
|
55
|
+
# Supports --auto-correct
|
56
|
+
SpaceAroundOperators:
|
57
|
+
Description: Use spaces around operators.
|
58
|
+
Enabled: true
|
59
|
+
|
60
|
+
# Supports --auto-correct
|
61
|
+
SpaceBeforeBlockBraces:
|
62
|
+
Description: Checks that the left block brace has or doesn't have space before it.
|
63
|
+
Enabled: true
|
64
|
+
EnforcedStyle: space
|
65
|
+
SupportedStyles:
|
66
|
+
- space
|
67
|
+
- no_space
|
68
|
+
|
69
|
+
# Supports --auto-correct
|
70
|
+
SpaceAfterSemicolon:
|
71
|
+
Description: Use spaces after semicolons.
|
72
|
+
Enabled: true
|
73
|
+
|
74
|
+
# Supports --auto-correct
|
75
|
+
SpaceAfterColon:
|
76
|
+
Description: Use spaces after colons.
|
77
|
+
Enabled: true
|
78
|
+
|
79
|
+
# Supports --auto-correct
|
80
|
+
SpaceAfterComma:
|
81
|
+
Description: Use spaces after commas.
|
82
|
+
Enabled: true
|
83
|
+
|
84
|
+
# Supports --auto-correct
|
85
|
+
SpaceInsideBrackets:
|
86
|
+
Description: No spaces after [ or before ].
|
87
|
+
Enabled: true
|
88
|
+
|
89
|
+
# Supports --auto-correct
|
90
|
+
SpaceInsideParens:
|
91
|
+
Description: No spaces after ( or before ).
|
92
|
+
Enabled: true
|
93
|
+
|
94
|
+
Tab:
|
95
|
+
Description: No hard tabs.
|
96
|
+
Enabled: true
|
97
|
+
|
98
|
+
# Supports --auto-correct
|
99
|
+
TrailingWhitespace:
|
100
|
+
Description: Avoid trailing whitespace.
|
101
|
+
Enabled: true
|
102
|
+
|
103
|
+
# Supports --auto-correct
|
104
|
+
TrailingBlankLines:
|
105
|
+
Description: Checks trailing blank lines and final newline.
|
106
|
+
Enabled: true
|
107
|
+
EnforcedStyle: final_newline
|
108
|
+
SupportedStyles:
|
109
|
+
- final_newline
|
110
|
+
- final_blank_line
|
111
|
+
|
112
|
+
## Syntax
|
113
|
+
|
114
|
+
# Supports --auto-correct
|
115
|
+
AndOr:
|
116
|
+
Description: Use &&/|| instead of and/or.
|
117
|
+
Enabled: true
|
118
|
+
|
119
|
+
# Supports --auto-correct
|
120
|
+
DefWithParentheses:
|
121
|
+
Description: Use def with parentheses when there are arguments.
|
122
|
+
Enabled: true
|
123
|
+
|
124
|
+
For:
|
125
|
+
Description: Checks use of for or each in multiline loops.
|
126
|
+
Enabled: true
|
127
|
+
EnforcedStyle: each
|
128
|
+
SupportedStyles:
|
129
|
+
- for
|
130
|
+
- each
|
131
|
+
|
132
|
+
IfUnlessModifier:
|
133
|
+
Description: Favor modifier if/unless usage when you have a single-line body.
|
134
|
+
Enabled: true
|
135
|
+
MaxLineLength: 80
|
136
|
+
|
137
|
+
MethodCalledOnDoEndBlock:
|
138
|
+
Description: Avoid chaining a method call on a do...end block.
|
139
|
+
Enabled: true
|
140
|
+
|
141
|
+
MethodCallParentheses:
|
142
|
+
Description: 'Do not use parentheses for method calls with no arguments.'
|
143
|
+
Enabled: true
|
144
|
+
|
145
|
+
MultilineBlockChain:
|
146
|
+
Description: Avoid multi-line chains of blocks.
|
147
|
+
Enabled: true
|
148
|
+
|
149
|
+
MultilineIfThen:
|
150
|
+
Description: Never use then for multi-line if/unless.
|
151
|
+
Enabled: true
|
152
|
+
|
153
|
+
MultilineTernaryOperator:
|
154
|
+
Description: 'Avoid multi-line ?: (the ternary operator); use if/unless instead.'
|
155
|
+
Enabled: true
|
156
|
+
|
157
|
+
NestedTernaryOperator:
|
158
|
+
Description: Use one expression per branch in a ternary operator.
|
159
|
+
Enabled: true
|
160
|
+
|
161
|
+
OneLineConditional:
|
162
|
+
Description: Favor the ternary operator(?:) over if/then/else/end constructs.
|
163
|
+
Enabled: true
|
164
|
+
|
165
|
+
# Supports --auto-correct
|
166
|
+
ParenthesesAroundCondition:
|
167
|
+
Description: Don't use parentheses around the condition of an if/unless/while.
|
168
|
+
Enabled: true
|
169
|
+
AllowSafeAssignment: true
|
170
|
+
|
171
|
+
# Supports --auto-correct
|
172
|
+
RedundantReturn:
|
173
|
+
Description: Don't use return where it's not required.
|
174
|
+
Enabled: true
|
175
|
+
AllowMultipleReturnValues: false
|
176
|
+
|
177
|
+
# Supports --auto-correct
|
178
|
+
SpaceAfterMethodName:
|
179
|
+
Description: Never put a space between a method name and the opening parenthesis in
|
180
|
+
a method definition.
|
181
|
+
Enabled: true
|
182
|
+
|
183
|
+
# Supports --auto-correct
|
184
|
+
SpaceAroundEqualsInParameterDefault:
|
185
|
+
Description: Checks that the equals signs in parameter default assignments have or
|
186
|
+
don't have surrounding space depending on configuration.
|
187
|
+
Enabled: true
|
188
|
+
EnforcedStyle: space
|
189
|
+
SupportedStyles:
|
190
|
+
- space
|
191
|
+
- no_space
|
192
|
+
|
193
|
+
UnlessElse:
|
194
|
+
Description: Never use unless with else. Rewrite these with the positive case first.
|
195
|
+
Enabled: true
|
196
|
+
|
197
|
+
# Supports --auto-correct
|
198
|
+
UnusedBlockArgument:
|
199
|
+
Description: Checks for unused block arguments.
|
200
|
+
Enabled: true
|
201
|
+
|
202
|
+
## Naming
|
203
|
+
|
204
|
+
ClassAndModuleCamelCase:
|
205
|
+
Description: Use CamelCase for classes and modules.
|
206
|
+
Enabled: true
|
207
|
+
|
208
|
+
# Supports --auto-correct
|
209
|
+
ClassMethods:
|
210
|
+
Description: Use self when defining module/class methods.
|
211
|
+
Enabled: true
|
212
|
+
|
213
|
+
ClassVars:
|
214
|
+
Description: Avoid the use of class variables.
|
215
|
+
Enabled: true
|
216
|
+
|
217
|
+
ConstantName:
|
218
|
+
Description: Constants should use SCREAMING_SNAKE_CASE.
|
219
|
+
Enabled: true
|
220
|
+
|
221
|
+
MethodName:
|
222
|
+
Description: Use the configured style when naming methods.
|
223
|
+
Enabled: true
|
224
|
+
EnforcedStyle: snake_case
|
225
|
+
SupportedStyles:
|
226
|
+
- snake_case
|
227
|
+
- camelCase
|
228
|
+
|
229
|
+
# Supports --auto-correct
|
230
|
+
TrivialAccessors:
|
231
|
+
Description: Prefer attr_* methods to trivial readers/writers.
|
232
|
+
Enabled: true
|
233
|
+
ExactNameMatch: true
|
234
|
+
AllowPredicates: false
|
235
|
+
AllowDSLWriters: false
|
236
|
+
Whitelist:
|
237
|
+
- to_ary
|
238
|
+
- to_a
|
239
|
+
- to_c
|
240
|
+
- to_enum
|
241
|
+
- to_h
|
242
|
+
- to_hash
|
243
|
+
- to_i
|
244
|
+
- to_int
|
245
|
+
- to_io
|
246
|
+
- to_open
|
247
|
+
- to_path
|
248
|
+
- to_proc
|
249
|
+
- to_r
|
250
|
+
- to_regexp
|
251
|
+
- to_str
|
252
|
+
- to_s
|
253
|
+
- to_sym
|
254
|
+
|
255
|
+
VariableName:
|
256
|
+
Description: Use the configured style when naming variables.
|
257
|
+
Enabled: true
|
258
|
+
EnforcedStyle: snake_case
|
259
|
+
SupportedStyles:
|
260
|
+
- snake_case
|
261
|
+
- camelCase
|
262
|
+
|
263
|
+
## Exceptions
|
264
|
+
|
265
|
+
# Supports --auto-correct
|
266
|
+
RescueException:
|
267
|
+
Description: Avoid rescuing the Exception class.
|
268
|
+
Enabled: true
|
269
|
+
|
270
|
+
## Collections
|
271
|
+
|
272
|
+
# Supports --auto-correct
|
273
|
+
AlignArray:
|
274
|
+
Description: Align the elements of an array literal if they span more than one line.
|
275
|
+
Enabled: true
|
276
|
+
|
277
|
+
# Supports --auto-correct
|
278
|
+
HashSyntax:
|
279
|
+
Description: 'Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax { :a => 1,
|
280
|
+
:b => 2 }.'
|
281
|
+
Enabled: true
|
282
|
+
Exclude:
|
283
|
+
- 'db/schema.rb'
|
284
|
+
|
285
|
+
EnforcedStyle: ruby19
|
286
|
+
SupportedStyles:
|
287
|
+
- ruby19
|
288
|
+
- hash_rockets
|
289
|
+
|
290
|
+
TrailingComma:
|
291
|
+
Description: Checks for trailing comma in parameter lists and literals.
|
292
|
+
Enabled: false
|
293
|
+
EnforcedStyleForMultiline: comma
|
294
|
+
SupportedStyles:
|
295
|
+
- comma
|
296
|
+
- no_comma
|
297
|
+
|
298
|
+
# Supports --auto-correct
|
299
|
+
WordArray:
|
300
|
+
Description: Use %w or %W for arrays of words.
|
301
|
+
Enabled: true
|
302
|
+
MinSize: 0
|
303
|
+
|
304
|
+
## Strings
|
305
|
+
|
306
|
+
# Supports --auto-correct
|
307
|
+
StringConversionInInterpolation:
|
308
|
+
Description: Checks for Object#to_s usage in string interpolation.
|
309
|
+
Enabled: true
|
310
|
+
|
311
|
+
# Supports --auto-correct
|
312
|
+
StringLiterals:
|
313
|
+
Description: Checks if uses of quotes match the configured preference.
|
314
|
+
Enabled: true
|
315
|
+
EnforcedStyle: double_quotes
|
316
|
+
SupportedStyles:
|
317
|
+
- single_quotes
|
318
|
+
- double_quotes
|
@@ -0,0 +1,131 @@
|
|
1
|
+
AmbiguousOperator:
|
2
|
+
Description: >-
|
3
|
+
Checks for ambiguous operators in the first argument of a
|
4
|
+
method invocation without parentheses.
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
AmbiguousRegexpLiteral:
|
8
|
+
Description: >-
|
9
|
+
Checks for ambiguous regexp literals in the first argument of
|
10
|
+
a method invocation without parenthesis.
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
AssignmentInCondition:
|
14
|
+
Description: "Don't use assignment in conditions."
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
ConditionPosition:
|
18
|
+
Description: 'Checks for condition placed in a confusing position relative to the keyword.'
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Debugger:
|
22
|
+
Description: 'Check for debugger calls.'
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
DeprecatedClassMethods:
|
26
|
+
Description: 'Check for deprecated class method calls.'
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
EmptyEnsure:
|
30
|
+
Description: 'Checks for empty ensure block.'
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
EmptyInterpolation:
|
34
|
+
Description: 'Checks for empty string interpolation.'
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
EndInMethod:
|
38
|
+
Description: 'END blocks should not be placed inside method definitions.'
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
EnsureReturn:
|
42
|
+
Description: 'Never use return in an ensure block.'
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Eval:
|
46
|
+
Description: 'The use of eval represents a serious security risk.'
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
HandleExceptions:
|
50
|
+
Description: "Don't suppress exception."
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
InvalidCharacterLiteral:
|
54
|
+
Description: >-
|
55
|
+
Checks for invalid character literals with a non-escaped
|
56
|
+
whitespace character.
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
LiteralInCondition:
|
60
|
+
Description: 'Checks of literals used in conditions.'
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
LiteralInInterpolation:
|
64
|
+
Description: 'Checks for literals used in interpolation.'
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Loop:
|
68
|
+
Description: >-
|
69
|
+
Use Kernel#loop with break rather than begin/end/until or
|
70
|
+
begin/end/while for post-loop tests.
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
ParenthesesAsGroupedExpression:
|
74
|
+
Description: >-
|
75
|
+
Checks for method calls with a space before the opening
|
76
|
+
parenthesis.
|
77
|
+
Enabled: false
|
78
|
+
|
79
|
+
RequireParentheses:
|
80
|
+
Description: >-
|
81
|
+
Use parentheses in the method call to avoid confusion
|
82
|
+
about precedence.
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
ShadowingOuterLocalVariable:
|
86
|
+
Description: >-
|
87
|
+
Do not use the same name as outer local variable
|
88
|
+
for block arguments or block local variables.
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
SpaceBeforeFirstArg:
|
92
|
+
Description: >-
|
93
|
+
Put a space between a method name and the first argument
|
94
|
+
in a method call without parentheses.
|
95
|
+
Enabled: false
|
96
|
+
|
97
|
+
UnderscorePrefixedVariableName:
|
98
|
+
Description: 'Do not use prefix `_` for a variable that is used.'
|
99
|
+
Enabled: false
|
100
|
+
|
101
|
+
UnusedMethodArgument:
|
102
|
+
Description: 'Checks for unused method arguments.'
|
103
|
+
Enabled: false
|
104
|
+
|
105
|
+
UnreachableCode:
|
106
|
+
Description: 'Unreachable code.'
|
107
|
+
Enabled: false
|
108
|
+
|
109
|
+
UselessAccessModifier:
|
110
|
+
Description: 'Checks for useless access modifiers.'
|
111
|
+
Enabled: false
|
112
|
+
|
113
|
+
UselessAssignment:
|
114
|
+
Description: 'Checks for useless assignment to a local variable.'
|
115
|
+
Enabled: false
|
116
|
+
|
117
|
+
UselessComparison:
|
118
|
+
Description: 'Checks for comparison of something with itself.'
|
119
|
+
Enabled: false
|
120
|
+
|
121
|
+
UselessElseWithoutRescue:
|
122
|
+
Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
|
123
|
+
Enabled: false
|
124
|
+
|
125
|
+
UselessSetterCall:
|
126
|
+
Description: 'Checks for useless setter call to a local variable.'
|
127
|
+
Enabled: false
|
128
|
+
|
129
|
+
Void:
|
130
|
+
Description: 'Possible use of operator/literal/variable in void context.'
|
131
|
+
Enabled: false
|
@@ -0,0 +1,33 @@
|
|
1
|
+
##################### Rails ##################################
|
2
|
+
|
3
|
+
ActionFilter:
|
4
|
+
Description: 'Enforces consistent use of action filter methods.'
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
DefaultScope:
|
8
|
+
Description: 'Checks if the argument passed to default_scope is a block.'
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Delegate:
|
12
|
+
Description: 'Prefer delegate method for delegations.'
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
HasAndBelongsToMany:
|
16
|
+
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Output:
|
20
|
+
Description: 'Checks for calls to puts, print, etc.'
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
ReadWriteAttribute:
|
24
|
+
Description: 'Checks for read_attribute(:attr) and write_attribute(:attr, val).'
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
ScopeArgs:
|
28
|
+
Description: 'Checks the arguments of ActiveRecord scopes.'
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Validation:
|
32
|
+
Description: 'Use sexy validations.'
|
33
|
+
Enabled: false
|
@@ -0,0 +1,381 @@
|
|
1
|
+
AccessModifierIndentation:
|
2
|
+
Description: Check indentation of private/protected visibility modifiers.
|
3
|
+
Enabled: false
|
4
|
+
|
5
|
+
AccessorMethodName:
|
6
|
+
Description: Check the naming of accessor methods for get_/set_.
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Alias:
|
10
|
+
Description: 'Use alias_method instead of alias.'
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
AlignHash:
|
14
|
+
Description: >-
|
15
|
+
Align the elements of a hash literal if they span more than
|
16
|
+
one line.
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
AlignParameters:
|
20
|
+
Description: >-
|
21
|
+
Align the parameters of a method call if they span more
|
22
|
+
than one line.
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
ArrayJoin:
|
26
|
+
Description: 'Use Array#join instead of Array#*.'
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
AsciiComments:
|
30
|
+
Description: 'Use only ascii symbols in comments.'
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
AsciiIdentifiers:
|
34
|
+
Description: 'Use only ascii symbols in identifiers.'
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Attr:
|
38
|
+
Description: 'Checks for uses of Module#attr.'
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
BeginBlock:
|
42
|
+
Description: 'Avoid the use of BEGIN blocks.'
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
BlockComments:
|
46
|
+
Description: 'Do not use block comments.'
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
BlockNesting:
|
50
|
+
Description: 'Avoid excessive block nesting'
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
BlockDelimiters:
|
54
|
+
Description: >-
|
55
|
+
Avoid using {...} for multi-line blocks (multiline chaining is
|
56
|
+
always ugly).
|
57
|
+
Prefer {...} over do...end for single-line blocks.
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
BracesAroundHashParameters:
|
61
|
+
Description: 'Enforce braces style inside hash parameters.'
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
CaseEquality:
|
65
|
+
Description: 'Avoid explicit use of the case equality operator(===).'
|
66
|
+
Enabled: false
|
67
|
+
|
68
|
+
CharacterLiteral:
|
69
|
+
Description: 'Checks for uses of character literals.'
|
70
|
+
Enabled: false
|
71
|
+
|
72
|
+
ClassAndModuleChildren:
|
73
|
+
Description: 'Checks style of children classes and modules.'
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
ClassLength:
|
77
|
+
Description: 'Avoid classes longer than 100 lines of code.'
|
78
|
+
Enabled: false
|
79
|
+
|
80
|
+
CollectionMethods:
|
81
|
+
Description: 'Preferred collection methods.'
|
82
|
+
Enabled: false
|
83
|
+
|
84
|
+
ColonMethodCall:
|
85
|
+
Description: 'Do not use :: for method call.'
|
86
|
+
Enabled: false
|
87
|
+
|
88
|
+
CommentAnnotation:
|
89
|
+
Description: >-
|
90
|
+
Checks formatting of special comments
|
91
|
+
(TODO, FIXME, OPTIMIZE, HACK, REVIEW).
|
92
|
+
Enabled: false
|
93
|
+
|
94
|
+
CommentIndentation:
|
95
|
+
Description: 'Indentation of comments.'
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
CyclomaticComplexity:
|
99
|
+
Description: 'Avoid complex methods.'
|
100
|
+
Enabled: false
|
101
|
+
|
102
|
+
DeprecatedHashMethods:
|
103
|
+
Description: 'Checks for use of deprecated Hash methods.'
|
104
|
+
Enabled: false
|
105
|
+
|
106
|
+
Documentation:
|
107
|
+
Description: 'Document classes and non-namespace modules.'
|
108
|
+
Enabled: false
|
109
|
+
|
110
|
+
DotPosition:
|
111
|
+
Description: 'Checks the position of the dot in multi-line method calls.'
|
112
|
+
Enabled: false
|
113
|
+
|
114
|
+
DoubleNegation:
|
115
|
+
Description: 'Checks for uses of double negation (!!).'
|
116
|
+
Enabled: false
|
117
|
+
|
118
|
+
EachWithObject:
|
119
|
+
Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
|
120
|
+
Enabled: false
|
121
|
+
|
122
|
+
EmptyLinesAroundAccessModifier:
|
123
|
+
Description: "Keep blank lines around access modifiers."
|
124
|
+
Enabled: false
|
125
|
+
|
126
|
+
EmptyLines:
|
127
|
+
Description: "Keeps track of empty lines around expression bodies."
|
128
|
+
Enabled: false
|
129
|
+
|
130
|
+
EmptyLiteral:
|
131
|
+
Description: 'Prefer literals to Array.new/Hash.new/String.new.'
|
132
|
+
Enabled: false
|
133
|
+
|
134
|
+
Encoding:
|
135
|
+
Description: 'Use UTF-8 as the source file encoding.'
|
136
|
+
Enabled: false
|
137
|
+
|
138
|
+
EndBlock:
|
139
|
+
Description: 'Avoid the use of END blocks.'
|
140
|
+
Enabled: false
|
141
|
+
|
142
|
+
EvenOdd:
|
143
|
+
Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
|
144
|
+
Enabled: false
|
145
|
+
|
146
|
+
FileName:
|
147
|
+
Description: 'Use snake_case for source file names.'
|
148
|
+
Enabled: false
|
149
|
+
|
150
|
+
FlipFlop:
|
151
|
+
Description: 'Checks for flip flops'
|
152
|
+
Enabled: false
|
153
|
+
|
154
|
+
FormatString:
|
155
|
+
Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
|
156
|
+
Enabled: false
|
157
|
+
|
158
|
+
GlobalVars:
|
159
|
+
Description: 'Do not introduce global variables.'
|
160
|
+
Enabled: false
|
161
|
+
|
162
|
+
GuardClause:
|
163
|
+
Description: 'Check for conditionals that can be replaced with guard clauses'
|
164
|
+
Enabled: false
|
165
|
+
|
166
|
+
IfWithSemicolon:
|
167
|
+
Description: 'Never use if x; .... Use the ternary operator instead.'
|
168
|
+
Enabled: false
|
169
|
+
|
170
|
+
IndentArray:
|
171
|
+
Description: >-
|
172
|
+
Checks the indentation of the first element in an array
|
173
|
+
literal.
|
174
|
+
Enabled: false
|
175
|
+
|
176
|
+
IndentHash:
|
177
|
+
Description: 'Checks the indentation of the first key in a hash literal.'
|
178
|
+
Enabled: false
|
179
|
+
|
180
|
+
Lambda:
|
181
|
+
Description: 'Use the new lambda literal syntax for single-line blocks.'
|
182
|
+
Enabled: false
|
183
|
+
|
184
|
+
LambdaCall:
|
185
|
+
Description: 'Use lambda.call(...) instead of lambda.(...).'
|
186
|
+
Enabled: false
|
187
|
+
|
188
|
+
LeadingCommentSpace:
|
189
|
+
Description: 'Comments should start with a space.'
|
190
|
+
Enabled: false
|
191
|
+
|
192
|
+
LineEndConcatenation:
|
193
|
+
Description: >-
|
194
|
+
Use \ instead of + or << to concatenate two string literals at
|
195
|
+
line end.
|
196
|
+
Enabled: false
|
197
|
+
|
198
|
+
MethodDefParentheses:
|
199
|
+
Description: >-
|
200
|
+
Checks if the method definitions have or don't have
|
201
|
+
parentheses.
|
202
|
+
Enabled: false
|
203
|
+
|
204
|
+
MethodLength:
|
205
|
+
Description: 'Avoid methods longer than 10 lines of code.'
|
206
|
+
Enabled: false
|
207
|
+
|
208
|
+
ModuleFunction:
|
209
|
+
Description: 'Checks for usage of `extend self` in modules.'
|
210
|
+
Enabled: false
|
211
|
+
|
212
|
+
NegatedIf:
|
213
|
+
Description: >-
|
214
|
+
Favor unless over if for negative conditions
|
215
|
+
(or control flow or).
|
216
|
+
Enabled: false
|
217
|
+
|
218
|
+
NegatedWhile:
|
219
|
+
Description: 'Favor until over while for negative conditions.'
|
220
|
+
Enabled: false
|
221
|
+
|
222
|
+
Next:
|
223
|
+
Description: 'Use `next` to skip iteration instead of a condition at the end.'
|
224
|
+
Enabled: false
|
225
|
+
|
226
|
+
NilComparison:
|
227
|
+
Description: 'Prefer x.nil? to x == nil.'
|
228
|
+
Enabled: false
|
229
|
+
|
230
|
+
NonNilCheck:
|
231
|
+
Description: 'Checks for redundant nil checks.'
|
232
|
+
Enabled: false
|
233
|
+
|
234
|
+
Not:
|
235
|
+
Description: 'Use ! instead of not.'
|
236
|
+
Enabled: false
|
237
|
+
|
238
|
+
NumericLiterals:
|
239
|
+
Description: >-
|
240
|
+
Add underscores to large numeric literals to improve their
|
241
|
+
readability.
|
242
|
+
Enabled: false
|
243
|
+
|
244
|
+
OpMethod:
|
245
|
+
Description: 'When defining binary operators, name the argument other.'
|
246
|
+
Enabled: false
|
247
|
+
|
248
|
+
ParameterLists:
|
249
|
+
Description: 'Avoid parameter lists longer than three or four parameters.'
|
250
|
+
Enabled: false
|
251
|
+
|
252
|
+
PercentLiteralDelimiters:
|
253
|
+
Description: 'Use `%`-literal delimiters consistently'
|
254
|
+
Enabled: false
|
255
|
+
|
256
|
+
PerlBackrefs:
|
257
|
+
Description: 'Avoid Perl-style regex back references.'
|
258
|
+
Enabled: false
|
259
|
+
|
260
|
+
PredicateName:
|
261
|
+
Description: 'Check the names of predicate methods.'
|
262
|
+
Enabled: false
|
263
|
+
|
264
|
+
Proc:
|
265
|
+
Description: 'Use proc instead of Proc.new.'
|
266
|
+
Enabled: false
|
267
|
+
|
268
|
+
RaiseArgs:
|
269
|
+
Description: 'Checks the arguments passed to raise/fail.'
|
270
|
+
Enabled: false
|
271
|
+
|
272
|
+
RedundantBegin:
|
273
|
+
Description: "Don't use begin blocks when they are not needed."
|
274
|
+
Enabled: false
|
275
|
+
|
276
|
+
RedundantException:
|
277
|
+
Description: "Checks for an obsolete RuntimeException argument in raise/fail."
|
278
|
+
Enabled: false
|
279
|
+
|
280
|
+
RedundantSelf:
|
281
|
+
Description: "Don't use self where it's not needed."
|
282
|
+
Enabled: false
|
283
|
+
|
284
|
+
RegexpLiteral:
|
285
|
+
Description: >-
|
286
|
+
Use %r for regular expressions matching more than
|
287
|
+
`MaxSlashes` '/' characters.
|
288
|
+
Use %r only for regular expressions matching more than
|
289
|
+
`MaxSlashes` '/' character.
|
290
|
+
Enabled: false
|
291
|
+
|
292
|
+
RescueModifier:
|
293
|
+
Description: 'Avoid using rescue in its modifier form.'
|
294
|
+
Enabled: false
|
295
|
+
|
296
|
+
SelfAssignment:
|
297
|
+
Description: 'Checks for places where self-assignment shorthand should have been used.'
|
298
|
+
Enabled: false
|
299
|
+
|
300
|
+
Semicolon:
|
301
|
+
Description: "Don't use semicolons to terminate expressions."
|
302
|
+
Enabled: false
|
303
|
+
|
304
|
+
SignalException:
|
305
|
+
Description: 'Checks for proper usage of fail and raise.'
|
306
|
+
Enabled: false
|
307
|
+
|
308
|
+
SingleLineBlockParams:
|
309
|
+
Description: 'Enforces the names of some block params.'
|
310
|
+
Enabled: false
|
311
|
+
|
312
|
+
SingleLineMethods:
|
313
|
+
Description: 'Avoid single-line methods.'
|
314
|
+
Enabled: false
|
315
|
+
|
316
|
+
SingleSpaceBeforeFirstArg:
|
317
|
+
Description: >-
|
318
|
+
Checks that exactly one space is used between a method name
|
319
|
+
and the first argument for method calls without parentheses.
|
320
|
+
Enabled: false
|
321
|
+
|
322
|
+
SpaceAfterControlKeyword:
|
323
|
+
Description: 'Use spaces after if/elsif/unless/while/until/case/when.'
|
324
|
+
Enabled: false
|
325
|
+
|
326
|
+
SpaceAfterNot:
|
327
|
+
Description: Tracks redundant space after the ! operator.
|
328
|
+
Enabled: false
|
329
|
+
|
330
|
+
SpaceBeforeComment:
|
331
|
+
Description: >-
|
332
|
+
Checks for missing space between code and a comment on the
|
333
|
+
same line.
|
334
|
+
Enabled: false
|
335
|
+
|
336
|
+
SpaceInsideBlockBraces:
|
337
|
+
Description: >-
|
338
|
+
Checks that block braces have or don't have surrounding space.
|
339
|
+
For blocks taking parameters, checks that the left brace has
|
340
|
+
or doesn't have trailing space.
|
341
|
+
Enabled: false
|
342
|
+
|
343
|
+
SpaceBeforeModifierKeyword:
|
344
|
+
Description: 'Put a space before the modifier keyword.'
|
345
|
+
Enabled: false
|
346
|
+
|
347
|
+
SpaceInsideHashLiteralBraces:
|
348
|
+
Description: "Use spaces inside hash literal braces - or don't."
|
349
|
+
Enabled: false
|
350
|
+
|
351
|
+
SpecialGlobalVars:
|
352
|
+
Description: 'Avoid Perl-style global variables.'
|
353
|
+
Enabled: false
|
354
|
+
|
355
|
+
UnneededCapitalW:
|
356
|
+
Description: 'Checks for %W when interpolation is not needed.'
|
357
|
+
Enabled: false
|
358
|
+
|
359
|
+
CommandLiteral:
|
360
|
+
Description: 'Checks for %x when `` would do.'
|
361
|
+
Enabled: false
|
362
|
+
|
363
|
+
VariableInterpolation:
|
364
|
+
Description: >-
|
365
|
+
Don't interpolate global, instance and class variables
|
366
|
+
directly in strings.
|
367
|
+
Enabled: false
|
368
|
+
|
369
|
+
WhenThen:
|
370
|
+
Description: 'Use when x then ... for one-line cases.'
|
371
|
+
Enabled: false
|
372
|
+
|
373
|
+
WhileUntilDo:
|
374
|
+
Description: 'Checks for redundant do after while or until.'
|
375
|
+
Enabled: false
|
376
|
+
|
377
|
+
WhileUntilModifier:
|
378
|
+
Description: >-
|
379
|
+
Favor modifier while/until usage when you have a
|
380
|
+
single-line body.
|
381
|
+
Enabled: false
|
data/lib/govuk/lint.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "rubocop"
|
2
|
+
|
3
|
+
module Govuk
|
4
|
+
module Lint
|
5
|
+
class CLI < RuboCop::CLI
|
6
|
+
def run(args = ARGV)
|
7
|
+
args += ["--config",
|
8
|
+
File.join(Govuk::Lint::CONFIG_PATH, "rubocop/all.yml")]
|
9
|
+
|
10
|
+
Diff.enable!(args) if args.include? "--diff"
|
11
|
+
|
12
|
+
super(args)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Govuk
|
2
|
+
module Lint
|
3
|
+
module Diff
|
4
|
+
module EnabledLines
|
5
|
+
def enabled_line?(line_number)
|
6
|
+
super(line_number) &&
|
7
|
+
Diff.changed_lines[@processed_source.path].include?(line_number)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module TargetFinder
|
12
|
+
def find(args)
|
13
|
+
super(args).select { |f| Diff.changed_lines.keys.include? f }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.enable!(args)
|
18
|
+
args.delete("--diff")
|
19
|
+
@cached = true if args.delete("--cached")
|
20
|
+
RuboCop::Cop::Cop.prepend EnabledLines
|
21
|
+
RuboCop::TargetFinder.prepend TargetFinder
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.changed_lines
|
25
|
+
@changed_lines ||= begin
|
26
|
+
changes = changed_files.map do |file|
|
27
|
+
next unless File.exist?(file)
|
28
|
+
[file, `git difftool #{commit_options}
|
29
|
+
-y
|
30
|
+
-x 'diff
|
31
|
+
--new-line-format="%dn "
|
32
|
+
--unchanged-line-format=""
|
33
|
+
--changed-group-format="%>"'
|
34
|
+
#{file}`.split.map(&:to_i)]
|
35
|
+
end
|
36
|
+
|
37
|
+
Hash[changes.compact].tap { |h| h.default = [] }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def self.changed_files
|
43
|
+
`git diff #{commit_options} --name-only`.
|
44
|
+
split.
|
45
|
+
select { |f| f =~ %r{.rb$} }.
|
46
|
+
map { |f| File.expand_path(f.chomp, "./") }
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.commit_options
|
50
|
+
@cached ? "--cached origin/master" : "origin/master HEAD"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: govuk-lint
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Government Digital Service
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: gem_publisher
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.5.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.5.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.32'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.32'
|
69
|
+
description: Include this in your project to easily validate it against the GDS style
|
70
|
+
guides
|
71
|
+
email:
|
72
|
+
- govuk-dev@digital.cabinet-office.gov.uk
|
73
|
+
executables:
|
74
|
+
- govuk-lint-ruby
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- bin/govuk-lint-ruby
|
79
|
+
- configs/rubocop/all.yml
|
80
|
+
- configs/rubocop/gds-ruby-styleguide.yml
|
81
|
+
- configs/rubocop/other-lint.yml
|
82
|
+
- configs/rubocop/other-metrics.yml
|
83
|
+
- configs/rubocop/other-rails.yml
|
84
|
+
- configs/rubocop/other-style.yml
|
85
|
+
- lib/govuk/lint.rb
|
86
|
+
- lib/govuk/lint/cli.rb
|
87
|
+
- lib/govuk/lint/diff.rb
|
88
|
+
- lib/govuk/lint/version.rb
|
89
|
+
homepage: https://github.com/alphagov/govuk-lint
|
90
|
+
licenses: []
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.4.5
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: A wrapper around rubocop, configured with the GDS style guides
|
112
|
+
test_files: []
|