rubocop 1.17.0 → 1.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +73 -28
- data/lib/rubocop.rb +2 -0
- data/lib/rubocop/cli/command/suggest_extensions.rb +3 -3
- data/lib/rubocop/config_loader.rb +1 -1
- data/lib/rubocop/config_validator.rb +5 -5
- data/lib/rubocop/cop/base.rb +2 -2
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +1 -1
- data/lib/rubocop/cop/bundler/gem_version.rb +38 -4
- data/lib/rubocop/cop/corrector.rb +4 -4
- data/lib/rubocop/cop/generator.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -1
- data/lib/rubocop/cop/layout/argument_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/array_alignment.rb +2 -2
- data/lib/rubocop/cop/layout/block_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +7 -1
- data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/first_parameter_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/hash_alignment.rb +9 -8
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +1 -1
- data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +122 -0
- data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +6 -6
- data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +2 -2
- data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +6 -6
- data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +6 -6
- data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +6 -6
- data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +3 -3
- data/lib/rubocop/cop/layout/parameter_alignment.rb +2 -2
- data/lib/rubocop/cop/layout/space_around_operators.rb +1 -1
- data/lib/rubocop/cop/lint/nested_percent_literal.rb +1 -1
- data/lib/rubocop/cop/lint/percent_string_array.rb +1 -1
- data/lib/rubocop/cop/lint/percent_symbol_array.rb +1 -1
- data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
- data/lib/rubocop/cop/lint/unused_block_argument.rb +1 -1
- data/lib/rubocop/cop/lint/useless_assignment.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -1
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +10 -1
- data/lib/rubocop/cop/naming/inclusive_language.rb +249 -0
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +2 -2
- data/lib/rubocop/cop/style/class_and_module_children.rb +14 -0
- data/lib/rubocop/cop/style/multiple_comparison.rb +1 -1
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
- data/lib/rubocop/cop/style/quoted_symbols.rb +2 -2
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +1 -1
- data/lib/rubocop/cop/style/regexp_literal.rb +3 -2
- data/lib/rubocop/cop/style/special_global_vars.rb +3 -3
- data/lib/rubocop/cop/style/string_concatenation.rb +32 -5
- data/lib/rubocop/cop/style/string_literals.rb +2 -2
- data/lib/rubocop/cop/style/swap_values.rb +1 -1
- data/lib/rubocop/cop/style/unpack_first.rb +1 -1
- data/lib/rubocop/cop/variable_force/variable_table.rb +1 -1
- data/lib/rubocop/options.rb +4 -4
- data/lib/rubocop/rspec/cop_helper.rb +1 -1
- data/lib/rubocop/rspec/expect_offense.rb +1 -1
- data/lib/rubocop/version.rb +1 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da981ff0ada31e8ea4e414bf7d7d767fde269a06ad5b0cd61e71a36a16068263
|
4
|
+
data.tar.gz: 3b48f1b0f024c3202f5513a05a210707af81caa0b6d0bf2ba5ac4adad69f6b6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab683eefa5181d9dd814b18fc8a4949940a8623014ee12ded5e89ded4ea32162735275bbe4e27e2b025dc4cfe22d77072129bdc12be3d36ceda0ce232de6d6a8
|
7
|
+
data.tar.gz: 9058879a763a810107ce870cdb1eb1269e3bfdd432154d8c9ee19472f6dd69d3624ecaf97d520090ea7f80953f9a68c1da6455484738f28a6cb2ee59cd9c47dd
|
data/README.md
CHANGED
@@ -54,7 +54,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
|
|
54
54
|
in your `Gemfile`:
|
55
55
|
|
56
56
|
```rb
|
57
|
-
gem 'rubocop', '~> 1.
|
57
|
+
gem 'rubocop', '~> 1.18', require: false
|
58
58
|
```
|
59
59
|
|
60
60
|
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
|
data/config/default.yml
CHANGED
@@ -270,8 +270,8 @@ Layout/AccessModifierIndentation:
|
|
270
270
|
SupportedStyles:
|
271
271
|
- outdent
|
272
272
|
- indent
|
273
|
-
# By default
|
274
|
-
#
|
273
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
274
|
+
# but it can be overridden by setting this parameter.
|
275
275
|
IndentationWidth: ~
|
276
276
|
|
277
277
|
Layout/ArgumentAlignment:
|
@@ -299,8 +299,8 @@ Layout/ArgumentAlignment:
|
|
299
299
|
SupportedStyles:
|
300
300
|
- with_first_argument
|
301
301
|
- with_fixed_indentation
|
302
|
-
# By default
|
303
|
-
#
|
302
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
303
|
+
# but it can be overridden by setting this parameter.
|
304
304
|
IndentationWidth: ~
|
305
305
|
|
306
306
|
Layout/ArrayAlignment:
|
@@ -328,8 +328,8 @@ Layout/ArrayAlignment:
|
|
328
328
|
SupportedStyles:
|
329
329
|
- with_first_element
|
330
330
|
- with_fixed_indentation
|
331
|
-
# By default
|
332
|
-
#
|
331
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
332
|
+
# but it can be overridden by setting this parameter.
|
333
333
|
IndentationWidth: ~
|
334
334
|
|
335
335
|
Layout/AssignmentIndentation:
|
@@ -339,8 +339,8 @@ Layout/AssignmentIndentation:
|
|
339
339
|
Enabled: true
|
340
340
|
VersionAdded: '0.49'
|
341
341
|
VersionChanged: '0.77'
|
342
|
-
# By default
|
343
|
-
#
|
342
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
343
|
+
# but it can be overridden by setting this parameter.
|
344
344
|
IndentationWidth: ~
|
345
345
|
|
346
346
|
Layout/BeginEndAlignment:
|
@@ -387,9 +387,9 @@ Layout/CaseIndentation:
|
|
387
387
|
- case
|
388
388
|
- end
|
389
389
|
IndentOneStep: false
|
390
|
-
# By default
|
391
|
-
#
|
392
|
-
# This only matters if `IndentOneStep` is `true
|
390
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
391
|
+
# but it can be overridden by setting this parameter.
|
392
|
+
# This only matters if `IndentOneStep` is `true`.
|
393
393
|
IndentationWidth: ~
|
394
394
|
|
395
395
|
Layout/ClassStructure:
|
@@ -666,8 +666,8 @@ Layout/FirstArgumentIndentation:
|
|
666
666
|
# Same as `special_for_inner_method_call` except that the special rule only
|
667
667
|
# applies if the outer method call encloses its arguments in parentheses.
|
668
668
|
- special_for_inner_method_call_in_parentheses
|
669
|
-
# By default
|
670
|
-
#
|
669
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
670
|
+
# but it can be overridden by setting this parameter.
|
671
671
|
IndentationWidth: ~
|
672
672
|
|
673
673
|
Layout/FirstArrayElementIndentation:
|
@@ -693,8 +693,8 @@ Layout/FirstArrayElementIndentation:
|
|
693
693
|
- special_inside_parentheses
|
694
694
|
- consistent
|
695
695
|
- align_brackets
|
696
|
-
# By default
|
697
|
-
#
|
696
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
697
|
+
# but it can be overridden by setting this parameter.
|
698
698
|
IndentationWidth: ~
|
699
699
|
|
700
700
|
Layout/FirstArrayElementLineBreak:
|
@@ -725,8 +725,8 @@ Layout/FirstHashElementIndentation:
|
|
725
725
|
- special_inside_parentheses
|
726
726
|
- consistent
|
727
727
|
- align_braces
|
728
|
-
# By default
|
729
|
-
#
|
728
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
729
|
+
# but it can be overridden by setting this parameter.
|
730
730
|
IndentationWidth: ~
|
731
731
|
|
732
732
|
Layout/FirstHashElementLineBreak:
|
@@ -761,8 +761,8 @@ Layout/FirstParameterIndentation:
|
|
761
761
|
SupportedStyles:
|
762
762
|
- consistent
|
763
763
|
- align_parentheses
|
764
|
-
# By default
|
765
|
-
#
|
764
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
765
|
+
# but it can be overridden by setting this parameter.
|
766
766
|
IndentationWidth: ~
|
767
767
|
|
768
768
|
Layout/HashAlignment:
|
@@ -883,8 +883,8 @@ Layout/IndentationStyle:
|
|
883
883
|
Enabled: true
|
884
884
|
VersionAdded: '0.49'
|
885
885
|
VersionChanged: '0.82'
|
886
|
-
# By default
|
887
|
-
#
|
886
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
887
|
+
# but it can be overridden by setting this parameter.
|
888
888
|
# It is used during auto-correction to determine how many spaces should
|
889
889
|
# replace each tab.
|
890
890
|
IndentationWidth: ~
|
@@ -923,6 +923,20 @@ Layout/LeadingEmptyLines:
|
|
923
923
|
VersionAdded: '0.57'
|
924
924
|
VersionChanged: '0.77'
|
925
925
|
|
926
|
+
Layout/LineEndStringConcatenationIndentation:
|
927
|
+
Description: >-
|
928
|
+
Checks the indentation of the next line after a line that
|
929
|
+
ends with a string literal and a backslash.
|
930
|
+
Enabled: pending
|
931
|
+
VersionAdded: '1.18'
|
932
|
+
EnforcedStyle: aligned
|
933
|
+
SupportedStyles:
|
934
|
+
- aligned
|
935
|
+
- indented
|
936
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
937
|
+
# but it can be overridden by setting this parameter.
|
938
|
+
IndentationWidth: ~
|
939
|
+
|
926
940
|
Layout/LineLength:
|
927
941
|
Description: 'Checks that line length does not exceed the configured limit.'
|
928
942
|
StyleGuide: '#max-line-length'
|
@@ -1053,8 +1067,8 @@ Layout/MultilineMethodCallIndentation:
|
|
1053
1067
|
- aligned
|
1054
1068
|
- indented
|
1055
1069
|
- indented_relative_to_receiver
|
1056
|
-
# By default
|
1057
|
-
#
|
1070
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
1071
|
+
# but it can be overridden by setting this parameter.
|
1058
1072
|
IndentationWidth: ~
|
1059
1073
|
|
1060
1074
|
Layout/MultilineMethodDefinitionBraceLayout:
|
@@ -1083,8 +1097,8 @@ Layout/MultilineOperationIndentation:
|
|
1083
1097
|
SupportedStyles:
|
1084
1098
|
- aligned
|
1085
1099
|
- indented
|
1086
|
-
# By default
|
1087
|
-
#
|
1100
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
1101
|
+
# but it can be overridden by setting this parameter.
|
1088
1102
|
IndentationWidth: ~
|
1089
1103
|
|
1090
1104
|
Layout/ParameterAlignment:
|
@@ -1112,8 +1126,8 @@ Layout/ParameterAlignment:
|
|
1112
1126
|
SupportedStyles:
|
1113
1127
|
- with_first_parameter
|
1114
1128
|
- with_fixed_indentation
|
1115
|
-
# By default
|
1116
|
-
#
|
1129
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
1130
|
+
# but it can be overridden by setting this parameter.
|
1117
1131
|
IndentationWidth: ~
|
1118
1132
|
|
1119
1133
|
Layout/RedundantLineBreak:
|
@@ -2520,6 +2534,36 @@ Naming/HeredocDelimiterNaming:
|
|
2520
2534
|
ForbiddenDelimiters:
|
2521
2535
|
- !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/'
|
2522
2536
|
|
2537
|
+
Naming/InclusiveLanguage:
|
2538
|
+
Description: 'Recommend the use of inclusive language instead of problematic terms.'
|
2539
|
+
Enabled: pending
|
2540
|
+
VersionAdded: '1.18'
|
2541
|
+
CheckIdentifiers: true
|
2542
|
+
CheckConstants: true
|
2543
|
+
CheckVariables: true
|
2544
|
+
CheckStrings: true
|
2545
|
+
CheckSymbols: true
|
2546
|
+
CheckComments: true
|
2547
|
+
CheckFilepaths: true
|
2548
|
+
FlaggedTerms:
|
2549
|
+
whitelist:
|
2550
|
+
Regex: !ruby/regexp '/white[-_\s]?list/'
|
2551
|
+
Suggestions:
|
2552
|
+
- allowlist
|
2553
|
+
- permit
|
2554
|
+
blacklist:
|
2555
|
+
Regex: !ruby/regexp '/black[-_\s]?list/'
|
2556
|
+
Suggestions:
|
2557
|
+
- denylist
|
2558
|
+
- block
|
2559
|
+
master:
|
2560
|
+
Suggestions: ['main', 'primary', 'leader']
|
2561
|
+
AllowedRegex:
|
2562
|
+
- 'Master of None'
|
2563
|
+
- 'Master Boot Record'
|
2564
|
+
slave:
|
2565
|
+
Suggestions: ['replica', 'secondary', 'follower']
|
2566
|
+
|
2523
2567
|
Naming/MemoizedInstanceVariableName:
|
2524
2568
|
Description: >-
|
2525
2569
|
Memoized method name should match memo instance variable name.
|
@@ -4576,7 +4620,8 @@ Style/StringConcatenation:
|
|
4576
4620
|
Enabled: true
|
4577
4621
|
Safe: false
|
4578
4622
|
VersionAdded: '0.89'
|
4579
|
-
VersionChanged: '1.
|
4623
|
+
VersionChanged: '1.18'
|
4624
|
+
Mode: aggressive
|
4580
4625
|
|
4581
4626
|
Style/StringHashKeys:
|
4582
4627
|
Description: 'Prefer symbols instead of strings as hash keys.'
|
data/lib/rubocop.rb
CHANGED
@@ -211,6 +211,7 @@ require_relative 'rubocop/cop/layout/indentation_width'
|
|
211
211
|
require_relative 'rubocop/cop/layout/initial_indentation'
|
212
212
|
require_relative 'rubocop/cop/layout/leading_comment_space'
|
213
213
|
require_relative 'rubocop/cop/layout/leading_empty_lines'
|
214
|
+
require_relative 'rubocop/cop/layout/line_end_string_concatenation_indentation'
|
214
215
|
require_relative 'rubocop/cop/layout/line_length'
|
215
216
|
require_relative 'rubocop/cop/layout/multiline_array_brace_layout'
|
216
217
|
require_relative 'rubocop/cop/layout/multiline_array_line_breaks'
|
@@ -400,6 +401,7 @@ require_relative 'rubocop/cop/naming/constant_name'
|
|
400
401
|
require_relative 'rubocop/cop/naming/file_name'
|
401
402
|
require_relative 'rubocop/cop/naming/heredoc_delimiter_case'
|
402
403
|
require_relative 'rubocop/cop/naming/heredoc_delimiter_naming'
|
404
|
+
require_relative 'rubocop/cop/naming/inclusive_language'
|
403
405
|
require_relative 'rubocop/cop/naming/memoized_instance_variable_name'
|
404
406
|
require_relative 'rubocop/cop/naming/method_name'
|
405
407
|
require_relative 'rubocop/cop/naming/method_parameter_name'
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
|
20
20
|
puts
|
21
21
|
puts 'Tip: Based on detected gems, the following '\
|
22
|
-
|
22
|
+
'RuboCop extension libraries might be helpful:'
|
23
23
|
|
24
24
|
extensions.sort.each do |extension|
|
25
25
|
puts " * #{extension} (https://github.com/rubocop/#{extension})"
|
@@ -27,8 +27,8 @@ module RuboCop
|
|
27
27
|
|
28
28
|
puts
|
29
29
|
puts 'You can opt out of this message by adding the following to your config '\
|
30
|
-
|
31
|
-
|
30
|
+
'(see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions '\
|
31
|
+
'for more options):'
|
32
32
|
puts ' AllCops:'
|
33
33
|
puts ' SuggestExtensions: false'
|
34
34
|
|
@@ -229,7 +229,7 @@ module RuboCop
|
|
229
229
|
line1 = key1.start_line + 1
|
230
230
|
line2 = key2.start_line + 1
|
231
231
|
"#{smart_path}:#{line1}: " \
|
232
|
-
|
232
|
+
"`#{value}` is concealed by line #{line2}"
|
233
233
|
else
|
234
234
|
"#{smart_path}: `#{value}` is concealed by duplicate"
|
235
235
|
end
|
@@ -81,11 +81,11 @@ module RuboCop
|
|
81
81
|
|
82
82
|
msg = if last_version
|
83
83
|
"RuboCop found unsupported Ruby version #{target_ruby_version} " \
|
84
|
-
|
85
|
-
|
84
|
+
"in #{source}. #{target_ruby_version}-compatible " \
|
85
|
+
"analysis was dropped after version #{last_version}."
|
86
86
|
else
|
87
87
|
'RuboCop found unknown Ruby version ' \
|
88
|
-
|
88
|
+
"#{target_ruby_version.inspect} in #{source}."
|
89
89
|
end
|
90
90
|
|
91
91
|
msg += "\nSupported versions: #{TargetRuby.supported_versions.join(', ')}"
|
@@ -179,8 +179,8 @@ module RuboCop
|
|
179
179
|
next if validate_support_and_has_list(name, style, valid)
|
180
180
|
|
181
181
|
msg = "invalid #{style_name} '#{style}' for #{name} found in " \
|
182
|
-
|
183
|
-
|
182
|
+
"#{smart_loaded_path}\n" \
|
183
|
+
"Valid choices are: #{valid.join(', ')}"
|
184
184
|
raise ValidationError, msg
|
185
185
|
end
|
186
186
|
end
|
data/lib/rubocop/cop/base.rb
CHANGED
@@ -261,7 +261,7 @@ module RuboCop
|
|
261
261
|
# @deprecated Make potential errors with previous API more obvious
|
262
262
|
def offenses
|
263
263
|
raise 'The offenses are not directly available; ' \
|
264
|
-
|
264
|
+
'they are returned as the result of the investigation'
|
265
265
|
end
|
266
266
|
|
267
267
|
### Reserved for Commissioner
|
@@ -441,7 +441,7 @@ module RuboCop
|
|
441
441
|
severity.to_sym
|
442
442
|
else
|
443
443
|
message = "Warning: Invalid severity '#{severity}'. " \
|
444
|
-
|
444
|
+
"Valid severities are #{Severity::NAMES.join(', ')}."
|
445
445
|
warn(Rainbow(message).red)
|
446
446
|
end
|
447
447
|
end
|
@@ -39,7 +39,7 @@ module RuboCop
|
|
39
39
|
include RangeHelp
|
40
40
|
|
41
41
|
MSG = 'Gem `%<gem_name>s` requirements already given on line '\
|
42
|
-
|
42
|
+
'%<line_of_first_occurrence>d of the Gemfile.'
|
43
43
|
|
44
44
|
def on_new_investigation
|
45
45
|
return if processed_source.blank?
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Bundler
|
6
|
-
# Enforce that Gem version specifications
|
7
|
-
# or forbidden.
|
6
|
+
# Enforce that Gem version specifications or a commit reference (branch,
|
7
|
+
# ref, or tag) are either required or forbidden.
|
8
8
|
#
|
9
9
|
# @example EnforcedStyle: required (default)
|
10
10
|
# # bad
|
@@ -19,6 +19,15 @@ module RuboCop
|
|
19
19
|
# # good
|
20
20
|
# gem 'rubocop', '>= 1.5.0', '< 1.10.0'
|
21
21
|
#
|
22
|
+
# # good
|
23
|
+
# gem 'rubocop', branch: 'feature-branch'
|
24
|
+
#
|
25
|
+
# # good
|
26
|
+
# gem 'rubocop', ref: '74b5bfbb2c4b6fd6cdbbc7254bd7084b36e0c85b'
|
27
|
+
#
|
28
|
+
# # good
|
29
|
+
# gem 'rubocop', tag: 'v1.17.0'
|
30
|
+
#
|
22
31
|
# @example EnforcedStyle: forbidden
|
23
32
|
# # good
|
24
33
|
# gem 'rubocop'
|
@@ -32,6 +41,15 @@ module RuboCop
|
|
32
41
|
# # bad
|
33
42
|
# gem 'rubocop', '>= 1.5.0', '< 1.10.0'
|
34
43
|
#
|
44
|
+
# # bad
|
45
|
+
# gem 'rubocop', branch: 'feature-branch'
|
46
|
+
#
|
47
|
+
# # bad
|
48
|
+
# gem 'rubocop', ref: '74b5bfbb2c4b6fd6cdbbc7254bd7084b36e0c85b'
|
49
|
+
#
|
50
|
+
# # bad
|
51
|
+
# gem 'rubocop', tag: 'v1.17.0'
|
52
|
+
#
|
35
53
|
class GemVersion < Base
|
36
54
|
include ConfigurableEnforcedStyle
|
37
55
|
include GemDeclaration
|
@@ -45,6 +63,11 @@ module RuboCop
|
|
45
63
|
(send nil? :gem <(str #version_specification?) ...>)
|
46
64
|
PATTERN
|
47
65
|
|
66
|
+
# @!method includes_commit_reference?(node)
|
67
|
+
def_node_matcher :includes_commit_reference?, <<~PATTERN
|
68
|
+
(send nil? :gem <(hash <(pair (sym {:branch :ref :tag}) (str _)) ...>) ...>)
|
69
|
+
PATTERN
|
70
|
+
|
48
71
|
def on_send(node)
|
49
72
|
return unless gem_declaration?(node)
|
50
73
|
return if allowed_gem?(node)
|
@@ -78,8 +101,19 @@ module RuboCop
|
|
78
101
|
end
|
79
102
|
|
80
103
|
def offense?(node)
|
81
|
-
(
|
82
|
-
|
104
|
+
required_offense?(node) || forbidden_offense?(node)
|
105
|
+
end
|
106
|
+
|
107
|
+
def required_offense?(node)
|
108
|
+
return unless required_style?
|
109
|
+
|
110
|
+
!includes_version_specification?(node) && !includes_commit_reference?(node)
|
111
|
+
end
|
112
|
+
|
113
|
+
def forbidden_offense?(node)
|
114
|
+
return unless forbidden_style?
|
115
|
+
|
116
|
+
includes_version_specification?(node) || includes_commit_reference?(node)
|
83
117
|
end
|
84
118
|
|
85
119
|
def forbidden_style?
|
@@ -32,7 +32,7 @@ module RuboCop
|
|
32
32
|
|
33
33
|
# Removes `size` characters prior to the source range.
|
34
34
|
#
|
35
|
-
# @param [Parser::Source::Range,
|
35
|
+
# @param [Parser::Source::Range, RuboCop::AST::Node] range or node
|
36
36
|
# @param [Integer] size
|
37
37
|
def remove_preceding(node_or_range, size)
|
38
38
|
range = to_range(node_or_range)
|
@@ -44,7 +44,7 @@ module RuboCop
|
|
44
44
|
# If `size` is greater than the size of `range`, the removed region can
|
45
45
|
# overrun the end of `range`.
|
46
46
|
#
|
47
|
-
# @param [Parser::Source::Range,
|
47
|
+
# @param [Parser::Source::Range, RuboCop::AST::Node] range or node
|
48
48
|
# @param [Integer] size
|
49
49
|
def remove_leading(node_or_range, size)
|
50
50
|
range = to_range(node_or_range)
|
@@ -56,7 +56,7 @@ module RuboCop
|
|
56
56
|
# If `size` is greater than the size of `range`, the removed region can
|
57
57
|
# overrun the beginning of `range`.
|
58
58
|
#
|
59
|
-
# @param [Parser::Source::Range,
|
59
|
+
# @param [Parser::Source::Range, RuboCop::AST::Node] range or node
|
60
60
|
# @param [Integer] size
|
61
61
|
def remove_trailing(node_or_range, size)
|
62
62
|
range = to_range(node_or_range)
|
@@ -90,7 +90,7 @@ module RuboCop
|
|
90
90
|
else
|
91
91
|
raise TypeError,
|
92
92
|
'Expected a Parser::Source::Range, Comment or ' \
|
93
|
-
"
|
93
|
+
"RuboCop::AST::Node, got #{node_or_range.class}"
|
94
94
|
end
|
95
95
|
validate_buffer(range.source_buffer)
|
96
96
|
range
|
@@ -104,7 +104,7 @@ module RuboCop
|
|
104
104
|
|
105
105
|
CONFIGURATION_ADDED_MESSAGE =
|
106
106
|
'[modify] A configuration for the cop is added into ' \
|
107
|
-
|
107
|
+
'%<configuration_file_path>s.'
|
108
108
|
|
109
109
|
def initialize(name, github_user, output: $stdout)
|
110
110
|
@badge = Badge.parse(name)
|