rubocop-github 0.12.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +31 -2
- data/STYLEGUIDE.md +27 -11
- data/config/_default_shared.yml +329 -0
- data/config/_rails_shared.yml +120 -0
- data/config/default.yml +2 -326
- data/config/default_deprecated.yml +4 -0
- data/config/default_edge.yml +4 -0
- data/config/rails.yml +2 -118
- data/config/rails_deprecated.yml +7 -0
- data/config/rails_edge.yml +4 -0
- data/lib/rubocop/cop/github.rb +1 -0
- data/lib/rubocop/cop/github/insecure_hash_algorithm.rb +139 -0
- data/lib/rubocop/cop/github/rails_controller_render_action_symbol.rb +2 -2
- data/lib/rubocop/cop/github/rails_controller_render_literal.rb +31 -16
- data/lib/rubocop/cop/github/rails_controller_render_paths_exist.rb +3 -3
- data/lib/rubocop/cop/github/rails_controller_render_shorthand.rb +1 -1
- data/lib/rubocop/cop/github/rails_render_inline.rb +1 -1
- data/lib/rubocop/cop/github/rails_render_object_collection.rb +1 -1
- data/lib/rubocop/cop/github/rails_view_render_literal.rb +26 -16
- data/lib/rubocop/cop/github/rails_view_render_paths_exist.rb +3 -3
- data/lib/rubocop/cop/github/rails_view_render_shorthand.rb +1 -1
- data/lib/rubocop/cop/github/render_literal_helpers.rb +54 -0
- metadata +49 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2b53ecd11b38faabbc6eea214afc14515faa069d354b38d048a054821018499b
|
4
|
+
data.tar.gz: 500ca24b6717dfe481a3c472e02ef3dcc61bb41c8de7f872ba838a58659548b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1ca6682867334fd2194722129145c669a094657259e76e2a449fbbff018ac541ce0f0f9d5395b9edd9c63eca9f846b4f4f185e39870fcb1cdc3ee335d205557
|
7
|
+
data.tar.gz: 2acd77310e4b23a59f4cd0c1fbad5d4c4b314e79e3cbd6047e7d11c423adf20944bd4ec2a769b5bf8dc88f8aacc27324f8a56af05989cd467bded66d287be71e
|
data/README.md
CHANGED
@@ -1,12 +1,17 @@
|
|
1
|
-
# RuboCop GitHub
|
1
|
+
# RuboCop GitHub ![CI](https://github.com/github/rubocop-github/workflows/CI/badge.svg?event=push)
|
2
2
|
|
3
3
|
This repository provides recommended RuboCop configuration and additional Cops for use on GitHub open source and internal Ruby projects.
|
4
4
|
|
5
|
-
##
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Rubocop 0.68 removed performance cops and 0.72 removed Rails cops. However, upgrading `rubocop-github` without modification will almost definitely create very many new offenses. The current version of this gem exposes the "legacy" configuration under `config/default.yml` and `config/rails.yml` which should be used *if and only if* the version of rubocop is locked to `< 0.68` in your project (which it should be unless you `bundle update rubocop`). It also exposes an "edge" configuration under `config/default_edge.yml` and `config/rails_edge.yml` so that the changes can be tested without introducing breaking changes.
|
8
|
+
|
9
|
+
### Legacy usage
|
6
10
|
|
7
11
|
**Gemfile**
|
8
12
|
|
9
13
|
``` ruby
|
14
|
+
gem "rubocop", "< 0.68"
|
10
15
|
gem "rubocop-github"
|
11
16
|
```
|
12
17
|
|
@@ -19,6 +24,30 @@ inherit_gem:
|
|
19
24
|
- config/rails.yml
|
20
25
|
```
|
21
26
|
|
27
|
+
### Edge usage
|
28
|
+
|
29
|
+
**Gemfile**
|
30
|
+
|
31
|
+
``` ruby
|
32
|
+
gem "rubocop-github"
|
33
|
+
gem "rubocop-performance", require: false
|
34
|
+
gem "rubocop-rails", require: false
|
35
|
+
```
|
36
|
+
|
37
|
+
**.rubocop.yml**
|
38
|
+
|
39
|
+
``` yaml
|
40
|
+
inherit_gem:
|
41
|
+
rubocop-github:
|
42
|
+
- config/default_edge.yml
|
43
|
+
- config/rails_edge.yml
|
44
|
+
```
|
45
|
+
|
46
|
+
## Testing
|
47
|
+
|
48
|
+
`bundle install`
|
49
|
+
`bundle exec rake test`
|
50
|
+
|
22
51
|
## The Cops
|
23
52
|
|
24
53
|
All cops are located under [`lib/rubocop/cop/github`](lib/rubocop/cop/github), and contain examples/documentation.
|
data/STYLEGUIDE.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
* Use soft-tabs with a two space indent.
|
4
4
|
|
5
|
-
* Keep each line of code to a readable length. Unless you have a reason to, keep lines to
|
5
|
+
* Keep each line of code to a readable length. Unless you have a reason to, keep lines to a maximum of 118 characters. Why 118? That's the width at which the pull request diff UI needs horizontal scrolling (making pull requests harder to review).
|
6
6
|
|
7
7
|
* Never leave trailing whitespace.
|
8
8
|
|
@@ -31,9 +31,34 @@ some(arg).other
|
|
31
31
|
!array.include?(element)
|
32
32
|
```
|
33
33
|
|
34
|
-
* Indent `when`
|
34
|
+
* Indent `when` with the start of the `case` expression.
|
35
35
|
|
36
36
|
``` ruby
|
37
|
+
# bad
|
38
|
+
message = case
|
39
|
+
when song.name == "Misty"
|
40
|
+
"Not again!"
|
41
|
+
when song.duration > 120
|
42
|
+
"Too long!"
|
43
|
+
when Time.now.hour > 21
|
44
|
+
"It's too late"
|
45
|
+
else
|
46
|
+
song.to_s
|
47
|
+
end
|
48
|
+
|
49
|
+
# good
|
50
|
+
message = case
|
51
|
+
when song.name == "Misty"
|
52
|
+
"Not again!"
|
53
|
+
when song.duration > 120
|
54
|
+
"Too long!"
|
55
|
+
when Time.now.hour > 21
|
56
|
+
"It's too late"
|
57
|
+
else
|
58
|
+
song.to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
# good
|
37
62
|
case
|
38
63
|
when song.name == "Misty"
|
39
64
|
puts "Not again!"
|
@@ -44,15 +69,6 @@ when Time.now.hour > 21
|
|
44
69
|
else
|
45
70
|
song.play
|
46
71
|
end
|
47
|
-
|
48
|
-
kind = case year
|
49
|
-
when 1850..1889 then "Blues"
|
50
|
-
when 1890..1909 then "Ragtime"
|
51
|
-
when 1910..1929 then "New Orleans Jazz"
|
52
|
-
when 1930..1939 then "Swing"
|
53
|
-
when 1940..1950 then "Bebop"
|
54
|
-
else "Jazz"
|
55
|
-
end
|
56
72
|
```
|
57
73
|
|
58
74
|
* Use empty lines between `def`s and to break up a method into logical
|
@@ -0,0 +1,329 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop/cop/github
|
3
|
+
- rubocop-performance
|
4
|
+
|
5
|
+
# These cops are compatible across supported versions of rubocop
|
6
|
+
|
7
|
+
Bundler/DuplicatedGem:
|
8
|
+
Enabled: true
|
9
|
+
|
10
|
+
Bundler/OrderedGems:
|
11
|
+
Enabled: true
|
12
|
+
|
13
|
+
GitHub/InsecureHashAlgorithm:
|
14
|
+
Enabled: true
|
15
|
+
|
16
|
+
Layout/BlockAlignment:
|
17
|
+
Enabled: true
|
18
|
+
|
19
|
+
Layout/BlockEndNewline:
|
20
|
+
Enabled: true
|
21
|
+
|
22
|
+
Layout/ConditionPosition:
|
23
|
+
Enabled: true
|
24
|
+
|
25
|
+
Layout/DefEndAlignment:
|
26
|
+
Enabled: true
|
27
|
+
|
28
|
+
Layout/EndAlignment:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Layout/EndOfLine:
|
32
|
+
Enabled: true
|
33
|
+
|
34
|
+
Layout/IndentationStyle:
|
35
|
+
Enabled: true
|
36
|
+
EnforcedStyle: spaces
|
37
|
+
IndentationWidth: 2
|
38
|
+
|
39
|
+
Layout/InitialIndentation:
|
40
|
+
Enabled: true
|
41
|
+
|
42
|
+
Layout/LineLength:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Layout/SpaceAfterColon:
|
46
|
+
Enabled: true
|
47
|
+
|
48
|
+
Layout/SpaceAfterComma:
|
49
|
+
Enabled: true
|
50
|
+
|
51
|
+
Layout/SpaceAfterMethodName:
|
52
|
+
Enabled: true
|
53
|
+
|
54
|
+
Layout/SpaceAfterNot:
|
55
|
+
Enabled: true
|
56
|
+
|
57
|
+
Layout/SpaceAfterSemicolon:
|
58
|
+
Enabled: true
|
59
|
+
|
60
|
+
Layout/SpaceAroundBlockParameters:
|
61
|
+
Enabled: true
|
62
|
+
|
63
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
64
|
+
Enabled: true
|
65
|
+
|
66
|
+
Layout/SpaceBeforeBlockBraces:
|
67
|
+
Enabled: true
|
68
|
+
|
69
|
+
Layout/SpaceInsideArrayLiteralBrackets:
|
70
|
+
Enabled: true
|
71
|
+
EnforcedStyle: no_space
|
72
|
+
|
73
|
+
Layout/SpaceInsideArrayPercentLiteral:
|
74
|
+
Enabled: true
|
75
|
+
|
76
|
+
Layout/SpaceInsideBlockBraces:
|
77
|
+
Enabled: true
|
78
|
+
|
79
|
+
Layout/SpaceInsideParens:
|
80
|
+
Enabled: true
|
81
|
+
|
82
|
+
Layout/SpaceInsideRangeLiteral:
|
83
|
+
Enabled: true
|
84
|
+
|
85
|
+
Layout/SpaceInsideReferenceBrackets:
|
86
|
+
Enabled: true
|
87
|
+
|
88
|
+
Layout/TrailingEmptyLines:
|
89
|
+
Enabled: true
|
90
|
+
|
91
|
+
Layout/TrailingWhitespace:
|
92
|
+
Enabled: true
|
93
|
+
|
94
|
+
Lint/CircularArgumentReference:
|
95
|
+
Enabled: true
|
96
|
+
|
97
|
+
Lint/Debugger:
|
98
|
+
Enabled: true
|
99
|
+
|
100
|
+
Lint/DeprecatedClassMethods:
|
101
|
+
Enabled: true
|
102
|
+
|
103
|
+
Lint/DuplicateMethods:
|
104
|
+
Enabled: true
|
105
|
+
|
106
|
+
Lint/DuplicateHashKey:
|
107
|
+
Enabled: true
|
108
|
+
|
109
|
+
Lint/EachWithObjectArgument:
|
110
|
+
Enabled: true
|
111
|
+
|
112
|
+
Lint/ElseLayout:
|
113
|
+
Enabled: true
|
114
|
+
|
115
|
+
Lint/EmptyEnsure:
|
116
|
+
Enabled: true
|
117
|
+
|
118
|
+
Lint/EmptyInterpolation:
|
119
|
+
Enabled: true
|
120
|
+
|
121
|
+
Lint/EnsureReturn:
|
122
|
+
Enabled: true
|
123
|
+
|
124
|
+
Lint/FlipFlop:
|
125
|
+
Enabled: true
|
126
|
+
|
127
|
+
Lint/FloatOutOfRange:
|
128
|
+
Enabled: true
|
129
|
+
|
130
|
+
Lint/FormatParameterMismatch:
|
131
|
+
Enabled: true
|
132
|
+
|
133
|
+
Lint/LiteralAsCondition:
|
134
|
+
Enabled: true
|
135
|
+
|
136
|
+
Lint/LiteralInInterpolation:
|
137
|
+
Enabled: true
|
138
|
+
|
139
|
+
Lint/Loop:
|
140
|
+
Enabled: true
|
141
|
+
|
142
|
+
Lint/NextWithoutAccumulator:
|
143
|
+
Enabled: true
|
144
|
+
|
145
|
+
Lint/RandOne:
|
146
|
+
Enabled: true
|
147
|
+
|
148
|
+
Lint/RequireParentheses:
|
149
|
+
Enabled: true
|
150
|
+
|
151
|
+
Lint/RescueException:
|
152
|
+
Enabled: true
|
153
|
+
|
154
|
+
Lint/RedundantStringCoercion:
|
155
|
+
Enabled: true
|
156
|
+
|
157
|
+
Lint/UnderscorePrefixedVariableName:
|
158
|
+
Enabled: true
|
159
|
+
|
160
|
+
Lint/RedundantCopDisableDirective:
|
161
|
+
Enabled: true
|
162
|
+
|
163
|
+
Lint/RedundantSplatExpansion:
|
164
|
+
Enabled: true
|
165
|
+
|
166
|
+
Lint/UnreachableCode:
|
167
|
+
Enabled: true
|
168
|
+
|
169
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
170
|
+
Enabled: true
|
171
|
+
|
172
|
+
Lint/UselessSetterCall:
|
173
|
+
Enabled: true
|
174
|
+
|
175
|
+
Lint/Void:
|
176
|
+
Enabled: true
|
177
|
+
|
178
|
+
Metrics/AbcSize:
|
179
|
+
Enabled: false
|
180
|
+
|
181
|
+
Metrics/BlockLength:
|
182
|
+
Enabled: false
|
183
|
+
|
184
|
+
Metrics/BlockNesting:
|
185
|
+
Enabled: false
|
186
|
+
|
187
|
+
Metrics/ClassLength:
|
188
|
+
Enabled: false
|
189
|
+
|
190
|
+
Metrics/CyclomaticComplexity:
|
191
|
+
Enabled: false
|
192
|
+
|
193
|
+
Metrics/MethodLength:
|
194
|
+
Enabled: false
|
195
|
+
|
196
|
+
Metrics/ModuleLength:
|
197
|
+
Enabled: false
|
198
|
+
|
199
|
+
Metrics/ParameterLists:
|
200
|
+
Enabled: false
|
201
|
+
|
202
|
+
Metrics/PerceivedComplexity:
|
203
|
+
Enabled: false
|
204
|
+
|
205
|
+
Naming/AsciiIdentifiers:
|
206
|
+
Enabled: true
|
207
|
+
|
208
|
+
Naming/ClassAndModuleCamelCase:
|
209
|
+
Enabled: true
|
210
|
+
|
211
|
+
Naming/FileName:
|
212
|
+
Enabled: true
|
213
|
+
|
214
|
+
Naming/MethodName:
|
215
|
+
Enabled: true
|
216
|
+
|
217
|
+
Performance/CaseWhenSplat:
|
218
|
+
Enabled: false
|
219
|
+
|
220
|
+
Performance/Count:
|
221
|
+
Enabled: true
|
222
|
+
|
223
|
+
Performance/Detect:
|
224
|
+
Enabled: true
|
225
|
+
|
226
|
+
Performance/DoubleStartEndWith:
|
227
|
+
Enabled: true
|
228
|
+
|
229
|
+
Performance/EndWith:
|
230
|
+
Enabled: true
|
231
|
+
|
232
|
+
Performance/FlatMap:
|
233
|
+
Enabled: true
|
234
|
+
|
235
|
+
Performance/RangeInclude:
|
236
|
+
Enabled: false
|
237
|
+
|
238
|
+
Performance/RedundantMatch:
|
239
|
+
Enabled: false
|
240
|
+
|
241
|
+
Performance/RedundantMerge:
|
242
|
+
Enabled: true
|
243
|
+
MaxKeyValuePairs: 1
|
244
|
+
|
245
|
+
Performance/ReverseEach:
|
246
|
+
Enabled: true
|
247
|
+
|
248
|
+
Performance/Size:
|
249
|
+
Enabled: true
|
250
|
+
|
251
|
+
Performance/StartWith:
|
252
|
+
Enabled: true
|
253
|
+
|
254
|
+
Security/Eval:
|
255
|
+
Enabled: true
|
256
|
+
|
257
|
+
Style/ArrayJoin:
|
258
|
+
Enabled: true
|
259
|
+
|
260
|
+
Style/BeginBlock:
|
261
|
+
Enabled: true
|
262
|
+
|
263
|
+
Style/BlockComments:
|
264
|
+
Enabled: true
|
265
|
+
|
266
|
+
Style/CaseEquality:
|
267
|
+
Enabled: true
|
268
|
+
|
269
|
+
Style/CharacterLiteral:
|
270
|
+
Enabled: true
|
271
|
+
|
272
|
+
Style/ClassMethods:
|
273
|
+
Enabled: true
|
274
|
+
|
275
|
+
Style/Copyright:
|
276
|
+
Enabled: false
|
277
|
+
|
278
|
+
Style/DefWithParentheses:
|
279
|
+
Enabled: true
|
280
|
+
|
281
|
+
Style/EndBlock:
|
282
|
+
Enabled: true
|
283
|
+
|
284
|
+
Style/For:
|
285
|
+
Enabled: true
|
286
|
+
|
287
|
+
Style/FrozenStringLiteralComment:
|
288
|
+
Enabled: true
|
289
|
+
|
290
|
+
Style/HashSyntax:
|
291
|
+
Enabled: true
|
292
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
293
|
+
|
294
|
+
Style/LambdaCall:
|
295
|
+
Enabled: true
|
296
|
+
|
297
|
+
Style/MethodCallWithoutArgsParentheses:
|
298
|
+
Enabled: true
|
299
|
+
|
300
|
+
Style/MethodDefParentheses:
|
301
|
+
Enabled: true
|
302
|
+
|
303
|
+
Style/MultilineIfThen:
|
304
|
+
Enabled: true
|
305
|
+
|
306
|
+
Style/NilComparison:
|
307
|
+
Enabled: true
|
308
|
+
|
309
|
+
Style/Not:
|
310
|
+
Enabled: true
|
311
|
+
|
312
|
+
Style/OneLineConditional:
|
313
|
+
Enabled: true
|
314
|
+
|
315
|
+
Style/RedundantSortBy:
|
316
|
+
Enabled: true
|
317
|
+
|
318
|
+
Style/Sample:
|
319
|
+
Enabled: true
|
320
|
+
|
321
|
+
Style/StabbyLambdaParentheses:
|
322
|
+
Enabled: true
|
323
|
+
|
324
|
+
Style/Strip:
|
325
|
+
Enabled: true
|
326
|
+
|
327
|
+
Style/StringLiterals:
|
328
|
+
Enabled: true
|
329
|
+
EnforcedStyle: double_quotes
|