rubocop 1.56.0 → 1.56.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/bundler/duplicated_group.rb +54 -8
- data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +7 -4
- data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
- data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +17 -9
- data/lib/rubocop/cop/layout/line_continuation_spacing.rb +1 -1
- data/lib/rubocop/cop/layout/redundant_line_break.rb +4 -2
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +10 -6
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +5 -3
- data/lib/rubocop/cop/lint/useless_assignment.rb +1 -2
- data/lib/rubocop/cop/naming/file_name.rb +1 -1
- data/lib/rubocop/cop/style/arguments_forwarding.rb +14 -5
- data/lib/rubocop/cop/style/concat_array_literals.rb +1 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +3 -1
- data/lib/rubocop/cop/style/open_struct_use.rb +1 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +3 -1
- data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +5 -0
- data/lib/rubocop/cop/style/symbol_array.rb +2 -0
- data/lib/rubocop/cop/utils/regexp_ranges.rb +26 -13
- data/lib/rubocop/lsp/routes.rb +4 -1
- data/lib/rubocop/target_ruby.rb +9 -5
- data/lib/rubocop/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 061c4fd159baec4f143f014ae432ec3607b0846cb46b3a4566a224922b6c5c7b
|
4
|
+
data.tar.gz: 943c45cc27dbbb861f6b2a910216a016c06e2ace63824c30a7ad922caabfed59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d5900ca290d826af3658c1d481a7778b44a4d57455d69c96c603bac7679c4b275cd192339e683e6ba020201e0dbb23ee3e64f9fbc953cc5bf4832ce1c293bbb
|
7
|
+
data.tar.gz: dfc761f98d05680a21093ce5092b933ff8534f7b7ed5f7c46ec52586673db9ad60b495e896b429499d151c6af827a30d1e67c2e1bf397f9a7947b1c0bff836ab
|
@@ -5,6 +5,24 @@ module RuboCop
|
|
5
5
|
module Bundler
|
6
6
|
# A Gem group, or a set of groups, should be listed only once in a Gemfile.
|
7
7
|
#
|
8
|
+
# For example, if the values of `source`, `git`, `platforms`, or `path`
|
9
|
+
# surrounding `group` are different, no offense will be registered:
|
10
|
+
#
|
11
|
+
# [source,ruby]
|
12
|
+
# -----
|
13
|
+
# platforms :ruby do
|
14
|
+
# group :default do
|
15
|
+
# gem 'openssl'
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# platforms :jruby do
|
20
|
+
# group :default do
|
21
|
+
# gem 'jruby-openssl'
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
# -----
|
25
|
+
#
|
8
26
|
# @example
|
9
27
|
# # bad
|
10
28
|
# group :development do
|
@@ -42,27 +60,35 @@ module RuboCop
|
|
42
60
|
|
43
61
|
MSG = 'Gem group `%<group_name>s` already defined on line ' \
|
44
62
|
'%<line_of_first_occurrence>d of the Gemfile.'
|
63
|
+
SOURCE_BLOCK_NAMES = %i[source git platforms path].freeze
|
64
|
+
|
65
|
+
# @!method group_declarations(node)
|
66
|
+
def_node_search :group_declarations, '(send nil? :group ...)'
|
45
67
|
|
46
68
|
def on_new_investigation
|
47
69
|
return if processed_source.blank?
|
48
70
|
|
49
71
|
duplicated_group_nodes.each do |nodes|
|
50
72
|
nodes[1..].each do |node|
|
51
|
-
|
73
|
+
group_name = node.arguments.map(&:source).join(', ')
|
74
|
+
|
75
|
+
register_offense(node, group_name, nodes.first.first_line)
|
52
76
|
end
|
53
77
|
end
|
54
78
|
end
|
55
79
|
|
56
80
|
private
|
57
81
|
|
58
|
-
# @!method group_declarations(node)
|
59
|
-
def_node_search :group_declarations, '(send nil? :group ...)'
|
60
|
-
|
61
82
|
def duplicated_group_nodes
|
62
|
-
group_declarations(processed_source.ast)
|
63
|
-
|
64
|
-
|
65
|
-
|
83
|
+
group_declarations = group_declarations(processed_source.ast)
|
84
|
+
group_keys = group_declarations.group_by do |node|
|
85
|
+
source_key = find_source_key(node)
|
86
|
+
group_attributes = group_attributes(node).sort.join
|
87
|
+
|
88
|
+
"#{source_key}#{group_attributes}"
|
89
|
+
end
|
90
|
+
|
91
|
+
group_keys.values.select { |nodes| nodes.size > 1 }
|
66
92
|
end
|
67
93
|
|
68
94
|
def register_offense(node, group_name, line_of_first_occurrence)
|
@@ -75,6 +101,26 @@ module RuboCop
|
|
75
101
|
)
|
76
102
|
add_offense(offense_location, message: message)
|
77
103
|
end
|
104
|
+
|
105
|
+
def find_source_key(node)
|
106
|
+
source_block = node.each_ancestor(:block).find do |block_node|
|
107
|
+
SOURCE_BLOCK_NAMES.include?(block_node.method_name)
|
108
|
+
end
|
109
|
+
|
110
|
+
return unless source_block
|
111
|
+
|
112
|
+
"#{source_block.method_name}#{source_block.send_node.first_argument&.source}"
|
113
|
+
end
|
114
|
+
|
115
|
+
def group_attributes(node)
|
116
|
+
node.arguments.map do |argument|
|
117
|
+
if argument.hash_type?
|
118
|
+
argument.pairs.map(&:source).sort.join(', ')
|
119
|
+
else
|
120
|
+
argument.value.to_s
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
78
124
|
end
|
79
125
|
end
|
80
126
|
end
|
@@ -14,12 +14,15 @@ module RuboCop
|
|
14
14
|
# Check for unparenthesized args' preceding and trailing whitespaces.
|
15
15
|
remove_unparenthesized_whitespace(corrector)
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
if block_node.block_type?
|
18
|
+
# Avoid correcting to `lambdado` by inserting whitespace
|
19
|
+
# if none exists before or after the lambda arguments.
|
20
|
+
insert_separating_space(corrector)
|
21
|
+
|
22
|
+
remove_arguments(corrector)
|
23
|
+
end
|
20
24
|
|
21
25
|
replace_selector(corrector)
|
22
|
-
remove_arguments(corrector)
|
23
26
|
|
24
27
|
replace_delimiters(corrector)
|
25
28
|
|
@@ -57,7 +57,7 @@ module RuboCop
|
|
57
57
|
|
58
58
|
def on_new_investigation
|
59
59
|
processed_source.comments.each do |comment|
|
60
|
-
next unless /\A#+[^#\s
|
60
|
+
next unless /\A(?!#\+\+|#--)(#+[^#\s=])/.match?(comment.text)
|
61
61
|
next if comment.loc.line == 1 && allowed_on_first_line?(comment)
|
62
62
|
next if doxygen_comment_style?(comment)
|
63
63
|
next if gemfile_ruby_comment?(comment)
|
@@ -57,16 +57,13 @@ module RuboCop
|
|
57
57
|
|
58
58
|
end_of_first_line = node.source_range.begin_pos - node.source_range.column
|
59
59
|
|
60
|
-
raw_lines(node)
|
60
|
+
lines = raw_lines(node)
|
61
|
+
lines.each_cons(2).with_index(node.first_line) do |(raw_line_one, raw_line_two), line_num|
|
61
62
|
end_of_first_line += raw_line_one.length
|
62
63
|
|
63
|
-
next unless continuation?(raw_line_one)
|
64
|
+
next unless continuation?(raw_line_one, line_num, node)
|
64
65
|
|
65
|
-
|
66
|
-
investigate_leading_style(raw_line_one, raw_line_two, end_of_first_line)
|
67
|
-
else
|
68
|
-
investigate_trailing_style(raw_line_one, raw_line_two, end_of_first_line)
|
69
|
-
end
|
66
|
+
investigate(raw_line_one, raw_line_two, end_of_first_line)
|
70
67
|
end
|
71
68
|
end
|
72
69
|
|
@@ -76,6 +73,14 @@ module RuboCop
|
|
76
73
|
processed_source.raw_source.lines[node.first_line - 1, line_range(node).size]
|
77
74
|
end
|
78
75
|
|
76
|
+
def investigate(first_line, second_line, end_of_first_line)
|
77
|
+
if enforced_style_leading?
|
78
|
+
investigate_leading_style(first_line, second_line, end_of_first_line)
|
79
|
+
else
|
80
|
+
investigate_trailing_style(first_line, second_line, end_of_first_line)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
79
84
|
def investigate_leading_style(first_line, second_line, end_of_first_line)
|
80
85
|
matches = first_line.match(LEADING_STYLE_OFFENSE)
|
81
86
|
return if matches.nil?
|
@@ -98,8 +103,11 @@ module RuboCop
|
|
98
103
|
end
|
99
104
|
end
|
100
105
|
|
101
|
-
def continuation?(line)
|
102
|
-
line.end_with?("\\\n")
|
106
|
+
def continuation?(line, line_num, node)
|
107
|
+
return false unless line.end_with?("\\\n")
|
108
|
+
|
109
|
+
# Ensure backslash isn't part of a token spanning to the next line.
|
110
|
+
node.children.none? { |c| c.first_line == line_num && c.multiline? }
|
103
111
|
end
|
104
112
|
|
105
113
|
def autocorrect(corrector, offense_range, insert_pos, spaces)
|
@@ -109,7 +109,7 @@ module RuboCop
|
|
109
109
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
110
110
|
|
111
111
|
def comment_ranges(comments)
|
112
|
-
comments.map(&:
|
112
|
+
comments.map(&:source_range)
|
113
113
|
end
|
114
114
|
|
115
115
|
def last_line(processed_source)
|
@@ -106,7 +106,7 @@ module RuboCop
|
|
106
106
|
|
107
107
|
def suitable_as_single_line?(node)
|
108
108
|
!comment_within?(node) &&
|
109
|
-
node.each_descendant(:if, :case, :kwbegin, :def).none? &&
|
109
|
+
node.each_descendant(:if, :case, :kwbegin, :def, :defs).none? &&
|
110
110
|
node.each_descendant(:dstr, :str).none? { |n| n.heredoc? || n.value.include?("\n") } &&
|
111
111
|
node.each_descendant(:begin).none? { |b| !b.single_line? }
|
112
112
|
end
|
@@ -118,7 +118,9 @@ module RuboCop
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def comment_within?(node)
|
121
|
-
processed_source.comments.map
|
121
|
+
comment_line_numbers = processed_source.comments.map { |comment| comment.loc.line }
|
122
|
+
|
123
|
+
comment_line_numbers.any? do |comment_line_number|
|
122
124
|
comment_line_number >= node.first_line && comment_line_number <= node.last_line
|
123
125
|
end
|
124
126
|
end
|
@@ -51,18 +51,20 @@ module RuboCop
|
|
51
51
|
MAKE_FORCE_METHODS = %i[makedirs mkdir_p mkpath].freeze
|
52
52
|
MAKE_METHODS = %i[mkdir].freeze
|
53
53
|
REMOVE_FORCE_METHODS = %i[rm_f rm_rf].freeze
|
54
|
-
REMOVE_METHODS = %i[remove
|
55
|
-
|
56
|
-
RESTRICT_ON_SEND = (
|
57
|
-
|
54
|
+
REMOVE_METHODS = %i[remove delete unlink remove_file rm rmdir safe_unlink].freeze
|
55
|
+
RECURSIVE_REMOVE_METHODS = %i[remove_dir remove_entry remove_entry_secure].freeze
|
56
|
+
RESTRICT_ON_SEND = (
|
57
|
+
MAKE_METHODS + MAKE_FORCE_METHODS + REMOVE_METHODS + RECURSIVE_REMOVE_METHODS +
|
58
|
+
REMOVE_FORCE_METHODS
|
59
|
+
).freeze
|
58
60
|
|
59
61
|
# @!method send_exist_node(node)
|
60
|
-
def_node_search :send_exist_node,
|
62
|
+
def_node_search :send_exist_node, <<~PATTERN
|
61
63
|
$(send (const nil? {:FileTest :File :Dir :Shell}) {:exist? :exists?} ...)
|
62
64
|
PATTERN
|
63
65
|
|
64
66
|
# @!method receiver_and_method_name(node)
|
65
|
-
def_node_matcher :receiver_and_method_name,
|
67
|
+
def_node_matcher :receiver_and_method_name, <<~PATTERN
|
66
68
|
(send (const nil? $_) $_ ...)
|
67
69
|
PATTERN
|
68
70
|
|
@@ -140,6 +142,8 @@ module RuboCop
|
|
140
142
|
'mkdir_p'
|
141
143
|
elsif REMOVE_METHODS.include?(node.method_name)
|
142
144
|
'rm_f'
|
145
|
+
elsif RECURSIVE_REMOVE_METHODS.include?(node.method_name)
|
146
|
+
'rm_rf'
|
143
147
|
else
|
144
148
|
node.method_name
|
145
149
|
end
|
@@ -74,7 +74,7 @@ module RuboCop
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
77
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
78
78
|
def argument_match?(send_arg, def_arg)
|
79
79
|
def_arg_name = def_arg.children[0]
|
80
80
|
|
@@ -87,12 +87,14 @@ module RuboCop
|
|
87
87
|
send_arg.hash_type? &&
|
88
88
|
send_arg.pairs.any? { |pair| passing_keyword_arg?(pair, def_arg_name) }
|
89
89
|
when :kwrestarg
|
90
|
-
send_arg.each_child_node(:kwsplat).any?
|
90
|
+
send_arg.each_child_node(:kwsplat, :forwarded_kwrestarg).any? do |child|
|
91
|
+
child.source == def_arg.source
|
92
|
+
end
|
91
93
|
when :forward_arg
|
92
94
|
send_arg.forwarded_args_type?
|
93
95
|
end
|
94
96
|
end
|
95
|
-
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
97
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
96
98
|
end
|
97
99
|
end
|
98
100
|
end
|
@@ -96,8 +96,7 @@ module RuboCop
|
|
96
96
|
return_value_node = return_value_node_of_scope(scope)
|
97
97
|
return unless assignment.meta_assignment_node.equal?(return_value_node)
|
98
98
|
|
99
|
-
" Use `#{assignment.operator.
|
100
|
-
"instead of `#{assignment.operator}`."
|
99
|
+
" Use `#{assignment.operator.delete_suffix('=')}` instead of `#{assignment.operator}`."
|
101
100
|
end
|
102
101
|
|
103
102
|
def similar_name_message(variable)
|
@@ -136,7 +136,7 @@ module RuboCop
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def filename_good?(basename)
|
139
|
-
basename = basename.
|
139
|
+
basename = basename.delete_prefix('.')
|
140
140
|
basename = basename.sub(/\.[^.]+$/, '')
|
141
141
|
# special handling for Action Pack Variants file names like
|
142
142
|
# some_file.xlsx+mobile.axlsx
|
@@ -80,6 +80,7 @@ module RuboCop
|
|
80
80
|
minimum_target_ruby_version 2.7
|
81
81
|
|
82
82
|
FORWARDING_LVAR_TYPES = %i[splat kwsplat block_pass].freeze
|
83
|
+
ADDITIONAL_ARG_TYPES = %i[lvar arg].freeze
|
83
84
|
|
84
85
|
FORWARDING_MSG = 'Use shorthand syntax `...` for arguments forwarding.'
|
85
86
|
ARGS_MSG = 'Use anonymous positional arguments forwarding (`*`).'
|
@@ -212,7 +213,7 @@ module RuboCop
|
|
212
213
|
end
|
213
214
|
|
214
215
|
def arguments_range(node, first_node)
|
215
|
-
arguments = node.arguments
|
216
|
+
arguments = node.arguments.reject { |arg| ADDITIONAL_ARG_TYPES.include?(arg.type) }
|
216
217
|
|
217
218
|
start_node = first_node || arguments.first
|
218
219
|
|
@@ -279,7 +280,7 @@ module RuboCop
|
|
279
280
|
|
280
281
|
if can_forward_all?
|
281
282
|
:all
|
282
|
-
|
283
|
+
else
|
283
284
|
:rest_or_kwrest
|
284
285
|
end
|
285
286
|
end
|
@@ -290,7 +291,7 @@ module RuboCop
|
|
290
291
|
return false if any_arg_referenced?
|
291
292
|
return false if ruby_32_missing_rest_or_kwest?
|
292
293
|
return false unless offensive_block_forwarding?
|
293
|
-
return false if
|
294
|
+
return false if additional_kwargs_or_forwarded_kwargs?
|
294
295
|
|
295
296
|
no_additional_args? || (target_ruby_version >= 3.0 && no_post_splat_args?)
|
296
297
|
end
|
@@ -332,12 +333,20 @@ module RuboCop
|
|
332
333
|
end
|
333
334
|
|
334
335
|
def no_post_splat_args?
|
335
|
-
splat_index = arguments.index(forwarded_rest_arg)
|
336
|
-
arg_after_splat = arguments[splat_index + 1]
|
336
|
+
return true unless (splat_index = arguments.index(forwarded_rest_arg))
|
337
337
|
|
338
|
+
arg_after_splat = arguments[splat_index + 1]
|
338
339
|
[nil, :hash, :block_pass].include?(arg_after_splat&.type)
|
339
340
|
end
|
340
341
|
|
342
|
+
def additional_kwargs_or_forwarded_kwargs?
|
343
|
+
additional_kwargs? || forward_additional_kwargs?
|
344
|
+
end
|
345
|
+
|
346
|
+
def additional_kwargs?
|
347
|
+
@def_node.arguments.any? { |a| a.kwarg_type? || a.kwoptarg_type? }
|
348
|
+
end
|
349
|
+
|
341
350
|
def forward_additional_kwargs?
|
342
351
|
return false unless forwarded_kwrest_arg
|
343
352
|
|
@@ -146,7 +146,9 @@ module RuboCop
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def call_in_match_pattern?(node)
|
149
|
-
node.parent
|
149
|
+
return false unless (parent = node.parent)
|
150
|
+
|
151
|
+
parent.match_pattern_type? || parent.match_pattern_p_type?
|
150
152
|
end
|
151
153
|
|
152
154
|
def hash_literal_in_arguments?(node)
|
@@ -45,7 +45,7 @@ module RuboCop
|
|
45
45
|
MSG = 'Avoid using `OpenStruct`; use `Struct`, `Hash`, a class or test doubles instead.'
|
46
46
|
|
47
47
|
# @!method uses_open_struct?(node)
|
48
|
-
def_node_matcher :uses_open_struct?,
|
48
|
+
def_node_matcher :uses_open_struct?, <<~PATTERN
|
49
49
|
(const {nil? (cbase)} :OpenStruct)
|
50
50
|
PATTERN
|
51
51
|
|
@@ -98,7 +98,9 @@ module RuboCop
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def like_method_argument_parentheses?(node)
|
101
|
-
node.send_type? && node.
|
101
|
+
return false if !node.send_type? && !node.super_type? && !node.yield_type?
|
102
|
+
|
103
|
+
node.arguments.one? && !node.parenthesized? &&
|
102
104
|
!node.arithmetic_operation? && node.first_argument.begin_type?
|
103
105
|
end
|
104
106
|
|
@@ -75,6 +75,11 @@ module RuboCop
|
|
75
75
|
add_offense(offense_branch) do |corrector|
|
76
76
|
assignment_value = opposite_branch ? opposite_branch.source : 'nil'
|
77
77
|
replacement = "#{assignment_value} #{keyword} #{if_node.condition.source}"
|
78
|
+
if opposite_branch.respond_to?(:heredoc?) && opposite_branch.heredoc?
|
79
|
+
replacement += opposite_branch.loc.heredoc_end.with(
|
80
|
+
begin_pos: opposite_branch.source_range.end_pos
|
81
|
+
).source
|
82
|
+
end
|
78
83
|
|
79
84
|
corrector.replace(if_node, replacement)
|
80
85
|
end
|
@@ -69,6 +69,8 @@ module RuboCop
|
|
69
69
|
|
70
70
|
def complex_content?(node)
|
71
71
|
node.children.any? do |sym|
|
72
|
+
return false if DELIMITERS.include?(sym.source)
|
73
|
+
|
72
74
|
content = *sym
|
73
75
|
content = content.map { |c| c.is_a?(AST::Node) ? c.source : c }.join
|
74
76
|
content_without_delimiter_pairs = content.gsub(/(\[[^\s\[\]]*\])|(\([^\s\(\)]*\))/, '')
|
@@ -6,27 +6,40 @@ module RuboCop
|
|
6
6
|
# Helper to abstract complexity of building range pairs
|
7
7
|
# with octal escape reconstruction (needed for regexp_parser < 2.7).
|
8
8
|
class RegexpRanges
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :root
|
10
10
|
|
11
11
|
def initialize(root)
|
12
12
|
@root = root
|
13
13
|
@compound_token = []
|
14
|
+
@pairs = []
|
15
|
+
@populated = false
|
16
|
+
end
|
17
|
+
|
18
|
+
def compound_token
|
19
|
+
populate_all unless @populated
|
20
|
+
|
21
|
+
@compound_token
|
14
22
|
end
|
15
23
|
|
16
24
|
def pairs
|
17
|
-
unless @
|
18
|
-
|
19
|
-
|
20
|
-
|
25
|
+
populate_all unless @populated
|
26
|
+
|
27
|
+
@pairs
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def populate_all
|
33
|
+
populate(@root)
|
21
34
|
|
22
35
|
# If either bound is a compound the first one is an escape
|
23
36
|
# and that's all we need to work with.
|
24
37
|
# If there are any cops that wanted to operate on the compound
|
25
38
|
# expression we could wrap it with a facade class.
|
26
|
-
@pairs.map { |pair| pair.map(&:first) }
|
27
|
-
end
|
39
|
+
@pairs.map! { |pair| pair.map(&:first) }
|
28
40
|
|
29
|
-
|
41
|
+
@populated = true
|
42
|
+
end
|
30
43
|
|
31
44
|
def populate(expr)
|
32
45
|
expressions = expr.expressions.to_a
|
@@ -35,15 +48,15 @@ module RuboCop
|
|
35
48
|
current = expressions.shift
|
36
49
|
|
37
50
|
if escaped_octal?(current)
|
38
|
-
compound_token << current
|
39
|
-
compound_token.concat(pop_octal_digits(expressions))
|
51
|
+
@compound_token << current
|
52
|
+
@compound_token.concat(pop_octal_digits(expressions))
|
40
53
|
# If we have all the digits we can discard.
|
41
54
|
end
|
42
55
|
|
43
56
|
next unless current.type == :set
|
44
57
|
|
45
58
|
process_set(expressions, current)
|
46
|
-
compound_token.clear
|
59
|
+
@compound_token.clear
|
47
60
|
end
|
48
61
|
end
|
49
62
|
|
@@ -64,8 +77,8 @@ module RuboCop
|
|
64
77
|
|
65
78
|
def compose_range(expressions, current)
|
66
79
|
range_start, range_end = current.expressions
|
67
|
-
range_start = if compound_token.size.between?(1, 2) && octal_digit?(range_start.text)
|
68
|
-
compound_token.dup << range_start
|
80
|
+
range_start = if @compound_token.size.between?(1, 2) && octal_digit?(range_start.text)
|
81
|
+
@compound_token.dup << range_start
|
69
82
|
else
|
70
83
|
[range_start]
|
71
84
|
end
|
data/lib/rubocop/lsp/routes.rb
CHANGED
@@ -45,7 +45,10 @@ module RuboCop
|
|
45
45
|
result: LanguageServer::Protocol::Interface::InitializeResult.new(
|
46
46
|
capabilities: LanguageServer::Protocol::Interface::ServerCapabilities.new(
|
47
47
|
document_formatting_provider: true,
|
48
|
-
diagnostic_provider:
|
48
|
+
diagnostic_provider: LanguageServer::Protocol::Interface::DiagnosticOptions.new(
|
49
|
+
inter_file_dependencies: false,
|
50
|
+
workspace_diagnostics: false
|
51
|
+
),
|
49
52
|
text_document_sync: LanguageServer::Protocol::Interface::TextDocumentSyncOptions.new(
|
50
53
|
change: LanguageServer::Protocol::Constant::TextDocumentSyncKind::FULL,
|
51
54
|
open_close: true
|
data/lib/rubocop/target_ruby.rb
CHANGED
@@ -155,9 +155,11 @@ module RuboCop
|
|
155
155
|
(send _ :required_ruby_version= $_)
|
156
156
|
PATTERN
|
157
157
|
|
158
|
-
# @!method
|
159
|
-
def_node_matcher :
|
160
|
-
(send (const(const _ :Gem):Requirement) :new
|
158
|
+
# @!method gem_requirement_versions(node)
|
159
|
+
def_node_matcher :gem_requirement_versions, <<~PATTERN
|
160
|
+
(send (const(const _ :Gem):Requirement) :new
|
161
|
+
{$str+ | (send $str :freeze)+ | (array $str+) | (array (send $str :freeze)+)}
|
162
|
+
)
|
161
163
|
PATTERN
|
162
164
|
|
163
165
|
def name
|
@@ -194,10 +196,12 @@ module RuboCop
|
|
194
196
|
end
|
195
197
|
|
196
198
|
def version_from_right_hand_side(right_hand_side)
|
199
|
+
gem_requirement_versions = gem_requirement_versions(right_hand_side)
|
200
|
+
|
197
201
|
if right_hand_side.array_type?
|
198
202
|
version_from_array(right_hand_side)
|
199
|
-
elsif
|
200
|
-
|
203
|
+
elsif gem_requirement_versions
|
204
|
+
gem_requirement_versions.map(&:value)
|
201
205
|
else
|
202
206
|
right_hand_side.value
|
203
207
|
end
|
data/lib/rubocop/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.56.
|
4
|
+
version: 1.56.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-08-
|
13
|
+
date: 2023-08-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: base64
|
@@ -196,9 +196,9 @@ dependencies:
|
|
196
196
|
- - "<"
|
197
197
|
- !ruby/object:Gem::Version
|
198
198
|
version: '3.0'
|
199
|
-
description: |
|
200
|
-
|
201
|
-
|
199
|
+
description: |
|
200
|
+
RuboCop is a Ruby code style checking and code formatting tool.
|
201
|
+
It aims to enforce the community-driven Ruby Style Guide.
|
202
202
|
email: rubocop@googlegroups.com
|
203
203
|
executables:
|
204
204
|
- rubocop
|