rubocop-github 0.26.0 → 0.28.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 +4 -4
- data/STYLEGUIDE.md +50 -23
- data/config/default.yml +39 -4
- data/config/default_cops.yml +4 -0
- data/config/default_pending.yml +84 -0
- data/config/rails_pending.yml +12 -0
- data/lib/rubocop/cop/github/rails_view_render_literal.rb +3 -0
- data/lib/rubocop/cop/github/unreliable_subclasses.rb +48 -0
- data/lib/rubocop-github.rb +1 -0
- data/lib/version.rb +1 -1
- metadata +10 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 85257a3c793f7ca693d8ef2f85c669195d104754b3badbd4f7079ee2c1c1ddfa
|
|
4
|
+
data.tar.gz: 122d57805c2f7b00ef10d26d65cc8e2d2e9347d9079cc8505969739f3393ab44
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 604bbfb3f9a7c1db7ff43263cfc5cb63a16887ebfaf9657edb1a92e3a8274846aeae09437285a11412395833ea9b3b9c120ee01c1f38e90f70832cd1ca0aef21
|
|
7
|
+
data.tar.gz: c31d203509da54b381c9d52f85980406620e711b13880dced839308fff4abd750b87e1a0e9d242c4c68f25521abd3d0d414b1c5caa0965e25d18f6cc61d6fb55
|
data/STYLEGUIDE.md
CHANGED
|
@@ -31,6 +31,8 @@ This is GitHub's Ruby Style Guide, inspired by [RuboCop's guide][rubocop-guide].
|
|
|
31
31
|
18. [Rails](#rails)
|
|
32
32
|
1. [content_for](#content_for)
|
|
33
33
|
2. [Instance Variables in Views](#instance-variables-in-views)
|
|
34
|
+
19. [Subclasses](#subclasses)
|
|
35
|
+
1. [Avoid Class#descendants and Class#subclasses](#avoid-classdescendants-and-classsubclasses)
|
|
34
36
|
|
|
35
37
|
## Layout
|
|
36
38
|
|
|
@@ -236,7 +238,7 @@ end
|
|
|
236
238
|
|
|
237
239
|
* Indent the `public`, `protected`, and `private` methods as much the
|
|
238
240
|
method definitions they apply to. Leave one blank line above them.
|
|
239
|
-
<a name="access-modifier-
|
|
241
|
+
<a name="access-modifier-indentation"></a><sup>[[link](#access-modifier-indentation)]</sup>
|
|
240
242
|
* <a href="https://docs.rubocop.org/rubocop/cops_layout.html#layoutaccessmodifierindentation">RuboCop rule: Layout/AccessModifierIndentation</a>
|
|
241
243
|
* <a href="https://docs.rubocop.org/rubocop/cops_layout.html#layoutemptylinesaroundaccessmodifier">RuboCop rule: Layout/EmptyLinesAroundAccessModifier</a>
|
|
242
244
|
|
|
@@ -476,7 +478,7 @@ remove_member(user, skip_membership_check: true)
|
|
|
476
478
|
|
|
477
479
|
* Use `snake_case` for methods and variables.
|
|
478
480
|
<a name="snake-case-methods-vars"></a><sup>[[link](#snake-case-methods-vars)]</sup>
|
|
479
|
-
* <a href="https://docs.rubocop.org/rubocop/cops_naming.html#
|
|
481
|
+
* <a href="https://docs.rubocop.org/rubocop/cops_naming.html#namingmethodname">RuboCop rule: Naming/MethodName</a>
|
|
480
482
|
* <a href="https://docs.rubocop.org/rubocop/cops_naming.html#namingvariablename">RuboCop rule: Naming/VariableName</a>
|
|
481
483
|
|
|
482
484
|
* Use `CamelCase` for classes and modules. (Keep acronyms like HTTP,
|
|
@@ -491,7 +493,7 @@ remove_member(user, skip_membership_check: true)
|
|
|
491
493
|
* The names of predicate methods (methods that return a boolean value)
|
|
492
494
|
should end in a question mark. (i.e. `Array#empty?`).
|
|
493
495
|
<a name="bool-methods-qmark"></a><sup>[[link](#bool-methods-qmark)]</sup>
|
|
494
|
-
* <a href="https://docs.rubocop.org/rubocop/cops_naming.html#
|
|
496
|
+
* <a href="https://docs.rubocop.org/rubocop/cops_naming.html#namingpredicateprefix">RuboCop rule: Naming/PredicatePrefix</a>
|
|
495
497
|
|
|
496
498
|
* The names of potentially "dangerous" methods (i.e. methods that modify `self` or the
|
|
497
499
|
arguments, `exit!`, etc.) should end with an exclamation mark. Bang methods
|
|
@@ -716,7 +718,7 @@ end
|
|
|
716
718
|
* Favor modifier `if/unless` usage when you have a single-line
|
|
717
719
|
body.
|
|
718
720
|
<a name="favor-modifier-if-unless"></a><sup>[[link](#favor-modifier-if-unless)]</sup>
|
|
719
|
-
* <a href="https://docs.rubocop.org/rubocop/cops_style.html#
|
|
721
|
+
* <a href="https://docs.rubocop.org/rubocop/cops_style.html#styleifunlessmodifier">RuboCop rule: Style/IfUnlessModifier</a>
|
|
720
722
|
|
|
721
723
|
``` ruby
|
|
722
724
|
# bad
|
|
@@ -786,7 +788,7 @@ end
|
|
|
786
788
|
trivial. However, do use the ternary operator(`?:`) over `if/then/else/end` constructs
|
|
787
789
|
for single line conditionals.
|
|
788
790
|
<a name="trivial-ternary"></a><sup>[[link](#trivial-ternary)]</sup>
|
|
789
|
-
* <a href="https://docs.rubocop.org/rubocop/cops_style.html#
|
|
791
|
+
* <a href="https://docs.rubocop.org/rubocop/cops_style.html#styleonelineconditional">RuboCop rule: Style/OneLineConditional</a>
|
|
790
792
|
|
|
791
793
|
``` ruby
|
|
792
794
|
# bad
|
|
@@ -840,11 +842,9 @@ end
|
|
|
840
842
|
arr.each { |elem| puts elem }
|
|
841
843
|
```
|
|
842
844
|
|
|
843
|
-
* Prefer `{...}` over `do...end` for single-line blocks.
|
|
844
|
-
`{...}` for multi-line blocks
|
|
845
|
-
|
|
846
|
-
definitions" (e.g. in Rakefiles and certain DSLs). Avoid `do...end`
|
|
847
|
-
when chaining.
|
|
845
|
+
* Prefer `{...}` over `do...end` for single-line blocks. Avoid using
|
|
846
|
+
`{...}` for multi-line blocks. Always use `do...end` for "control flow" and "method
|
|
847
|
+
definitions" (e.g. in Rakefiles and certain DSLs).
|
|
848
848
|
<a name="squiggly-braces"></a><sup>[[link](#squiggly-braces)]</sup>
|
|
849
849
|
* <a href="https://docs.rubocop.org/rubocop/cops_style.html#styleblockdelimiters">RuboCop rule: Style/BlockDelimiters</a>
|
|
850
850
|
|
|
@@ -858,20 +858,8 @@ names.each { |name| puts name }
|
|
|
858
858
|
names.each do |name|
|
|
859
859
|
puts name
|
|
860
860
|
end
|
|
861
|
-
|
|
862
|
-
# good
|
|
863
|
-
names.select { |name| name.start_with?("S") }.map { |name| name.upcase }
|
|
864
|
-
|
|
865
|
-
# bad
|
|
866
|
-
names.select do |name|
|
|
867
|
-
name.start_with?("S")
|
|
868
|
-
end.map { |name| name.upcase }
|
|
869
861
|
```
|
|
870
862
|
|
|
871
|
-
* Some will argue that multiline chaining would look OK with the use of `{...}`,
|
|
872
|
-
but they should ask themselves: is this code really readable and can't the block's
|
|
873
|
-
contents be extracted into nifty methods?
|
|
874
|
-
|
|
875
863
|
* Avoid `return` where not required.
|
|
876
864
|
<a name="avoid-return"></a><sup>[[link](#avoid-return)]</sup>
|
|
877
865
|
* <a href="https://docs.rubocop.org/rubocop/cops_style.html#styleredundantreturn">RuboCop rule: Style/RedundantReturn</a>
|
|
@@ -890,7 +878,7 @@ end
|
|
|
890
878
|
|
|
891
879
|
* Use spaces around the `=` operator when assigning default values to method parameters:
|
|
892
880
|
<a name="spaces-around-equals"></a><sup>[[link](#spaces-around-equals)]</sup>
|
|
893
|
-
* <a href="https://docs.rubocop.org/rubocop/
|
|
881
|
+
* <a href="https://docs.rubocop.org/rubocop/cops_layout.html#layoutspacearoundequalsinparameterdefault">RuboCop rule: Layout/SpaceAroundEqualsInParameterDefault</a>
|
|
894
882
|
|
|
895
883
|
``` ruby
|
|
896
884
|
# bad
|
|
@@ -1096,4 +1084,43 @@ If you need to call a subview that expects an instance variable be set. If possi
|
|
|
1096
1084
|
|
|
1097
1085
|
Unfortunately the only way to get data into a layout template is with instance variables. You can't explicitly pass locals to them.
|
|
1098
1086
|
|
|
1087
|
+
## Subclasses
|
|
1088
|
+
|
|
1089
|
+
### Avoid `Class#descendants` and `Class#subclasses`
|
|
1090
|
+
|
|
1091
|
+
Skip `Class#descendants` (ActiveSupport) and `Class#subclasses` (Ruby). They might lie to you in two ways:
|
|
1092
|
+
|
|
1093
|
+
* If a class hasn't been autoloaded yet, they don't see it. So your answer depends on what the app happened to touch first.
|
|
1094
|
+
* GC can drop dynamically defined classes whenever it feels like it. Tests love this one.
|
|
1095
|
+
|
|
1096
|
+
If you really, really need it, add a `rubocop:disable` on the line with a short note so that future-you isn't confused.
|
|
1097
|
+
|
|
1098
|
+
* <a href="https://github.com/github/rubocop-github/blob/main/lib/rubocop/cop/github/unreliable_subclasses.rb">RuboCop rule: GitHub/UnreliableSubclasses</a>
|
|
1099
|
+
|
|
1100
|
+
``` ruby
|
|
1101
|
+
class Person < ApplicationRecord
|
|
1102
|
+
end
|
|
1103
|
+
|
|
1104
|
+
class Employee < Person
|
|
1105
|
+
end
|
|
1106
|
+
|
|
1107
|
+
# bad
|
|
1108
|
+
Person.descendants # => maybe [Employee], maybe [], who knows? Not me! I never lost control.
|
|
1109
|
+
Person.subclasses # => same problem
|
|
1110
|
+
|
|
1111
|
+
# good. Keep an explicit registry
|
|
1112
|
+
class Person < ApplicationRecord
|
|
1113
|
+
TYPES = []
|
|
1114
|
+
|
|
1115
|
+
def self.inherited(subclass)
|
|
1116
|
+
super
|
|
1117
|
+
TYPES << subclass
|
|
1118
|
+
end
|
|
1119
|
+
end
|
|
1120
|
+
|
|
1121
|
+
Person::TYPES # => [Employee, ...]
|
|
1122
|
+
```
|
|
1123
|
+
|
|
1124
|
+
Other alternatives: eager load the dependency tree ([`Rails.application.eager_load!`](https://api.rubyonrails.org/classes/Rails/Application.html#method-i-eager_load-21) in tests, `config.eager_load = true` in prod) or use [`ActiveSupport::DescendantsTracker`](https://api.rubyonrails.org/classes/ActiveSupport/DescendantsTracker.html) directly if you really need the reflection.
|
|
1125
|
+
|
|
1099
1126
|
[rubocop-guide]: https://github.com/rubocop-hq/ruby-style-guide
|
data/config/default.yml
CHANGED
|
@@ -53,8 +53,13 @@ GitHub/AvoidObjectSendWithDynamicMethod:
|
|
|
53
53
|
GitHub/InsecureHashAlgorithm:
|
|
54
54
|
Enabled: true
|
|
55
55
|
|
|
56
|
+
GitHub/UnreliableSubclasses:
|
|
57
|
+
Enabled: true
|
|
58
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#avoid-classdescendants-and-classsubclasses
|
|
59
|
+
|
|
56
60
|
Layout/AccessModifierIndentation:
|
|
57
61
|
Enabled: false
|
|
62
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#user-content-access-modifier-indentation
|
|
58
63
|
|
|
59
64
|
Layout/ArgumentAlignment:
|
|
60
65
|
Enabled: false
|
|
@@ -117,12 +122,14 @@ Layout/EmptyLineAfterMultilineCondition:
|
|
|
117
122
|
|
|
118
123
|
Layout/EmptyLineBetweenDefs:
|
|
119
124
|
Enabled: false
|
|
125
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#empty-lines-def
|
|
120
126
|
|
|
121
127
|
Layout/EmptyLines:
|
|
122
128
|
Enabled: false
|
|
123
129
|
|
|
124
130
|
Layout/EmptyLinesAroundAccessModifier:
|
|
125
131
|
Enabled: false
|
|
132
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#access-modifier-indentation
|
|
126
133
|
|
|
127
134
|
Layout/EmptyLinesAroundArguments:
|
|
128
135
|
Enabled: false
|
|
@@ -280,6 +287,7 @@ Layout/SpaceAfterMethodName:
|
|
|
280
287
|
|
|
281
288
|
Layout/SpaceAfterNot:
|
|
282
289
|
Enabled: true
|
|
290
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#no-spaces-bang
|
|
283
291
|
|
|
284
292
|
Layout/SpaceAfterSemicolon:
|
|
285
293
|
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#spaces-operators
|
|
@@ -304,6 +312,7 @@ Layout/SpaceAroundOperators:
|
|
|
304
312
|
|
|
305
313
|
Layout/SpaceBeforeBlockBraces:
|
|
306
314
|
Enabled: true
|
|
315
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#spaces-operators
|
|
307
316
|
|
|
308
317
|
Layout/SpaceBeforeBrackets:
|
|
309
318
|
Enabled: false
|
|
@@ -339,6 +348,7 @@ Layout/SpaceInsideHashLiteralBraces:
|
|
|
339
348
|
|
|
340
349
|
Layout/SpaceInsideParens:
|
|
341
350
|
Enabled: true
|
|
351
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#no-spaces-braces
|
|
342
352
|
|
|
343
353
|
Layout/SpaceInsidePercentLiteralDelimiters:
|
|
344
354
|
Enabled: false
|
|
@@ -348,12 +358,14 @@ Layout/SpaceInsideRangeLiteral:
|
|
|
348
358
|
|
|
349
359
|
Layout/SpaceInsideReferenceBrackets:
|
|
350
360
|
Enabled: true
|
|
361
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#no-spaces-braces
|
|
351
362
|
|
|
352
363
|
Layout/SpaceInsideStringInterpolation:
|
|
353
364
|
Enabled: false
|
|
354
365
|
|
|
355
366
|
Layout/TrailingEmptyLines:
|
|
356
367
|
Enabled: true
|
|
368
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#newlines
|
|
357
369
|
|
|
358
370
|
Layout/TrailingWhitespace:
|
|
359
371
|
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#trailing-whitespace
|
|
@@ -400,6 +412,9 @@ Lint/ConstantOverwrittenInRescue:
|
|
|
400
412
|
Lint/ConstantResolution:
|
|
401
413
|
Enabled: false
|
|
402
414
|
|
|
415
|
+
Lint/CopDirectiveSyntax:
|
|
416
|
+
Enabled: false
|
|
417
|
+
|
|
403
418
|
Lint/Debugger:
|
|
404
419
|
Enabled: true
|
|
405
420
|
|
|
@@ -531,6 +546,7 @@ Lint/MissingSuper:
|
|
|
531
546
|
|
|
532
547
|
Lint/MixedRegexpCaptureTypes:
|
|
533
548
|
Enabled: false
|
|
549
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#capture-with-named-groups
|
|
534
550
|
|
|
535
551
|
Lint/MultipleComparison:
|
|
536
552
|
Enabled: false
|
|
@@ -793,9 +809,11 @@ Naming/BlockParameterName:
|
|
|
793
809
|
|
|
794
810
|
Naming/ClassAndModuleCamelCase:
|
|
795
811
|
Enabled: true
|
|
812
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#naming
|
|
796
813
|
|
|
797
814
|
Naming/ConstantName:
|
|
798
815
|
Enabled: false
|
|
816
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#naming
|
|
799
817
|
|
|
800
818
|
Naming/FileName:
|
|
801
819
|
Enabled: true
|
|
@@ -814,18 +832,21 @@ Naming/MemoizedInstanceVariableName:
|
|
|
814
832
|
|
|
815
833
|
Naming/MethodName:
|
|
816
834
|
Enabled: true
|
|
835
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#snake-case-methods-vars
|
|
817
836
|
|
|
818
837
|
Naming/MethodParameterName:
|
|
819
838
|
Enabled: false
|
|
820
839
|
|
|
821
840
|
Naming/PredicatePrefix:
|
|
822
841
|
Enabled: false
|
|
842
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#bool-methods-qmark
|
|
823
843
|
|
|
824
844
|
Naming/RescuedExceptionsVariableName:
|
|
825
845
|
Enabled: false
|
|
826
846
|
|
|
827
847
|
Naming/VariableName:
|
|
828
848
|
Enabled: false
|
|
849
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#naming
|
|
829
850
|
|
|
830
851
|
Naming/VariableNumber:
|
|
831
852
|
Enabled: false
|
|
@@ -1032,6 +1053,7 @@ Style/AutoResourceCleanup:
|
|
|
1032
1053
|
|
|
1033
1054
|
Style/BarePercentLiterals:
|
|
1034
1055
|
Enabled: false
|
|
1056
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#percent-literals
|
|
1035
1057
|
|
|
1036
1058
|
Style/BeginBlock:
|
|
1037
1059
|
Enabled: true
|
|
@@ -1044,10 +1066,11 @@ Style/BlockComments:
|
|
|
1044
1066
|
|
|
1045
1067
|
Style/BlockDelimiters:
|
|
1046
1068
|
Enabled: false
|
|
1069
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#syntax
|
|
1047
1070
|
|
|
1048
1071
|
Style/CaseEquality:
|
|
1049
1072
|
Enabled: true
|
|
1050
|
-
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#type-checking-is-a-kind-of
|
|
1073
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#user-content-type-checking-is-a-kind-of
|
|
1051
1074
|
|
|
1052
1075
|
Style/CaseLikeIf:
|
|
1053
1076
|
Enabled: false
|
|
@@ -1129,9 +1152,6 @@ Style/Documentation:
|
|
|
1129
1152
|
Style/DocumentationMethod:
|
|
1130
1153
|
Enabled: false
|
|
1131
1154
|
|
|
1132
|
-
Style/DoubleCopDisableDirective:
|
|
1133
|
-
Enabled: false
|
|
1134
|
-
|
|
1135
1155
|
Style/DoubleNegation:
|
|
1136
1156
|
Enabled: false
|
|
1137
1157
|
|
|
@@ -1255,6 +1275,7 @@ Style/IfInsideElse:
|
|
|
1255
1275
|
|
|
1256
1276
|
Style/IfUnlessModifier:
|
|
1257
1277
|
Enabled: false
|
|
1278
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#favor-modifier-if-unless
|
|
1258
1279
|
|
|
1259
1280
|
Style/IfUnlessModifierOfIfUnless:
|
|
1260
1281
|
Enabled: false
|
|
@@ -1306,6 +1327,7 @@ Style/MapToHash:
|
|
|
1306
1327
|
|
|
1307
1328
|
Style/MethodCallWithArgsParentheses:
|
|
1308
1329
|
Enabled: false
|
|
1330
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#parens-no-spaces
|
|
1309
1331
|
|
|
1310
1332
|
Style/MethodCallWithoutArgsParentheses:
|
|
1311
1333
|
Enabled: true
|
|
@@ -1354,6 +1376,7 @@ Style/MultilineMethodSignature:
|
|
|
1354
1376
|
|
|
1355
1377
|
Style/MultilineTernaryOperator:
|
|
1356
1378
|
Enabled: false
|
|
1379
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#no-multiline-ternary
|
|
1357
1380
|
|
|
1358
1381
|
Style/MultilineWhenThen:
|
|
1359
1382
|
Enabled: false
|
|
@@ -1372,6 +1395,7 @@ Style/NegatedIfElseCondition:
|
|
|
1372
1395
|
|
|
1373
1396
|
Style/NegatedUnless:
|
|
1374
1397
|
Enabled: true
|
|
1398
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#user-content-no-unless-negation
|
|
1375
1399
|
|
|
1376
1400
|
Style/NegatedWhile:
|
|
1377
1401
|
Enabled: false
|
|
@@ -1426,6 +1450,7 @@ Style/ObjectThen:
|
|
|
1426
1450
|
|
|
1427
1451
|
Style/OneLineConditional:
|
|
1428
1452
|
Enabled: true
|
|
1453
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#trivial-ternary
|
|
1429
1454
|
|
|
1430
1455
|
Style/OpenStructUse:
|
|
1431
1456
|
Enabled: false
|
|
@@ -1438,6 +1463,7 @@ Style/OptionalArguments:
|
|
|
1438
1463
|
|
|
1439
1464
|
Style/OptionalBooleanParameter:
|
|
1440
1465
|
Enabled: false
|
|
1466
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#keyword-arguments
|
|
1441
1467
|
|
|
1442
1468
|
Style/OrAssignment:
|
|
1443
1469
|
Enabled: true
|
|
@@ -1450,6 +1476,7 @@ Style/ParallelAssignment:
|
|
|
1450
1476
|
|
|
1451
1477
|
Style/ParenthesesAroundCondition:
|
|
1452
1478
|
Enabled: false
|
|
1479
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#no-parens-if-unless-while
|
|
1453
1480
|
|
|
1454
1481
|
Style/PercentLiteralDelimiters:
|
|
1455
1482
|
Enabled: false
|
|
@@ -1530,6 +1557,7 @@ Style/RedundantReturn:
|
|
|
1530
1557
|
|
|
1531
1558
|
Style/RedundantSelf:
|
|
1532
1559
|
Enabled: false
|
|
1560
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#self-messages
|
|
1533
1561
|
|
|
1534
1562
|
Style/RedundantSelfAssignment:
|
|
1535
1563
|
Enabled: false
|
|
@@ -1545,6 +1573,7 @@ Style/RedundantSortBy:
|
|
|
1545
1573
|
|
|
1546
1574
|
Style/RegexpLiteral:
|
|
1547
1575
|
Enabled: false
|
|
1576
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#percent-r-regular-expressions
|
|
1548
1577
|
|
|
1549
1578
|
Style/RescueModifier:
|
|
1550
1579
|
Enabled: false
|
|
@@ -1572,6 +1601,7 @@ Style/Semicolon:
|
|
|
1572
1601
|
|
|
1573
1602
|
Style/Send:
|
|
1574
1603
|
Enabled: false
|
|
1604
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#avoid-send
|
|
1575
1605
|
|
|
1576
1606
|
Style/SignalException:
|
|
1577
1607
|
Enabled: false
|
|
@@ -1593,6 +1623,7 @@ Style/SoleNestedConditional:
|
|
|
1593
1623
|
|
|
1594
1624
|
Style/SpecialGlobalVars:
|
|
1595
1625
|
Enabled: false
|
|
1626
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#no-cryptic-vars
|
|
1596
1627
|
|
|
1597
1628
|
Style/StabbyLambdaParentheses:
|
|
1598
1629
|
Enabled: true
|
|
@@ -1608,9 +1639,11 @@ Style/StringChars:
|
|
|
1608
1639
|
|
|
1609
1640
|
Style/StringConcatenation:
|
|
1610
1641
|
Enabled: false
|
|
1642
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#string-interpolation
|
|
1611
1643
|
|
|
1612
1644
|
Style/StringHashKeys:
|
|
1613
1645
|
Enabled: false
|
|
1646
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#symbols-as-keys
|
|
1614
1647
|
|
|
1615
1648
|
Style/StringLiterals:
|
|
1616
1649
|
EnforcedStyle: double_quotes
|
|
@@ -1699,8 +1732,10 @@ Style/WhileUntilDo:
|
|
|
1699
1732
|
Style/WhileUntilModifier:
|
|
1700
1733
|
Enabled: false
|
|
1701
1734
|
|
|
1735
|
+
# TODO: Enable this since it's in the styleguide.
|
|
1702
1736
|
Style/WordArray:
|
|
1703
1737
|
Enabled: false
|
|
1738
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#percent-w
|
|
1704
1739
|
|
|
1705
1740
|
Style/YodaCondition:
|
|
1706
1741
|
Enabled: false
|
data/config/default_cops.yml
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
GitHub/InsecureHashAlgorithm:
|
|
2
2
|
Description: 'Encourage usage of secure hash algorithms'
|
|
3
3
|
Enabled: pending
|
|
4
|
+
|
|
5
|
+
GitHub/UnreliableSubclasses:
|
|
6
|
+
Description: "Avoid `Class#subclasses` and `Class#descendants`; they miss not-yet-autoloaded classes and depend on GC timing."
|
|
7
|
+
Enabled: pending
|
data/config/default_pending.yml
CHANGED
|
@@ -112,5 +112,89 @@ Style/SendWithLiteralMethodName: # new in 1.64
|
|
|
112
112
|
Enabled: false
|
|
113
113
|
Style/SuperArguments: # new in 1.64
|
|
114
114
|
Enabled: false
|
|
115
|
+
Gemspec/AttributeAssignment: # new in 1.77
|
|
116
|
+
Enabled: true
|
|
117
|
+
Layout/EmptyLinesAfterModuleInclusion: # new in 1.79
|
|
118
|
+
Enabled: true
|
|
119
|
+
Lint/ArgumentMismatch: # new in 1.90
|
|
120
|
+
Enabled: true
|
|
121
|
+
Lint/ArrayLiteralInRegexp: # new in 1.71
|
|
122
|
+
Enabled: true
|
|
123
|
+
Lint/DataDefineOverride: # new in 1.85
|
|
124
|
+
Enabled: true
|
|
125
|
+
Lint/DeprecatedReference: # new in 1.89
|
|
126
|
+
Enabled: true
|
|
127
|
+
Lint/MisplacedMagicComment: # new in 1.91
|
|
128
|
+
Enabled: true
|
|
129
|
+
Lint/NameTypo: # new in 1.89
|
|
130
|
+
Enabled: true
|
|
131
|
+
Lint/RedundantTypeConversion: # new in 1.72
|
|
132
|
+
Enabled: true
|
|
133
|
+
Lint/SuperArgumentMismatch: # new in 1.90
|
|
134
|
+
Enabled: true
|
|
135
|
+
Lint/SuppressedExceptionInNumberConversion: # new in 1.72
|
|
136
|
+
Enabled: true
|
|
137
|
+
Lint/UnreachablePatternBranch: # new in 1.85
|
|
138
|
+
Enabled: true
|
|
139
|
+
Lint/UselessConstantScoping: # new in 1.72
|
|
140
|
+
Enabled: true
|
|
141
|
+
Lint/UselessDefaultValueArgument: # new in 1.76
|
|
142
|
+
Enabled: true
|
|
143
|
+
Lint/UselessOr: # new in 1.76
|
|
144
|
+
Enabled: true
|
|
145
|
+
Naming/PredicateMethod: # new in 1.76
|
|
146
|
+
Enabled: true
|
|
147
|
+
Style/ArrayIntersectWithSingleElement: # new in 1.81
|
|
148
|
+
Enabled: true
|
|
149
|
+
Style/CollectionQuerying: # new in 1.77
|
|
150
|
+
Enabled: true
|
|
151
|
+
Style/ComparableBetween: # new in 1.74
|
|
152
|
+
Enabled: true
|
|
153
|
+
Style/DirectiveScope: # new in 1.90
|
|
154
|
+
Enabled: true
|
|
155
|
+
Style/EmptyClassDefinition: # new in 1.84
|
|
156
|
+
Enabled: true
|
|
157
|
+
Style/EmptyStringInsideInterpolation: # new in 1.76
|
|
158
|
+
Enabled: true
|
|
159
|
+
Style/FileOpen: # new in 1.85
|
|
160
|
+
Enabled: true
|
|
161
|
+
Style/HashFetchChain: # new in 1.75
|
|
162
|
+
Enabled: true
|
|
163
|
+
Style/HashSlice: # new in 1.71
|
|
164
|
+
Enabled: true
|
|
165
|
+
Style/ItBlockParameter: # new in 1.75
|
|
166
|
+
Enabled: true
|
|
167
|
+
Style/MapJoin: # new in 1.85
|
|
168
|
+
Enabled: true
|
|
169
|
+
Style/ModuleMemberExistenceCheck: # new in 1.82
|
|
170
|
+
Enabled: true
|
|
171
|
+
Style/NegativeArrayIndex: # new in 1.84
|
|
172
|
+
Enabled: true
|
|
173
|
+
Style/OneClassPerFile: # new in 1.85
|
|
174
|
+
Enabled: true
|
|
175
|
+
Style/PartitionInsteadOfDoubleSelect: # new in 1.85
|
|
176
|
+
Enabled: true
|
|
177
|
+
Style/PredicateWithKind: # new in 1.85
|
|
178
|
+
Enabled: true
|
|
179
|
+
Style/ReduceToHash: # new in 1.85
|
|
180
|
+
Enabled: true
|
|
181
|
+
Style/RedundantArrayFlatten: # new in 1.76
|
|
182
|
+
Enabled: true
|
|
183
|
+
Style/RedundantFormat: # new in 1.72
|
|
184
|
+
Enabled: true
|
|
185
|
+
Style/RedundantMinMaxBy: # new in 1.85
|
|
186
|
+
Enabled: true
|
|
187
|
+
Style/ReverseFind: # new in 1.84
|
|
188
|
+
Enabled: true
|
|
189
|
+
Style/SelectByKind: # new in 1.85
|
|
190
|
+
Enabled: true
|
|
191
|
+
Style/SelectByRange: # new in 1.85
|
|
192
|
+
Enabled: true
|
|
193
|
+
Style/TallyMethod: # new in 1.85
|
|
194
|
+
Enabled: true
|
|
195
|
+
Style/TimeNow: # new in 1.90
|
|
196
|
+
Enabled: true
|
|
115
197
|
Performance/StringBytesize: # new in 1.23
|
|
116
198
|
Enabled: false
|
|
199
|
+
Performance/ZipWithoutBlock: # new in 1.24
|
|
200
|
+
Enabled: true
|
data/config/rails_pending.yml
CHANGED
|
@@ -100,3 +100,15 @@ Rails/EnumSyntax: # new in 2.26
|
|
|
100
100
|
Enabled: false
|
|
101
101
|
Rails/WhereRange: # new in 2.25
|
|
102
102
|
Enabled: false
|
|
103
|
+
Rails/FindByOrAssignmentMemoization: # new in 2.33
|
|
104
|
+
Enabled: true
|
|
105
|
+
Rails/HttpStatusNameConsistency: # new in 2.34
|
|
106
|
+
Enabled: true
|
|
107
|
+
Rails/MultipleRoutePaths: # new in 2.29
|
|
108
|
+
Enabled: true
|
|
109
|
+
Rails/OrderArguments: # new in 2.33
|
|
110
|
+
Enabled: true
|
|
111
|
+
Rails/RedirectBackOrTo: # new in 2.34
|
|
112
|
+
Enabled: true
|
|
113
|
+
Rails/StrongParametersExpect: # new in 2.29
|
|
114
|
+
Enabled: true
|
|
@@ -52,7 +52,10 @@ module RuboCop
|
|
|
52
52
|
return
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
# `many?` is an ActiveSupport extension, but this cop runs without ActiveSupport.
|
|
56
|
+
# rubocop:disable Style/CollectionQuerying
|
|
55
57
|
if render_literal?(node) && node.arguments.count > 1
|
|
58
|
+
# rubocop:enable Style/CollectionQuerying
|
|
56
59
|
locals = node.arguments[1]
|
|
57
60
|
elsif option_pairs = render_with_options?(node)
|
|
58
61
|
locals = option_pairs.map { |pair| locals_key?(pair) }.compact.first
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rubocop"
|
|
4
|
+
|
|
5
|
+
module RuboCop
|
|
6
|
+
module Cop
|
|
7
|
+
module GitHub
|
|
8
|
+
# Inform people when they reach for Class#subclasses (Ruby) or
|
|
9
|
+
# Class#descendants (ActiveSupport).
|
|
10
|
+
#
|
|
11
|
+
# two reasons these can be unreliable:
|
|
12
|
+
# 1. autoload hasn't run yet, so half the tree is invisible
|
|
13
|
+
# 2. GC may have eaten dynamically-defined classes (i.e. in test suites)
|
|
14
|
+
#
|
|
15
|
+
# If you really need it, add a rubocop:disable on the line with a note
|
|
16
|
+
# explaining why future-you won't be sad.
|
|
17
|
+
class UnreliableSubclasses < Base
|
|
18
|
+
MSG = "Avoid `%<method>s` here. It may miss not-yet-autoloaded classes and depends on GC timing. " \
|
|
19
|
+
"Prefer an explicit registry or eager loading."
|
|
20
|
+
|
|
21
|
+
RESTRICT_ON_SEND = %i[descendants subclasses].freeze
|
|
22
|
+
|
|
23
|
+
# matches Foo.descendants, Foo::Bar.subclasses, self.descendants
|
|
24
|
+
# receiver has to be a constant or `self`
|
|
25
|
+
def_node_matcher :unreliable_call?, <<~PATTERN
|
|
26
|
+
(send {const self} {:descendants :subclasses})
|
|
27
|
+
PATTERN
|
|
28
|
+
|
|
29
|
+
# the same thing but with safe navigation operator
|
|
30
|
+
def_node_matcher :unreliable_csend?, <<~PATTERN
|
|
31
|
+
(csend {const self} {:descendants :subclasses})
|
|
32
|
+
PATTERN
|
|
33
|
+
|
|
34
|
+
def on_send(node)
|
|
35
|
+
return unless unreliable_call?(node)
|
|
36
|
+
|
|
37
|
+
add_offense(node, message: format(MSG, method: node.method_name))
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def on_csend(node)
|
|
41
|
+
return unless unreliable_csend?(node)
|
|
42
|
+
|
|
43
|
+
add_offense(node, message: format(MSG, method: node.method_name))
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/rubocop-github.rb
CHANGED
data/lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-github
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.28.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GitHub
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-09-30 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rubocop
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '1.
|
|
18
|
+
version: '1.91'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '1.
|
|
25
|
+
version: '1.91'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: rubocop-performance
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -43,28 +43,28 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '2.
|
|
46
|
+
version: '2.34'
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '2.
|
|
53
|
+
version: '2.34'
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: actionview
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version:
|
|
60
|
+
version: 8.1.3
|
|
61
61
|
type: :development
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version:
|
|
67
|
+
version: 8.1.3
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
69
|
name: minitest
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -124,6 +124,7 @@ files:
|
|
|
124
124
|
- lib/rubocop/cop/github/rails_view_render_paths_exist.rb
|
|
125
125
|
- lib/rubocop/cop/github/rails_view_render_shorthand.rb
|
|
126
126
|
- lib/rubocop/cop/github/render_literal_helpers.rb
|
|
127
|
+
- lib/rubocop/cop/github/unreliable_subclasses.rb
|
|
127
128
|
- lib/rubocop/github.rb
|
|
128
129
|
- lib/rubocop/github/inject.rb
|
|
129
130
|
- lib/version.rb
|
|
@@ -141,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
141
142
|
requirements:
|
|
142
143
|
- - ">="
|
|
143
144
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: 3.
|
|
145
|
+
version: 3.4.2
|
|
145
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
147
|
requirements:
|
|
147
148
|
- - ">="
|