rubocop-github 0.27.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 +49 -22
- data/config/default.yml +19 -3
- 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
|
|
|
@@ -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,6 +53,10 @@ 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
|
|
58
62
|
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#user-content-access-modifier-indentation
|
|
@@ -283,6 +287,7 @@ Layout/SpaceAfterMethodName:
|
|
|
283
287
|
|
|
284
288
|
Layout/SpaceAfterNot:
|
|
285
289
|
Enabled: true
|
|
290
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#no-spaces-bang
|
|
286
291
|
|
|
287
292
|
Layout/SpaceAfterSemicolon:
|
|
288
293
|
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#spaces-operators
|
|
@@ -307,6 +312,7 @@ Layout/SpaceAroundOperators:
|
|
|
307
312
|
|
|
308
313
|
Layout/SpaceBeforeBlockBraces:
|
|
309
314
|
Enabled: true
|
|
315
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#spaces-operators
|
|
310
316
|
|
|
311
317
|
Layout/SpaceBeforeBrackets:
|
|
312
318
|
Enabled: false
|
|
@@ -342,6 +348,7 @@ Layout/SpaceInsideHashLiteralBraces:
|
|
|
342
348
|
|
|
343
349
|
Layout/SpaceInsideParens:
|
|
344
350
|
Enabled: true
|
|
351
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#no-spaces-braces
|
|
345
352
|
|
|
346
353
|
Layout/SpaceInsidePercentLiteralDelimiters:
|
|
347
354
|
Enabled: false
|
|
@@ -351,6 +358,7 @@ Layout/SpaceInsideRangeLiteral:
|
|
|
351
358
|
|
|
352
359
|
Layout/SpaceInsideReferenceBrackets:
|
|
353
360
|
Enabled: true
|
|
361
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#no-spaces-braces
|
|
354
362
|
|
|
355
363
|
Layout/SpaceInsideStringInterpolation:
|
|
356
364
|
Enabled: false
|
|
@@ -404,6 +412,9 @@ Lint/ConstantOverwrittenInRescue:
|
|
|
404
412
|
Lint/ConstantResolution:
|
|
405
413
|
Enabled: false
|
|
406
414
|
|
|
415
|
+
Lint/CopDirectiveSyntax:
|
|
416
|
+
Enabled: false
|
|
417
|
+
|
|
407
418
|
Lint/Debugger:
|
|
408
419
|
Enabled: true
|
|
409
420
|
|
|
@@ -821,12 +832,14 @@ Naming/MemoizedInstanceVariableName:
|
|
|
821
832
|
|
|
822
833
|
Naming/MethodName:
|
|
823
834
|
Enabled: true
|
|
835
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#snake-case-methods-vars
|
|
824
836
|
|
|
825
837
|
Naming/MethodParameterName:
|
|
826
838
|
Enabled: false
|
|
827
839
|
|
|
828
840
|
Naming/PredicatePrefix:
|
|
829
841
|
Enabled: false
|
|
842
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#bool-methods-qmark
|
|
830
843
|
|
|
831
844
|
Naming/RescuedExceptionsVariableName:
|
|
832
845
|
Enabled: false
|
|
@@ -1139,9 +1152,6 @@ Style/Documentation:
|
|
|
1139
1152
|
Style/DocumentationMethod:
|
|
1140
1153
|
Enabled: false
|
|
1141
1154
|
|
|
1142
|
-
Style/DoubleCopDisableDirective:
|
|
1143
|
-
Enabled: false
|
|
1144
|
-
|
|
1145
1155
|
Style/DoubleNegation:
|
|
1146
1156
|
Enabled: false
|
|
1147
1157
|
|
|
@@ -1265,6 +1275,7 @@ Style/IfInsideElse:
|
|
|
1265
1275
|
|
|
1266
1276
|
Style/IfUnlessModifier:
|
|
1267
1277
|
Enabled: false
|
|
1278
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#favor-modifier-if-unless
|
|
1268
1279
|
|
|
1269
1280
|
Style/IfUnlessModifierOfIfUnless:
|
|
1270
1281
|
Enabled: false
|
|
@@ -1365,6 +1376,7 @@ Style/MultilineMethodSignature:
|
|
|
1365
1376
|
|
|
1366
1377
|
Style/MultilineTernaryOperator:
|
|
1367
1378
|
Enabled: false
|
|
1379
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#no-multiline-ternary
|
|
1368
1380
|
|
|
1369
1381
|
Style/MultilineWhenThen:
|
|
1370
1382
|
Enabled: false
|
|
@@ -1438,6 +1450,7 @@ Style/ObjectThen:
|
|
|
1438
1450
|
|
|
1439
1451
|
Style/OneLineConditional:
|
|
1440
1452
|
Enabled: true
|
|
1453
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#trivial-ternary
|
|
1441
1454
|
|
|
1442
1455
|
Style/OpenStructUse:
|
|
1443
1456
|
Enabled: false
|
|
@@ -1450,6 +1463,7 @@ Style/OptionalArguments:
|
|
|
1450
1463
|
|
|
1451
1464
|
Style/OptionalBooleanParameter:
|
|
1452
1465
|
Enabled: false
|
|
1466
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#keyword-arguments
|
|
1453
1467
|
|
|
1454
1468
|
Style/OrAssignment:
|
|
1455
1469
|
Enabled: true
|
|
@@ -1462,6 +1476,7 @@ Style/ParallelAssignment:
|
|
|
1462
1476
|
|
|
1463
1477
|
Style/ParenthesesAroundCondition:
|
|
1464
1478
|
Enabled: false
|
|
1479
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#no-parens-if-unless-while
|
|
1465
1480
|
|
|
1466
1481
|
Style/PercentLiteralDelimiters:
|
|
1467
1482
|
Enabled: false
|
|
@@ -1624,6 +1639,7 @@ Style/StringChars:
|
|
|
1624
1639
|
|
|
1625
1640
|
Style/StringConcatenation:
|
|
1626
1641
|
Enabled: false
|
|
1642
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#string-interpolation
|
|
1627
1643
|
|
|
1628
1644
|
Style/StringHashKeys:
|
|
1629
1645
|
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: 2026-
|
|
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
|
- - ">="
|