rubocop-github 0.20.0 → 0.23.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/README.md +9 -4
- data/STYLEGUIDE.md +1 -1
- data/config/default.yml +30 -10
- data/config/default_pending.yml +110 -0
- data/config/rails.yml +2 -0
- data/config/rails_pending.yml +82 -0
- data/lib/rubocop/cop/github/avoid_object_send_with_dynamic_method.rb +77 -0
- data/lib/rubocop/cop/github/rails_controller_render_literal.rb +1 -1
- data/lib/rubocop/cop/github/render_literal_helpers.rb +2 -1
- data/lib/rubocop-github.rb +1 -0
- data/lib/version.rb +3 -0
- metadata +21 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ac1a38127e5b53652d7f45eafe37d56a3292733cd2b8fbc51d9850c0ba7cb35
|
4
|
+
data.tar.gz: 1178bcc28c86fad227f719bd657e722528275f606dd18bd7259593952df014ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f738eee673c0bfb656397d4ca3700d440727e91068df5e855cecc2a82e0f2c58e1e50fca8c55caf75f0ff644644c097fab91dc9bbbdca18b1b251dc288d03ed0
|
7
|
+
data.tar.gz: f0c1c5a71d71643df7ff30da1bd999423f5ab07eeed36cf5f08bb948573c7bb960cb5aa4d82ef71fb3af3fde3335b767230b054691a6fb487db1c95a7e56f2d7
|
data/README.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
# RuboCop GitHub
|
1
|
+
# RuboCop GitHub
|
2
|
+
|
3
|
+
[](https://github.com/github/rubocop-github/actions/workflows/test.yml)
|
4
|
+
[](https://github.com/github/rubocop-github/actions/workflows/build.yml)
|
5
|
+
[](https://github.com/github/rubocop-github/actions/workflows/lint.yml)
|
6
|
+
[](https://github.com/github/rubocop-github/actions/workflows/release.yml)
|
2
7
|
|
3
8
|
This repository provides recommended RuboCop configuration and additional Cops for use on GitHub open source and internal Ruby projects, and is the home of [GitHub's Ruby Style Guide](./STYLEGUIDE.md).
|
4
9
|
|
@@ -16,10 +21,10 @@ Inherit all of the stylistic rules and cops through an inheritance declaration i
|
|
16
21
|
|
17
22
|
```yaml
|
18
23
|
# .rubocop.yml
|
19
|
-
|
24
|
+
inherit_gem:
|
20
25
|
rubocop-github:
|
21
|
-
|
22
|
-
|
26
|
+
- config/default.yml # generic Ruby rules and cops
|
27
|
+
- config/rails.yml # Rails-specific rules and cops
|
23
28
|
```
|
24
29
|
|
25
30
|
Alternatively, only require the additional custom cops in your `.rubocop.yml` without inheriting/enabling the other stylistic rules:
|
data/STYLEGUIDE.md
CHANGED
@@ -678,7 +678,7 @@ end
|
|
678
678
|
|
679
679
|
* Never put a space between a method name and the opening parenthesis.
|
680
680
|
<a name="no-spaces-method-parens"></a><sup>[[link](#no-spaces-method-parens)]</sup>
|
681
|
-
* <a href="https://docs.rubocop.org/rubocop/
|
681
|
+
* <a href="https://docs.rubocop.org/rubocop/cops_lint.html#lintparenthesesasgroupedexpression">RuboCop rule: Lint/ParenthesesAsGroupedExpression</a>
|
682
682
|
|
683
683
|
``` ruby
|
684
684
|
# bad
|
data/config/default.yml
CHANGED
@@ -3,6 +3,8 @@ inherit_from:
|
|
3
3
|
|
4
4
|
require:
|
5
5
|
- rubocop-github
|
6
|
+
|
7
|
+
plugins:
|
6
8
|
- rubocop-performance
|
7
9
|
|
8
10
|
Bundler/DuplicatedGem:
|
@@ -44,6 +46,9 @@ Gemspec/RequiredRubyVersion:
|
|
44
46
|
Gemspec/RubyVersionGlobalsUsage:
|
45
47
|
Enabled: false
|
46
48
|
|
49
|
+
GitHub/AvoidObjectSendWithDynamicMethod:
|
50
|
+
Enabled: true
|
51
|
+
|
47
52
|
GitHub/InsecureHashAlgorithm:
|
48
53
|
Enabled: true
|
49
54
|
|
@@ -68,10 +73,10 @@ Layout/BlockAlignment:
|
|
68
73
|
Layout/BlockEndNewline:
|
69
74
|
Enabled: true
|
70
75
|
|
71
|
-
# TODO: Enable this since it's in the styleguide.
|
72
76
|
Layout/CaseIndentation:
|
73
|
-
Enabled:
|
77
|
+
Enabled: true
|
74
78
|
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#indent-when-as-start-of-case
|
79
|
+
EnforcedStyle: end
|
75
80
|
|
76
81
|
Layout/ClassStructure:
|
77
82
|
Enabled: false
|
@@ -216,6 +221,7 @@ Layout/LineEndStringConcatenationIndentation:
|
|
216
221
|
|
217
222
|
Layout/LineLength:
|
218
223
|
Enabled: false
|
224
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#line-length
|
219
225
|
|
220
226
|
Layout/MultilineArrayBraceLayout:
|
221
227
|
Enabled: false
|
@@ -290,7 +296,10 @@ Layout/SpaceAroundMethodCallOperator:
|
|
290
296
|
Enabled: false
|
291
297
|
|
292
298
|
Layout/SpaceAroundOperators:
|
293
|
-
Enabled:
|
299
|
+
Enabled: true
|
300
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#spaces-operators
|
301
|
+
Exclude:
|
302
|
+
- "**/*.erb"
|
294
303
|
|
295
304
|
Layout/SpaceBeforeBlockBraces:
|
296
305
|
Enabled: true
|
@@ -324,7 +333,8 @@ Layout/SpaceInsideBlockBraces:
|
|
324
333
|
Enabled: true
|
325
334
|
|
326
335
|
Layout/SpaceInsideHashLiteralBraces:
|
327
|
-
Enabled:
|
336
|
+
Enabled: true
|
337
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#spaces-operators
|
328
338
|
|
329
339
|
Layout/SpaceInsideParens:
|
330
340
|
Enabled: true
|
@@ -561,7 +571,9 @@ Lint/OutOfRangeRegexpRef:
|
|
561
571
|
Enabled: false
|
562
572
|
|
563
573
|
Lint/ParenthesesAsGroupedExpression:
|
564
|
-
|
574
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#no-spaces-method-parens
|
575
|
+
Exclude:
|
576
|
+
- "**/*.erb"
|
565
577
|
|
566
578
|
Lint/PercentStringArray:
|
567
579
|
Enabled: false
|
@@ -995,9 +1007,8 @@ Style/AccessorGrouping:
|
|
995
1007
|
Style/Alias:
|
996
1008
|
Enabled: false
|
997
1009
|
|
998
|
-
# TODO: Enable this since it's in the styleguide.
|
999
1010
|
Style/AndOr:
|
1000
|
-
Enabled:
|
1011
|
+
Enabled: true
|
1001
1012
|
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#no-and-or-or
|
1002
1013
|
|
1003
1014
|
Style/ArgumentsForwarding:
|
@@ -1035,6 +1046,7 @@ Style/BlockDelimiters:
|
|
1035
1046
|
|
1036
1047
|
Style/CaseEquality:
|
1037
1048
|
Enabled: true
|
1049
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#type-checking-is-a-kind-of
|
1038
1050
|
|
1039
1051
|
Style/CaseLikeIf:
|
1040
1052
|
Enabled: false
|
@@ -1055,10 +1067,12 @@ Style/ClassMethods:
|
|
1055
1067
|
Enabled: true
|
1056
1068
|
|
1057
1069
|
Style/ClassMethodsDefinitions:
|
1058
|
-
Enabled:
|
1070
|
+
Enabled: true
|
1071
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#classes
|
1059
1072
|
|
1060
1073
|
Style/ClassVars:
|
1061
1074
|
Enabled: false
|
1075
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#class-variables
|
1062
1076
|
|
1063
1077
|
Style/CollectionCompact:
|
1064
1078
|
Enabled: false
|
@@ -1371,7 +1385,10 @@ Style/NestedParenthesizedCalls:
|
|
1371
1385
|
Enabled: false
|
1372
1386
|
|
1373
1387
|
Style/NestedTernaryOperator:
|
1374
|
-
Enabled:
|
1388
|
+
Enabled: true
|
1389
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#one-expression-per-branch
|
1390
|
+
Exclude:
|
1391
|
+
- "**/*.erb"
|
1375
1392
|
|
1376
1393
|
Style/Next:
|
1377
1394
|
Enabled: false
|
@@ -1422,7 +1439,10 @@ Style/OptionalBooleanParameter:
|
|
1422
1439
|
Enabled: false
|
1423
1440
|
|
1424
1441
|
Style/OrAssignment:
|
1425
|
-
Enabled:
|
1442
|
+
Enabled: true
|
1443
|
+
StyleGuide: https://github.com/github/rubocop-github/blob/main/STYLEGUIDE.md#memoize-away
|
1444
|
+
Exclude:
|
1445
|
+
- "**/*.erb"
|
1426
1446
|
|
1427
1447
|
Style/ParallelAssignment:
|
1428
1448
|
Enabled: false
|
data/config/default_pending.yml
CHANGED
@@ -4,3 +4,113 @@ Style/OperatorMethodCall: # new in 1.37
|
|
4
4
|
Enabled: false
|
5
5
|
Style/RedundantStringEscape: # new in 1.37
|
6
6
|
Enabled: false
|
7
|
+
Gemspec/DevelopmentDependencies: # new in 1.44
|
8
|
+
Enabled: false
|
9
|
+
Lint/DuplicateMatchPattern: # new in 1.50
|
10
|
+
Enabled: false
|
11
|
+
Lint/ItWithoutArgumentsInBlock: # new in 1.59
|
12
|
+
Enabled: false
|
13
|
+
Lint/LiteralAssignmentInCondition: # new in 1.58
|
14
|
+
Enabled: false
|
15
|
+
Lint/MixedCaseRange: # new in 1.53
|
16
|
+
Enabled: false
|
17
|
+
Lint/RedundantRegexpQuantifiers: # new in 1.53
|
18
|
+
Enabled: false
|
19
|
+
Lint/UselessRescue: # new in 1.43
|
20
|
+
Enabled: false
|
21
|
+
Metrics/CollectionLiteralLength: # new in 1.47
|
22
|
+
Enabled: false
|
23
|
+
Style/ArrayIntersect: # new in 1.40
|
24
|
+
Enabled: false
|
25
|
+
Style/ComparableClamp: # new in 1.44
|
26
|
+
Enabled: false
|
27
|
+
Style/ConcatArrayLiterals: # new in 1.41
|
28
|
+
Enabled: false
|
29
|
+
Style/DataInheritance: # new in 1.49
|
30
|
+
Enabled: false
|
31
|
+
Style/DirEmpty: # new in 1.48
|
32
|
+
Enabled: false
|
33
|
+
Style/ExactRegexpMatch: # new in 1.51
|
34
|
+
Enabled: false
|
35
|
+
Style/FileEmpty: # new in 1.48
|
36
|
+
Enabled: false
|
37
|
+
Style/MapIntoArray: # new in 1.63
|
38
|
+
Enabled: false
|
39
|
+
Style/MapToSet: # new in 1.42
|
40
|
+
Enabled: false
|
41
|
+
Style/MinMaxComparison: # new in 1.42
|
42
|
+
Enabled: false
|
43
|
+
Style/RedundantArrayConstructor: # new in 1.52
|
44
|
+
Enabled: false
|
45
|
+
Style/RedundantConstantBase: # new in 1.40
|
46
|
+
Enabled: false
|
47
|
+
Style/RedundantCurrentDirectoryInPath: # new in 1.53
|
48
|
+
Enabled: false
|
49
|
+
Style/RedundantDoubleSplatHashBraces: # new in 1.41
|
50
|
+
Enabled: false
|
51
|
+
Style/RedundantEach: # new in 1.38
|
52
|
+
Enabled: false
|
53
|
+
Style/RedundantFilterChain: # new in 1.52
|
54
|
+
Enabled: false
|
55
|
+
Style/RedundantHeredocDelimiterQuotes: # new in 1.45
|
56
|
+
Enabled: false
|
57
|
+
Style/RedundantLineContinuation: # new in 1.49
|
58
|
+
Enabled: false
|
59
|
+
Style/RedundantRegexpArgument: # new in 1.53
|
60
|
+
Enabled: false
|
61
|
+
Style/RedundantRegexpConstructor: # new in 1.52
|
62
|
+
Enabled: false
|
63
|
+
Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
|
64
|
+
Enabled: false
|
65
|
+
Style/SingleLineDoEndBlock: # new in 1.57
|
66
|
+
Enabled: false
|
67
|
+
Style/SuperWithArgsParentheses: # new in 1.58
|
68
|
+
Enabled: false
|
69
|
+
Style/YAMLFileRead: # new in 1.53
|
70
|
+
Enabled: false
|
71
|
+
Performance/MapMethodChain: # new in 1.19
|
72
|
+
Enabled: false
|
73
|
+
Gemspec/AddRuntimeDependency: # new in 1.65
|
74
|
+
Enabled: false
|
75
|
+
Lint/ConstantReassignment: # new in 1.70
|
76
|
+
Enabled: false
|
77
|
+
Lint/DuplicateSetElement: # new in 1.67
|
78
|
+
Enabled: false
|
79
|
+
Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69
|
80
|
+
Enabled: false
|
81
|
+
Lint/NumericOperationWithConstantResult: # new in 1.69
|
82
|
+
Enabled: false
|
83
|
+
Lint/SharedMutableDefault: # new in 1.70
|
84
|
+
Enabled: false
|
85
|
+
Lint/UnescapedBracketInRegexp: # new in 1.68
|
86
|
+
Enabled: false
|
87
|
+
Lint/UselessDefined: # new in 1.69
|
88
|
+
Enabled: false
|
89
|
+
Lint/UselessNumericOperation: # new in 1.66
|
90
|
+
Enabled: false
|
91
|
+
Style/AmbiguousEndlessMethodDefinition: # new in 1.68
|
92
|
+
Enabled: false
|
93
|
+
Style/BitwisePredicate: # new in 1.68
|
94
|
+
Enabled: false
|
95
|
+
Style/CombinableDefined: # new in 1.68
|
96
|
+
Enabled: false
|
97
|
+
Style/DigChain: # new in 1.69
|
98
|
+
Enabled: false
|
99
|
+
Style/FileNull: # new in 1.69
|
100
|
+
Enabled: false
|
101
|
+
Style/FileTouch: # new in 1.69
|
102
|
+
Enabled: false
|
103
|
+
Style/ItAssignment: # new in 1.70
|
104
|
+
Enabled: false
|
105
|
+
Style/KeywordArgumentsMerging: # new in 1.68
|
106
|
+
Enabled: false
|
107
|
+
Style/RedundantInterpolationUnfreeze: # new in 1.66
|
108
|
+
Enabled: false
|
109
|
+
Style/SafeNavigationChainLength: # new in 1.68
|
110
|
+
Enabled: false
|
111
|
+
Style/SendWithLiteralMethodName: # new in 1.64
|
112
|
+
Enabled: false
|
113
|
+
Style/SuperArguments: # new in 1.64
|
114
|
+
Enabled: false
|
115
|
+
Performance/StringBytesize: # new in 1.23
|
116
|
+
Enabled: false
|
data/config/rails.yml
CHANGED
data/config/rails_pending.yml
CHANGED
@@ -18,3 +18,85 @@ Rails/WhereMissing: # new in 2.16
|
|
18
18
|
Enabled: false
|
19
19
|
Rails/WhereNotWithMultipleConditions: # new in 2.17
|
20
20
|
Enabled: false
|
21
|
+
Gemspec/DevelopmentDependencies: # new in 1.44
|
22
|
+
Enabled: false
|
23
|
+
Lint/DuplicateMatchPattern: # new in 1.50
|
24
|
+
Enabled: false
|
25
|
+
Lint/ItWithoutArgumentsInBlock: # new in 1.59
|
26
|
+
Enabled: false
|
27
|
+
Lint/LiteralAssignmentInCondition: # new in 1.58
|
28
|
+
Enabled: false
|
29
|
+
Lint/MixedCaseRange: # new in 1.53
|
30
|
+
Enabled: false
|
31
|
+
Lint/RedundantRegexpQuantifiers: # new in 1.53
|
32
|
+
Enabled: false
|
33
|
+
Lint/UselessRescue: # new in 1.43
|
34
|
+
Enabled: false
|
35
|
+
Metrics/CollectionLiteralLength: # new in 1.47
|
36
|
+
Enabled: false
|
37
|
+
Style/ArrayIntersect: # new in 1.40
|
38
|
+
Enabled: false
|
39
|
+
Style/ComparableClamp: # new in 1.44
|
40
|
+
Enabled: false
|
41
|
+
Style/ConcatArrayLiterals: # new in 1.41
|
42
|
+
Enabled: false
|
43
|
+
Style/DataInheritance: # new in 1.49
|
44
|
+
Enabled: false
|
45
|
+
Style/DirEmpty: # new in 1.48
|
46
|
+
Enabled: false
|
47
|
+
Style/ExactRegexpMatch: # new in 1.51
|
48
|
+
Enabled: false
|
49
|
+
Style/FileEmpty: # new in 1.48
|
50
|
+
Enabled: false
|
51
|
+
Style/MapIntoArray: # new in 1.63
|
52
|
+
Enabled: false
|
53
|
+
Style/MapToSet: # new in 1.42
|
54
|
+
Enabled: false
|
55
|
+
Style/MinMaxComparison: # new in 1.42
|
56
|
+
Enabled: false
|
57
|
+
Style/RedundantArrayConstructor: # new in 1.52
|
58
|
+
Enabled: false
|
59
|
+
Style/RedundantConstantBase: # new in 1.40
|
60
|
+
Enabled: false
|
61
|
+
Style/RedundantCurrentDirectoryInPath: # new in 1.53
|
62
|
+
Enabled: false
|
63
|
+
Style/RedundantDoubleSplatHashBraces: # new in 1.41
|
64
|
+
Enabled: false
|
65
|
+
Style/RedundantEach: # new in 1.38
|
66
|
+
Enabled: false
|
67
|
+
Style/RedundantFilterChain: # new in 1.52
|
68
|
+
Enabled: false
|
69
|
+
Style/RedundantHeredocDelimiterQuotes: # new in 1.45
|
70
|
+
Enabled: false
|
71
|
+
Style/RedundantLineContinuation: # new in 1.49
|
72
|
+
Enabled: false
|
73
|
+
Style/RedundantRegexpArgument: # new in 1.53
|
74
|
+
Enabled: false
|
75
|
+
Style/RedundantRegexpConstructor: # new in 1.52
|
76
|
+
Enabled: false
|
77
|
+
Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
|
78
|
+
Enabled: false
|
79
|
+
Style/SingleLineDoEndBlock: # new in 1.57
|
80
|
+
Enabled: false
|
81
|
+
Style/SuperWithArgsParentheses: # new in 1.58
|
82
|
+
Enabled: false
|
83
|
+
Style/YAMLFileRead: # new in 1.53
|
84
|
+
Enabled: false
|
85
|
+
Performance/MapMethodChain: # new in 1.19
|
86
|
+
Enabled: false
|
87
|
+
Rails/DangerousColumnNames: # new in 2.21
|
88
|
+
Enabled: false
|
89
|
+
Rails/EnvLocal: # new in 2.22
|
90
|
+
Enabled: false
|
91
|
+
Rails/RedundantActiveRecordAllMethod: # new in 2.21
|
92
|
+
Enabled: false
|
93
|
+
Rails/ResponseParsedBody: # new in 2.18
|
94
|
+
Enabled: false
|
95
|
+
Rails/ThreeStateBooleanColumn: # new in 2.19
|
96
|
+
Enabled: false
|
97
|
+
Rails/UnusedRenderContent: # new in 2.21
|
98
|
+
Enabled: false
|
99
|
+
Rails/EnumSyntax: # new in 2.26
|
100
|
+
Enabled: false
|
101
|
+
Rails/WhereRange: # new in 2.25
|
102
|
+
Enabled: false
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubocop"
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module GitHub
|
8
|
+
# Public: A Rubocop to discourage using methods like Object#send that allow you to dynamically call other
|
9
|
+
# methods on a Ruby object, when the method being called is itself completely dynamic. Instead, explicitly call
|
10
|
+
# methods by name.
|
11
|
+
#
|
12
|
+
# Examples:
|
13
|
+
#
|
14
|
+
# # bad
|
15
|
+
# foo.send(some_variable)
|
16
|
+
#
|
17
|
+
# # good
|
18
|
+
# case some_variable
|
19
|
+
# when "bar"
|
20
|
+
# foo.bar
|
21
|
+
# else
|
22
|
+
# foo.baz
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# # fine
|
26
|
+
# foo.send(:bar)
|
27
|
+
# foo.public_send("some_method")
|
28
|
+
# foo.__send__("some_#{variable}_method")
|
29
|
+
class AvoidObjectSendWithDynamicMethod < Base
|
30
|
+
MESSAGE_TEMPLATE = "Avoid using Object#%s with a dynamic method name."
|
31
|
+
SEND_METHODS = %i(send public_send __send__).freeze
|
32
|
+
CONSTANT_TYPES = %i(sym str const).freeze
|
33
|
+
|
34
|
+
def on_send(node)
|
35
|
+
return unless send_method?(node)
|
36
|
+
return if method_being_sent_is_constrained?(node)
|
37
|
+
add_offense(source_range_for_method_call(node), message: MESSAGE_TEMPLATE % node.method_name)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def send_method?(node)
|
43
|
+
SEND_METHODS.include?(node.method_name)
|
44
|
+
end
|
45
|
+
|
46
|
+
def method_being_sent_is_constrained?(node)
|
47
|
+
method_name_being_sent_is_constant?(node) || method_name_being_sent_is_dynamic_string_with_constants?(node)
|
48
|
+
end
|
49
|
+
|
50
|
+
def method_name_being_sent_is_constant?(node)
|
51
|
+
method_being_sent = node.arguments.first
|
52
|
+
# e.g., `worker.send(:perform)` or `base.send("extend", Foo)`
|
53
|
+
CONSTANT_TYPES.include?(method_being_sent.type)
|
54
|
+
end
|
55
|
+
|
56
|
+
def method_name_being_sent_is_dynamic_string_with_constants?(node)
|
57
|
+
method_being_sent = node.arguments.first
|
58
|
+
return false unless method_being_sent.type == :dstr
|
59
|
+
|
60
|
+
# e.g., `foo.send("can_#{action}?")`
|
61
|
+
method_being_sent.child_nodes.any? { |child_node| CONSTANT_TYPES.include?(child_node.type) }
|
62
|
+
end
|
63
|
+
|
64
|
+
def source_range_for_method_call(node)
|
65
|
+
begin_pos =
|
66
|
+
if node.receiver # e.g., for `foo.send(:bar)`, `foo` is the receiver
|
67
|
+
node.receiver.source_range.end_pos
|
68
|
+
else # e.g., `send(:bar)`
|
69
|
+
node.source_range.begin_pos
|
70
|
+
end
|
71
|
+
end_pos = node.loc.selector.end_pos
|
72
|
+
Parser::Source::Range.new(processed_source.buffer, begin_pos, end_pos)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -9,7 +9,7 @@ module RuboCop
|
|
9
9
|
class RailsControllerRenderLiteral < Base
|
10
10
|
include RenderLiteralHelpers
|
11
11
|
|
12
|
-
MSG = "render must be used with a string literal or an instance of a Class"
|
12
|
+
MSG = "render must be used with a string literal or an instance of a Class, and use literals for locals keys"
|
13
13
|
|
14
14
|
def_node_matcher :ignore_key?, <<-PATTERN
|
15
15
|
(pair (sym {
|
@@ -41,7 +41,8 @@ module RuboCop
|
|
41
41
|
PATTERN
|
42
42
|
|
43
43
|
def hash_with_literal_keys?(hash)
|
44
|
-
hash.
|
44
|
+
hash.children.all? { |child| child.pair_type? } &&
|
45
|
+
hash.pairs.all? { |pair| literal?(pair.key) }
|
45
46
|
end
|
46
47
|
|
47
48
|
def render_view_component?(node)
|
data/lib/rubocop-github.rb
CHANGED
data/lib/version.rb
ADDED
metadata
CHANGED
@@ -1,14 +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.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-27 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rubocop
|
@@ -16,56 +15,56 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
18
|
+
version: '1.72'
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
25
|
+
version: '1.72'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: rubocop-performance
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - ">="
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
32
|
+
version: '1.24'
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
39
|
+
version: '1.24'
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
name: rubocop-rails
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - ">="
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: '2.
|
46
|
+
version: '2.23'
|
48
47
|
type: :runtime
|
49
48
|
prerelease: false
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
51
|
- - ">="
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version: '2.
|
53
|
+
version: '2.23'
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
55
|
name: actionview
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
58
57
|
requirements:
|
59
|
-
- - "
|
58
|
+
- - "~>"
|
60
59
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
60
|
+
version: 7.1.5.1
|
62
61
|
type: :development
|
63
62
|
prerelease: false
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
65
64
|
requirements:
|
66
|
-
- - "
|
65
|
+
- - "~>"
|
67
66
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
67
|
+
version: 7.1.5.1
|
69
68
|
- !ruby/object:Gem::Dependency
|
70
69
|
name: minitest
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,7 +93,7 @@ dependencies:
|
|
94
93
|
- - ">="
|
95
94
|
- !ruby/object:Gem::Version
|
96
95
|
version: '0'
|
97
|
-
description:
|
96
|
+
description: Code style checking for GitHub Ruby repositories
|
98
97
|
email: engineering@github.com
|
99
98
|
executables: []
|
100
99
|
extensions: []
|
@@ -114,6 +113,7 @@ files:
|
|
114
113
|
- lib/rubocop-github-rails.rb
|
115
114
|
- lib/rubocop-github.rb
|
116
115
|
- lib/rubocop/cop/github.rb
|
116
|
+
- lib/rubocop/cop/github/avoid_object_send_with_dynamic_method.rb
|
117
117
|
- lib/rubocop/cop/github/insecure_hash_algorithm.rb
|
118
118
|
- lib/rubocop/cop/github/rails_controller_render_action_symbol.rb
|
119
119
|
- lib/rubocop/cop/github/rails_controller_render_literal.rb
|
@@ -126,11 +126,14 @@ files:
|
|
126
126
|
- lib/rubocop/cop/github/render_literal_helpers.rb
|
127
127
|
- lib/rubocop/github.rb
|
128
128
|
- lib/rubocop/github/inject.rb
|
129
|
+
- lib/version.rb
|
129
130
|
homepage: https://github.com/github/rubocop-github
|
130
131
|
licenses:
|
131
132
|
- MIT
|
132
|
-
metadata:
|
133
|
-
|
133
|
+
metadata:
|
134
|
+
source_code_uri: https://github.com/github/rubocop-github
|
135
|
+
documentation_uri: https://github.com/github/rubocop-github
|
136
|
+
bug_tracker_uri: https://github.com/github/rubocop-github/issues
|
134
137
|
rdoc_options: []
|
135
138
|
require_paths:
|
136
139
|
- lib
|
@@ -138,15 +141,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
141
|
requirements:
|
139
142
|
- - ">="
|
140
143
|
- !ruby/object:Gem::Version
|
141
|
-
version:
|
144
|
+
version: 3.0.0
|
142
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
146
|
requirements:
|
144
147
|
- - ">="
|
145
148
|
- !ruby/object:Gem::Version
|
146
149
|
version: '0'
|
147
150
|
requirements: []
|
148
|
-
rubygems_version: 3.
|
149
|
-
signing_key:
|
151
|
+
rubygems_version: 3.6.2
|
150
152
|
specification_version: 4
|
151
153
|
summary: RuboCop GitHub
|
152
154
|
test_files: []
|