rubocop 1.34.1 → 1.35.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 +22 -0
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +32 -2
- data/lib/rubocop/cop/gemspec/require_mfa.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/numblock_handler.rb +69 -0
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/layout/block_alignment.rb +2 -0
- data/lib/rubocop/cop/layout/block_end_newline.rb +2 -0
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +5 -2
- data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +2 -0
- data/lib/rubocop/cop/layout/indentation_width.rb +2 -0
- data/lib/rubocop/cop/layout/line_length.rb +4 -1
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +2 -0
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -1
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +2 -0
- data/lib/rubocop/cop/lint/empty_block.rb +1 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +9 -9
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +25 -6
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +12 -0
- data/lib/rubocop/cop/lint/redundant_with_index.rb +13 -10
- data/lib/rubocop/cop/lint/redundant_with_object.rb +12 -11
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +1 -0
- data/lib/rubocop/cop/lint/unreachable_loop.rb +7 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +6 -4
- data/lib/rubocop/cop/lint/void.rb +2 -0
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +76 -1
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -1
- data/lib/rubocop/cop/mixin/method_complexity.rb +4 -4
- data/lib/rubocop/cop/mixin/range_help.rb +2 -3
- data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
- data/lib/rubocop/cop/style/arguments_forwarding.rb +2 -2
- data/lib/rubocop/cop/style/class_methods_definitions.rb +2 -1
- data/lib/rubocop/cop/style/collection_methods.rb +2 -0
- data/lib/rubocop/cop/style/combinable_loops.rb +3 -1
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
- data/lib/rubocop/cop/style/each_with_object.rb +39 -8
- data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
- data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
- data/lib/rubocop/cop/style/for.rb +2 -0
- data/lib/rubocop/cop/style/hash_each_methods.rb +3 -1
- data/lib/rubocop/cop/style/hash_syntax.rb +17 -0
- data/lib/rubocop/cop/style/inverse_methods.rb +8 -6
- data/lib/rubocop/cop/style/magic_comment_format.rb +307 -0
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +4 -1
- data/lib/rubocop/cop/style/multiline_block_chain.rb +3 -1
- data/lib/rubocop/cop/style/next.rb +2 -0
- data/lib/rubocop/cop/style/nil_lambda.rb +1 -1
- data/lib/rubocop/cop/style/object_then.rb +2 -0
- data/lib/rubocop/cop/style/proc.rb +4 -1
- data/lib/rubocop/cop/style/redundant_begin.rb +2 -0
- data/lib/rubocop/cop/style/redundant_fetch_block.rb +1 -1
- data/lib/rubocop/cop/style/redundant_self.rb +2 -0
- data/lib/rubocop/cop/style/redundant_sort_by.rb +24 -8
- data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
- data/lib/rubocop/cop/style/top_level_method_definition.rb +3 -1
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
- data/lib/rubocop/feature_loader.rb +3 -1
- data/lib/rubocop/server/cache.rb +4 -2
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +2 -1
- metadata +7 -5
@@ -0,0 +1,307 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
# Ensures magic comments are written consistently throughout your code base.
|
7
|
+
# Looks for discrepancies in separators (`-` vs `_`) and capitalization for
|
8
|
+
# both magic comment directives and values.
|
9
|
+
#
|
10
|
+
# Required capitalization can be set with the `DirectiveCapitalization` and
|
11
|
+
# `ValueCapitalization` configuration keys.
|
12
|
+
#
|
13
|
+
# NOTE: If one of these configuration is set to nil, any capitalization is allowed.
|
14
|
+
#
|
15
|
+
# @example EnforcedStyle: snake_case (default)
|
16
|
+
# # The `snake_case` style will enforce that the frozen string literal
|
17
|
+
# # comment is written in snake case. (Words separated by underscores)
|
18
|
+
# # bad
|
19
|
+
# # frozen-string-literal: true
|
20
|
+
#
|
21
|
+
# module Bar
|
22
|
+
# # ...
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# # good
|
26
|
+
# # frozen_string_literal: false
|
27
|
+
#
|
28
|
+
# module Bar
|
29
|
+
# # ...
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# @example EnforcedStyle: kebab_case
|
33
|
+
# # The `kebab_case` style will enforce that the frozen string literal
|
34
|
+
# # comment is written in kebab case. (Words separated by hyphens)
|
35
|
+
# # bad
|
36
|
+
# # frozen_string_literal: true
|
37
|
+
#
|
38
|
+
# module Baz
|
39
|
+
# # ...
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# # good
|
43
|
+
# # frozen-string-literal: true
|
44
|
+
#
|
45
|
+
# module Baz
|
46
|
+
# # ...
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# @example DirectiveCapitalization: lowercase (default)
|
50
|
+
# # bad
|
51
|
+
# # FROZEN-STRING-LITERAL: true
|
52
|
+
#
|
53
|
+
# # good
|
54
|
+
# # frozen-string-literal: true
|
55
|
+
#
|
56
|
+
# @example DirectiveCapitalization: uppercase
|
57
|
+
# # bad
|
58
|
+
# # frozen-string-literal: true
|
59
|
+
#
|
60
|
+
# # good
|
61
|
+
# # FROZEN-STRING-LITERAL: true
|
62
|
+
#
|
63
|
+
# @example DirectiveCapitalization: nil
|
64
|
+
# # any capitalization is accepted
|
65
|
+
#
|
66
|
+
# # good
|
67
|
+
# # frozen-string-literal: true
|
68
|
+
#
|
69
|
+
# # good
|
70
|
+
# # FROZEN-STRING-LITERAL: true
|
71
|
+
#
|
72
|
+
# @example ValueCapitalization: nil (default)
|
73
|
+
# # any capitalization is accepted
|
74
|
+
#
|
75
|
+
# # good
|
76
|
+
# # frozen-string-literal: true
|
77
|
+
#
|
78
|
+
# # good
|
79
|
+
# # frozen-string-literal: TRUE
|
80
|
+
#
|
81
|
+
# @example ValueCapitalization: lowercase
|
82
|
+
# # when a value is not given, any capitalization is accepted
|
83
|
+
#
|
84
|
+
# # bad
|
85
|
+
# # frozen-string-literal: TRUE
|
86
|
+
#
|
87
|
+
# # good
|
88
|
+
# # frozen-string-literal: TRUE
|
89
|
+
#
|
90
|
+
# @example ValueCapitalization: uppercase
|
91
|
+
# # bad
|
92
|
+
# # frozen-string-literal: true
|
93
|
+
#
|
94
|
+
# # good
|
95
|
+
# # frozen-string-literal: TRUE
|
96
|
+
#
|
97
|
+
class MagicCommentFormat < Base
|
98
|
+
include ConfigurableEnforcedStyle
|
99
|
+
extend AutoCorrector
|
100
|
+
|
101
|
+
SNAKE_SEPARATOR = '_'
|
102
|
+
KEBAB_SEPARATOR = '-'
|
103
|
+
MSG = 'Prefer %<style>s case for magic comments.'
|
104
|
+
MSG_VALUE = 'Prefer %<case>s for magic comment values.'
|
105
|
+
|
106
|
+
# Value object to extract source ranges for the different parts of a magic comment
|
107
|
+
class CommentRange
|
108
|
+
extend Forwardable
|
109
|
+
|
110
|
+
DIRECTIVE_REGEXP = Regexp.union(MagicComment::KEYWORDS.map do |_, v|
|
111
|
+
Regexp.new(v, Regexp::IGNORECASE)
|
112
|
+
end).freeze
|
113
|
+
|
114
|
+
VALUE_REGEXP = Regexp.new("(?:#{DIRECTIVE_REGEXP}:\s*)(.*?)(?=;|$)")
|
115
|
+
|
116
|
+
def_delegators :@comment, :text, :loc
|
117
|
+
attr_reader :comment
|
118
|
+
|
119
|
+
def initialize(comment)
|
120
|
+
@comment = comment
|
121
|
+
end
|
122
|
+
|
123
|
+
# A magic comment can contain one directive (normal style) or
|
124
|
+
# multiple directives (emacs style)
|
125
|
+
def directives
|
126
|
+
@directives ||= begin
|
127
|
+
matches = []
|
128
|
+
|
129
|
+
text.scan(DIRECTIVE_REGEXP) do
|
130
|
+
offset = Regexp.last_match.offset(0)
|
131
|
+
matches << loc.expression.adjust(begin_pos: offset.first)
|
132
|
+
.with(end_pos: loc.expression.begin_pos + offset.last)
|
133
|
+
end
|
134
|
+
|
135
|
+
matches
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# A magic comment can contain one value (normal style) or
|
140
|
+
# multiple directives (emacs style)
|
141
|
+
def values
|
142
|
+
@values ||= begin
|
143
|
+
matches = []
|
144
|
+
|
145
|
+
text.scan(VALUE_REGEXP) do
|
146
|
+
offset = Regexp.last_match.offset(1)
|
147
|
+
matches << loc.expression.adjust(begin_pos: offset.first)
|
148
|
+
.with(end_pos: loc.expression.begin_pos + offset.last)
|
149
|
+
end
|
150
|
+
|
151
|
+
matches
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def on_new_investigation
|
157
|
+
return unless processed_source.ast
|
158
|
+
|
159
|
+
magic_comments.each do |comment|
|
160
|
+
issues = find_issues(comment)
|
161
|
+
register_offenses(issues) if issues.any?
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
private
|
166
|
+
|
167
|
+
def magic_comments
|
168
|
+
processed_source.each_comment_in_lines(leading_comment_lines)
|
169
|
+
.select { |comment| MagicComment.parse(comment.text).valid? }
|
170
|
+
.map { |comment| CommentRange.new(comment) }
|
171
|
+
end
|
172
|
+
|
173
|
+
def leading_comment_lines
|
174
|
+
first_non_comment_token = processed_source.tokens.find { |token| !token.comment? }
|
175
|
+
|
176
|
+
if first_non_comment_token
|
177
|
+
0...first_non_comment_token.line
|
178
|
+
else
|
179
|
+
(0..)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def find_issues(comment)
|
184
|
+
issues = { directives: [], values: [] }
|
185
|
+
|
186
|
+
comment.directives.each do |directive|
|
187
|
+
issues[:directives] << directive if directive_offends?(directive)
|
188
|
+
end
|
189
|
+
|
190
|
+
comment.values.each do |value| # rubocop:disable Style/HashEachMethods
|
191
|
+
issues[:values] << value if wrong_capitalization?(value.source, value_capitalization)
|
192
|
+
end
|
193
|
+
|
194
|
+
issues
|
195
|
+
end
|
196
|
+
|
197
|
+
def directive_offends?(directive)
|
198
|
+
incorrect_separator?(directive.source) ||
|
199
|
+
wrong_capitalization?(directive.source, directive_capitalization)
|
200
|
+
end
|
201
|
+
|
202
|
+
def register_offenses(issues)
|
203
|
+
fix_directives(issues[:directives])
|
204
|
+
fix_values(issues[:values])
|
205
|
+
end
|
206
|
+
|
207
|
+
def fix_directives(issues)
|
208
|
+
return if issues.empty?
|
209
|
+
|
210
|
+
msg = format(MSG, style: expected_style)
|
211
|
+
|
212
|
+
issues.each do |directive|
|
213
|
+
add_offense(directive, message: msg) do |corrector|
|
214
|
+
replacement = replace_separator(replace_capitalization(directive.source,
|
215
|
+
directive_capitalization))
|
216
|
+
corrector.replace(directive, replacement)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def fix_values(issues)
|
222
|
+
return if issues.empty?
|
223
|
+
|
224
|
+
msg = format(MSG_VALUE, case: value_capitalization)
|
225
|
+
|
226
|
+
issues.each do |value|
|
227
|
+
add_offense(value, message: msg) do |corrector|
|
228
|
+
corrector.replace(value, replace_capitalization(value.source, value_capitalization))
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def expected_style
|
234
|
+
[directive_capitalization, style].compact.join(' ').gsub(/_?case\b/, '')
|
235
|
+
end
|
236
|
+
|
237
|
+
def wrong_separator
|
238
|
+
style == :snake_case ? KEBAB_SEPARATOR : SNAKE_SEPARATOR
|
239
|
+
end
|
240
|
+
|
241
|
+
def correct_separator
|
242
|
+
style == :snake_case ? SNAKE_SEPARATOR : KEBAB_SEPARATOR
|
243
|
+
end
|
244
|
+
|
245
|
+
def incorrect_separator?(text)
|
246
|
+
text[wrong_separator]
|
247
|
+
end
|
248
|
+
|
249
|
+
def wrong_capitalization?(text, expected_case)
|
250
|
+
return false unless expected_case
|
251
|
+
|
252
|
+
case expected_case
|
253
|
+
when :lowercase
|
254
|
+
text != text.downcase
|
255
|
+
when :uppercase
|
256
|
+
text != text.upcase
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def replace_separator(text)
|
261
|
+
text.tr(wrong_separator, correct_separator)
|
262
|
+
end
|
263
|
+
|
264
|
+
def replace_capitalization(text, style)
|
265
|
+
return text unless style
|
266
|
+
|
267
|
+
case style
|
268
|
+
when :lowercase
|
269
|
+
text.downcase
|
270
|
+
when :uppercase
|
271
|
+
text.upcase
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
def line_range(line)
|
276
|
+
processed_source.buffer.line_range(line)
|
277
|
+
end
|
278
|
+
|
279
|
+
def directive_capitalization
|
280
|
+
cop_config['DirectiveCapitalization']&.to_sym.tap do |style|
|
281
|
+
unless valid_capitalization?(style)
|
282
|
+
raise "Unknown `DirectiveCapitalization` #{style} selected!"
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
def value_capitalization
|
288
|
+
cop_config['ValueCapitalization']&.to_sym.tap do |style|
|
289
|
+
unless valid_capitalization?(style)
|
290
|
+
raise "Unknown `ValueCapitalization` #{style} selected!"
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
def valid_capitalization?(style)
|
296
|
+
return true unless style
|
297
|
+
|
298
|
+
supported_capitalizations.include?(style)
|
299
|
+
end
|
300
|
+
|
301
|
+
def supported_capitalizations
|
302
|
+
cop_config['SupportedCapitalizations'].map(&:to_sym)
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
@@ -35,12 +35,15 @@ module RuboCop
|
|
35
35
|
ignore_node(node.send_node)
|
36
36
|
end
|
37
37
|
|
38
|
+
alias on_numblock on_block
|
39
|
+
|
38
40
|
def on_send(node)
|
39
41
|
return if ignored_node?(node)
|
40
42
|
|
41
43
|
receiver = node.receiver
|
42
44
|
|
43
|
-
return unless receiver&.block_type?
|
45
|
+
return unless (receiver&.block_type? || receiver&.numblock_type?) &&
|
46
|
+
receiver.loc.end.is?('end')
|
44
47
|
|
45
48
|
range = range_between(receiver.loc.end.begin_pos, node.source_range.end_pos)
|
46
49
|
|
@@ -31,7 +31,7 @@ module RuboCop
|
|
31
31
|
node.send_node.each_node(:send) do |send_node|
|
32
32
|
receiver = send_node.receiver
|
33
33
|
|
34
|
-
next unless receiver&.block_type? && receiver&.multiline?
|
34
|
+
next unless (receiver&.block_type? || receiver&.numblock_type?) && receiver&.multiline?
|
35
35
|
|
36
36
|
range = range_between(receiver.loc.end.begin_pos, node.send_node.source_range.end_pos)
|
37
37
|
|
@@ -42,6 +42,8 @@ module RuboCop
|
|
42
42
|
break
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
alias on_numblock on_block
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -19,7 +19,8 @@ module RuboCop
|
|
19
19
|
MSG = 'Use `proc` instead of `Proc.new`.'
|
20
20
|
|
21
21
|
# @!method proc_new?(node)
|
22
|
-
def_node_matcher :proc_new?,
|
22
|
+
def_node_matcher :proc_new?,
|
23
|
+
'({block numblock} $(send (const {nil? cbase} :Proc) :new) ...)'
|
23
24
|
|
24
25
|
def on_block(node)
|
25
26
|
proc_new?(node) do |block_method|
|
@@ -28,6 +29,8 @@ module RuboCop
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
32
|
+
|
33
|
+
alias on_numblock on_block
|
31
34
|
end
|
32
35
|
end
|
33
36
|
end
|
@@ -50,7 +50,7 @@ module RuboCop
|
|
50
50
|
${nil? #basic_literal? #const_type?})
|
51
51
|
PATTERN
|
52
52
|
|
53
|
-
def on_block(node)
|
53
|
+
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
|
54
54
|
redundant_fetch_block_candidate?(node) do |send, body|
|
55
55
|
return if should_not_check?(send, body)
|
56
56
|
|
@@ -120,6 +120,8 @@ module RuboCop
|
|
120
120
|
add_scope(node, @local_variables_scopes[node])
|
121
121
|
end
|
122
122
|
|
123
|
+
alias on_numblock on_block
|
124
|
+
|
123
125
|
def on_if(node)
|
124
126
|
# Allow conditional nodes to use `self` in the condition if that variable
|
125
127
|
# name is used in an `lvasgn` or `masgn` within the `if`.
|
@@ -19,18 +19,24 @@ module RuboCop
|
|
19
19
|
include RangeHelp
|
20
20
|
extend AutoCorrector
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
# @!method redundant_sort_by(node)
|
25
|
-
def_node_matcher :redundant_sort_by, <<~PATTERN
|
26
|
-
(block $(send _ :sort_by) (args (arg $_x)) (lvar _x))
|
27
|
-
PATTERN
|
22
|
+
MSG_BLOCK = 'Use `sort` instead of `sort_by { |%<var>s| %<var>s }`.'
|
23
|
+
MSG_NUMBLOCK = 'Use `sort` instead of `sort_by { _1 }`.'
|
28
24
|
|
29
25
|
def on_block(node)
|
30
|
-
|
26
|
+
redundant_sort_by_block(node) do |send, var_name|
|
31
27
|
range = sort_by_range(send, node)
|
32
28
|
|
33
|
-
add_offense(range, message: format(
|
29
|
+
add_offense(range, message: format(MSG_BLOCK, var: var_name)) do |corrector|
|
30
|
+
corrector.replace(range, 'sort')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def on_numblock(node)
|
36
|
+
redundant_sort_by_numblock(node) do |send|
|
37
|
+
range = sort_by_range(send, node)
|
38
|
+
|
39
|
+
add_offense(range, message: format(MSG_NUMBLOCK)) do |corrector|
|
34
40
|
corrector.replace(range, 'sort')
|
35
41
|
end
|
36
42
|
end
|
@@ -38,6 +44,16 @@ module RuboCop
|
|
38
44
|
|
39
45
|
private
|
40
46
|
|
47
|
+
# @!method redundant_sort_by_block(node)
|
48
|
+
def_node_matcher :redundant_sort_by_block, <<~PATTERN
|
49
|
+
(block $(send _ :sort_by) (args (arg $_x)) (lvar _x))
|
50
|
+
PATTERN
|
51
|
+
|
52
|
+
# @!method redundant_sort_by_numblock(node)
|
53
|
+
def_node_matcher :redundant_sort_by_numblock, <<~PATTERN
|
54
|
+
(numblock $(send _ :sort_by) 1 (lvar :_1))
|
55
|
+
PATTERN
|
56
|
+
|
41
57
|
def sort_by_range(send, node)
|
42
58
|
range_between(send.loc.selector.begin_pos, node.loc.end.end_pos)
|
43
59
|
end
|
@@ -63,6 +63,8 @@ module RuboCop
|
|
63
63
|
add_offense(node)
|
64
64
|
end
|
65
65
|
|
66
|
+
alias on_numblock on_block
|
67
|
+
|
66
68
|
private
|
67
69
|
|
68
70
|
def top_level_method_definition?(node)
|
@@ -75,7 +77,7 @@ module RuboCop
|
|
75
77
|
|
76
78
|
# @!method define_method_block?(node)
|
77
79
|
def_node_matcher :define_method_block?, <<~PATTERN
|
78
|
-
(block (send _ {:define_method} _) ...)
|
80
|
+
({block numblock} (send _ {:define_method} _) ...)
|
79
81
|
PATTERN
|
80
82
|
end
|
81
83
|
end
|
@@ -64,7 +64,7 @@ module RuboCop
|
|
64
64
|
|
65
65
|
MSG = 'Useless trailing comma present in block arguments.'
|
66
66
|
|
67
|
-
def on_block(node)
|
67
|
+
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
|
68
68
|
# lambda literal (`->`) never has block arguments.
|
69
69
|
return if node.send_node.lambda_literal?
|
70
70
|
return unless useless_trailing_comma?(node)
|
@@ -37,7 +37,9 @@ module RuboCop
|
|
37
37
|
raise if e.path != target
|
38
38
|
|
39
39
|
begin
|
40
|
-
|
40
|
+
# Don't use `::Kernel.require(target)` to prevent the following error:
|
41
|
+
# https://github.com/rubocop/rubocop/issues/10893
|
42
|
+
require(namespaced_target)
|
41
43
|
rescue ::LoadError => error_for_namespaced_target
|
42
44
|
raise e if error_for_namespaced_target.path == namespaced_target
|
43
45
|
|
data/lib/rubocop/server/cache.rb
CHANGED
@@ -69,10 +69,12 @@ module RuboCop
|
|
69
69
|
config_yaml = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('4.0.0')
|
70
70
|
YAML.safe_load_file(config_path, permitted_classes: [Regexp, Symbol])
|
71
71
|
else
|
72
|
-
YAML.load_file(config_path)
|
72
|
+
config = YAML.load_file(config_path)
|
73
|
+
|
74
|
+
config == false ? nil : config
|
73
75
|
end
|
74
76
|
|
75
|
-
config_yaml
|
77
|
+
config_yaml&.dig('AllCops', 'CacheRootDirectory')
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
@@ -48,6 +48,7 @@ require_relative 'rubocop/cop/severity'
|
|
48
48
|
require_relative 'rubocop/cop/generator'
|
49
49
|
require_relative 'rubocop/cop/generator/configuration_injector'
|
50
50
|
require_relative 'rubocop/cop/generator/require_file_injector'
|
51
|
+
require_relative 'rubocop/magic_comment'
|
51
52
|
|
52
53
|
require_relative 'rubocop/cop/variable_force'
|
53
54
|
require_relative 'rubocop/cop/variable_force/branch'
|
@@ -529,6 +530,7 @@ require_relative 'rubocop/cop/style/keyword_parameters_order'
|
|
529
530
|
require_relative 'rubocop/cop/style/lambda'
|
530
531
|
require_relative 'rubocop/cop/style/lambda_call'
|
531
532
|
require_relative 'rubocop/cop/style/line_end_concatenation'
|
533
|
+
require_relative 'rubocop/cop/style/magic_comment_format'
|
532
534
|
require_relative 'rubocop/cop/style/map_to_hash'
|
533
535
|
require_relative 'rubocop/cop/style/method_call_without_args_parentheses'
|
534
536
|
require_relative 'rubocop/cop/style/method_call_with_args_parentheses'
|
@@ -695,7 +697,6 @@ require_relative 'rubocop/lockfile'
|
|
695
697
|
require_relative 'rubocop/target_finder'
|
696
698
|
require_relative 'rubocop/directive_comment'
|
697
699
|
require_relative 'rubocop/comment_config'
|
698
|
-
require_relative 'rubocop/magic_comment'
|
699
700
|
require_relative 'rubocop/result_cache'
|
700
701
|
require_relative 'rubocop/runner'
|
701
702
|
require_relative 'rubocop/cli'
|
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.
|
4
|
+
version: 1.35.0
|
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: 2022-08-
|
13
|
+
date: 2022-08-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
requirements:
|
121
121
|
- - ">="
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: 1.20.
|
123
|
+
version: 1.20.1
|
124
124
|
- - "<"
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '2.0'
|
@@ -130,7 +130,7 @@ dependencies:
|
|
130
130
|
requirements:
|
131
131
|
- - ">="
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: 1.20.
|
133
|
+
version: 1.20.1
|
134
134
|
- - "<"
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '2.0'
|
@@ -293,6 +293,7 @@ files:
|
|
293
293
|
- lib/rubocop/cop/internal_affairs/node_destructuring.rb
|
294
294
|
- lib/rubocop/cop/internal_affairs/node_matcher_directive.rb
|
295
295
|
- lib/rubocop/cop/internal_affairs/node_type_predicate.rb
|
296
|
+
- lib/rubocop/cop/internal_affairs/numblock_handler.rb
|
296
297
|
- lib/rubocop/cop/internal_affairs/offense_location_keyword.rb
|
297
298
|
- lib/rubocop/cop/internal_affairs/redundant_context_config_parameter.rb
|
298
299
|
- lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb
|
@@ -748,6 +749,7 @@ files:
|
|
748
749
|
- lib/rubocop/cop/style/lambda.rb
|
749
750
|
- lib/rubocop/cop/style/lambda_call.rb
|
750
751
|
- lib/rubocop/cop/style/line_end_concatenation.rb
|
752
|
+
- lib/rubocop/cop/style/magic_comment_format.rb
|
751
753
|
- lib/rubocop/cop/style/map_compact_with_conditional_block.rb
|
752
754
|
- lib/rubocop/cop/style/map_to_hash.rb
|
753
755
|
- lib/rubocop/cop/style/method_call_with_args_parentheses.rb
|
@@ -975,7 +977,7 @@ metadata:
|
|
975
977
|
homepage_uri: https://rubocop.org/
|
976
978
|
changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
|
977
979
|
source_code_uri: https://github.com/rubocop/rubocop/
|
978
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
980
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.35/
|
979
981
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
980
982
|
rubygems_mfa_required: 'true'
|
981
983
|
post_install_message:
|