rubocop 1.64.0 → 1.65.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 -2
- data/config/default.yml +11 -1
- data/lib/rubocop/config_loader.rb +1 -1
- data/lib/rubocop/config_loader_resolver.rb +9 -3
- data/lib/rubocop/cop/cop.rb +20 -2
- data/lib/rubocop/cop/force.rb +12 -0
- data/lib/rubocop/cop/gemspec/add_runtime_dependency.rb +38 -0
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -2
- data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +3 -3
- data/lib/rubocop/cop/layout/case_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb +1 -1
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +1 -1
- data/lib/rubocop/cop/layout/line_length.rb +20 -20
- data/lib/rubocop/cop/layout/space_around_operators.rb +3 -0
- data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +3 -4
- data/lib/rubocop/cop/legacy/corrector.rb +12 -2
- data/lib/rubocop/cop/lint/duplicate_case_condition.rb +1 -1
- data/lib/rubocop/cop/lint/empty_when.rb +1 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +21 -14
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +14 -7
- data/lib/rubocop/cop/lint/literal_as_condition.rb +1 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +2 -9
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -0
- data/lib/rubocop/cop/lint/void.rb +5 -0
- data/lib/rubocop/cop/metrics/block_nesting.rb +19 -7
- data/lib/rubocop/cop/mixin/alignment.rb +5 -1
- data/lib/rubocop/cop/mixin/allowed_methods.rb +7 -1
- data/lib/rubocop/cop/mixin/allowed_pattern.rb +15 -3
- data/lib/rubocop/cop/mixin/configurable_max.rb +5 -1
- data/lib/rubocop/cop/mixin/rescue_node.rb +4 -0
- data/lib/rubocop/cop/style/arguments_forwarding.rb +1 -1
- data/lib/rubocop/cop/style/copyright.rb +5 -2
- data/lib/rubocop/cop/style/documentation.rb +24 -24
- data/lib/rubocop/cop/style/hash_except.rb +8 -5
- data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +77 -43
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +5 -0
- data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
- data/lib/rubocop/cop/style/redundant_begin.rb +1 -1
- data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +1 -1
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +2 -1
- data/lib/rubocop/cop/style/send_with_literal_method_name.rb +23 -2
- data/lib/rubocop/cop/style/super_arguments.rb +52 -15
- data/lib/rubocop/cop/style/symbol_proc.rb +8 -1
- data/lib/rubocop/cop/style/zero_length_predicate.rb +28 -24
- data/lib/rubocop/cop/team.rb +10 -0
- data/lib/rubocop/cop/util.rb +7 -1
- data/lib/rubocop/cops_documentation_generator.rb +1 -1
- data/lib/rubocop/ext/regexp_parser.rb +4 -21
- data/lib/rubocop/formatter/html_formatter.rb +3 -1
- data/lib/rubocop/lsp/routes.rb +1 -1
- data/lib/rubocop/rspec/shared_contexts.rb +20 -0
- data/lib/rubocop/rspec/support.rb +1 -0
- data/lib/rubocop/server/cache.rb +10 -0
- data/lib/rubocop/server/client_command/exec.rb +2 -2
- data/lib/rubocop/server/client_command/start.rb +1 -1
- data/lib/rubocop/server/core.rb +4 -0
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +1 -0
- metadata +7 -6
@@ -3,8 +3,25 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Style
|
6
|
-
# Checks for redundant argument forwarding when calling super
|
7
|
-
#
|
6
|
+
# Checks for redundant argument forwarding when calling super with arguments identical to
|
7
|
+
# the method definition.
|
8
|
+
#
|
9
|
+
# Using zero arity `super` within a `define_method` block results in `RuntimeError`:
|
10
|
+
#
|
11
|
+
# [source,ruby]
|
12
|
+
# ----
|
13
|
+
# def m
|
14
|
+
# define_method(:foo) { super() } # => OK
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# def m
|
18
|
+
# define_method(:foo) { super } # => RuntimeError
|
19
|
+
# end
|
20
|
+
# ----
|
21
|
+
#
|
22
|
+
# Furthermore, any arguments accompanied by a block may potentially be delegating to
|
23
|
+
# `define_method`, therefore, `super` used within these blocks will be allowed.
|
24
|
+
# This approach might result in false negatives, yet ensuring safe detection takes precedence.
|
8
25
|
#
|
9
26
|
# @example
|
10
27
|
# # bad
|
@@ -26,22 +43,34 @@ module RuboCop
|
|
26
43
|
# def method(*args, **kwargs)
|
27
44
|
# super()
|
28
45
|
# end
|
46
|
+
#
|
47
|
+
# # good - assigning to the block variable before calling super
|
48
|
+
# def method(&block)
|
49
|
+
# # Assigning to the block variable would pass the old value to super,
|
50
|
+
# # under this circumstance the block must be referenced explicitly.
|
51
|
+
# block ||= proc { 'fallback behavior' }
|
52
|
+
# super(&block)
|
53
|
+
# end
|
29
54
|
class SuperArguments < Base
|
30
55
|
extend AutoCorrector
|
31
56
|
|
32
57
|
DEF_TYPES = %i[def defs].freeze
|
58
|
+
ASSIGN_TYPES = %i[or_asgn lvasgn].freeze
|
33
59
|
|
34
60
|
MSG = 'Call `super` without arguments and parentheses when the signature is identical.'
|
35
61
|
|
36
62
|
def on_super(super_node)
|
37
63
|
def_node = super_node.ancestors.find do |node|
|
38
|
-
#
|
39
|
-
|
64
|
+
# When defining dynamic methods, implicitly calling `super` is not possible.
|
65
|
+
# Since there is a possibility of delegation to `define_method`,
|
66
|
+
# `super` used within the block is always allowed.
|
67
|
+
break if node.block_type?
|
40
68
|
|
41
69
|
break node if DEF_TYPES.include?(node.type)
|
42
70
|
end
|
43
71
|
return unless def_node
|
44
|
-
return unless arguments_identical?(def_node.arguments.argument_list,
|
72
|
+
return unless arguments_identical?(def_node, def_node.arguments.argument_list,
|
73
|
+
super_node.arguments)
|
45
74
|
|
46
75
|
add_offense(super_node) { |corrector| corrector.replace(super_node, 'super') }
|
47
76
|
end
|
@@ -49,7 +78,7 @@ module RuboCop
|
|
49
78
|
private
|
50
79
|
|
51
80
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
52
|
-
def arguments_identical?(def_args, super_args)
|
81
|
+
def arguments_identical?(def_node, def_args, super_args)
|
53
82
|
super_args = preprocess_super_args(super_args)
|
54
83
|
return false if def_args.size != super_args.size
|
55
84
|
|
@@ -58,7 +87,7 @@ module RuboCop
|
|
58
87
|
next if positional_rest_arg_same(def_arg, super_arg)
|
59
88
|
next if keyword_arg_same?(def_arg, super_arg)
|
60
89
|
next if keyword_rest_arg_same?(def_arg, super_arg)
|
61
|
-
next if block_arg_same?(def_arg, super_arg)
|
90
|
+
next if block_arg_same?(def_node, def_arg, super_arg)
|
62
91
|
next if forward_arg_same?(def_arg, super_arg)
|
63
92
|
|
64
93
|
return false
|
@@ -104,22 +133,30 @@ module RuboCop
|
|
104
133
|
def_arg.name == lvar_node.children.first
|
105
134
|
end
|
106
135
|
|
107
|
-
def block_arg_same?(def_arg, super_arg)
|
136
|
+
def block_arg_same?(def_node, def_arg, super_arg)
|
108
137
|
return false unless def_arg.blockarg_type? && super_arg.block_pass_type?
|
109
138
|
# anonymous forwarding
|
110
139
|
return true if (block_pass_child = super_arg.children.first).nil? && def_arg.name.nil?
|
111
140
|
|
112
|
-
|
141
|
+
block_arg_name = block_pass_child.children.first
|
142
|
+
def_arg.name == block_arg_name && !block_reassigned?(def_node, block_arg_name)
|
113
143
|
end
|
114
144
|
|
115
|
-
|
116
|
-
|
117
|
-
|
145
|
+
# Reassigning the block argument will still pass along the original block to super
|
146
|
+
# https://bugs.ruby-lang.org/issues/20505
|
147
|
+
def block_reassigned?(def_node, block_arg_name)
|
148
|
+
def_node.each_node(*ASSIGN_TYPES).any? do |assign_node|
|
149
|
+
# TODO: Since `Symbol#name` is supported from Ruby 3.0, the inheritance check for
|
150
|
+
# `AST::Node` can be removed when requiring Ruby 3.0+.
|
151
|
+
lhs = assign_node.node_parts[0]
|
152
|
+
next if lhs.is_a?(AST::Node) && !lhs.respond_to?(:name)
|
118
153
|
|
119
|
-
|
120
|
-
|
154
|
+
assign_node.name == block_arg_name
|
155
|
+
end
|
156
|
+
end
|
121
157
|
|
122
|
-
|
158
|
+
def forward_arg_same?(def_arg, super_arg)
|
159
|
+
def_arg.forward_arg_type? && super_arg.forwarded_args_type?
|
123
160
|
end
|
124
161
|
|
125
162
|
def preprocess_super_args(super_args)
|
@@ -223,7 +223,14 @@ module RuboCop
|
|
223
223
|
end
|
224
224
|
|
225
225
|
def autocorrect_without_args(corrector, node)
|
226
|
-
|
226
|
+
if node.send_node.lambda_literal?
|
227
|
+
if node.send_node.loc.selector.source == '->'
|
228
|
+
corrector.replace(node, "lambda(&:#{node.body.method_name})")
|
229
|
+
return
|
230
|
+
else
|
231
|
+
autocorrect_lambda_block(corrector, node)
|
232
|
+
end
|
233
|
+
end
|
227
234
|
|
228
235
|
corrector.replace(block_range_with_space(node), "(&:#{node.body.method_name})")
|
229
236
|
end
|
@@ -47,15 +47,16 @@ module RuboCop
|
|
47
47
|
check_zero_length_comparison(node)
|
48
48
|
check_nonzero_length_comparison(node)
|
49
49
|
end
|
50
|
+
alias on_csend on_send
|
50
51
|
|
51
52
|
private
|
52
53
|
|
53
54
|
def check_zero_length_predicate(node)
|
54
|
-
return unless
|
55
|
+
return unless zero_length_predicate?(node.parent)
|
55
56
|
return if non_polymorphic_collection?(node.parent)
|
56
57
|
|
57
58
|
offense = node.loc.selector.join(node.parent.source_range.end)
|
58
|
-
message = format(ZERO_MSG, current:
|
59
|
+
message = format(ZERO_MSG, current: offense.source)
|
59
60
|
|
60
61
|
add_offense(offense, message: message) do |corrector|
|
61
62
|
corrector.replace(offense, 'empty?')
|
@@ -92,44 +93,47 @@ module RuboCop
|
|
92
93
|
end
|
93
94
|
end
|
94
95
|
|
95
|
-
# @!method zero_length_predicate(node)
|
96
|
-
def_node_matcher :zero_length_predicate
|
97
|
-
(
|
96
|
+
# @!method zero_length_predicate?(node)
|
97
|
+
def_node_matcher :zero_length_predicate?, <<~PATTERN
|
98
|
+
(call (call (...) {:length :size}) :zero?)
|
98
99
|
PATTERN
|
99
100
|
|
100
101
|
# @!method zero_length_comparison(node)
|
101
102
|
def_node_matcher :zero_length_comparison, <<~PATTERN
|
102
|
-
{(
|
103
|
-
(
|
104
|
-
(
|
105
|
-
(
|
103
|
+
{(call (call (...) ${:length :size}) $:== (int $0))
|
104
|
+
(call (int $0) $:== (call (...) ${:length :size}))
|
105
|
+
(call (call (...) ${:length :size}) $:< (int $1))
|
106
|
+
(call (int $1) $:> (call (...) ${:length :size}))}
|
106
107
|
PATTERN
|
107
108
|
|
108
109
|
# @!method nonzero_length_comparison(node)
|
109
110
|
def_node_matcher :nonzero_length_comparison, <<~PATTERN
|
110
|
-
{(
|
111
|
-
(
|
111
|
+
{(call (call (...) ${:length :size}) ${:> :!=} (int $0))
|
112
|
+
(call (int $0) ${:< :!=} (call (...) ${:length :size}))}
|
112
113
|
PATTERN
|
113
114
|
|
114
115
|
def replacement(node)
|
115
|
-
|
116
|
-
|
116
|
+
length_node = zero_length_node(node)
|
117
|
+
if length_node&.receiver
|
118
|
+
return "#{length_node.receiver.source}#{length_node.loc.dot.source}empty?"
|
119
|
+
end
|
117
120
|
|
118
|
-
|
121
|
+
other_length_node = other_length_node(node)
|
122
|
+
"!#{other_length_node.receiver.source}#{other_length_node.loc.dot.source}empty?"
|
119
123
|
end
|
120
124
|
|
121
|
-
# @!method
|
122
|
-
def_node_matcher :
|
123
|
-
{(send (
|
124
|
-
(send (int 0) :== (
|
125
|
-
(send (
|
126
|
-
(send (int 1) :> (
|
125
|
+
# @!method zero_length_node(node)
|
126
|
+
def_node_matcher :zero_length_node, <<~PATTERN
|
127
|
+
{(send $(call _ _) :== (int 0))
|
128
|
+
(send (int 0) :== $(call _ _))
|
129
|
+
(send $(call _ _) :< (int 1))
|
130
|
+
(send (int 1) :> $(call _ _))}
|
127
131
|
PATTERN
|
128
132
|
|
129
|
-
# @!method
|
130
|
-
def_node_matcher :
|
131
|
-
{(
|
132
|
-
(
|
133
|
+
# @!method other_length_node(node)
|
134
|
+
def_node_matcher :other_length_node, <<~PATTERN
|
135
|
+
{(call $(call _ _) _ _)
|
136
|
+
(call _ _ $(call _ _))}
|
133
137
|
PATTERN
|
134
138
|
|
135
139
|
# Some collection like objects in the Ruby standard library
|
data/lib/rubocop/cop/team.rb
CHANGED
@@ -74,6 +74,10 @@ module RuboCop
|
|
74
74
|
# @deprecated. Use investigate
|
75
75
|
# @return Array<offenses>
|
76
76
|
def inspect_file(processed_source)
|
77
|
+
warn Rainbow(<<~WARNING).yellow, uplevel: 1
|
78
|
+
`inspect_file` is deprecated. Use `investigate` instead.
|
79
|
+
WARNING
|
80
|
+
|
77
81
|
investigate(processed_source).offenses
|
78
82
|
end
|
79
83
|
|
@@ -108,6 +112,10 @@ module RuboCop
|
|
108
112
|
|
109
113
|
# @deprecated
|
110
114
|
def forces
|
115
|
+
warn Rainbow(<<~WARNING).yellow, uplevel: 1
|
116
|
+
`forces` is deprecated.
|
117
|
+
WARNING
|
118
|
+
|
111
119
|
@forces ||= self.class.forces_for(cops)
|
112
120
|
end
|
113
121
|
|
@@ -240,6 +248,8 @@ module RuboCop
|
|
240
248
|
|
241
249
|
if cause.is_a?(Warning)
|
242
250
|
handle_warning(cause, location)
|
251
|
+
elsif cause.is_a?(Force::HookError)
|
252
|
+
handle_error(cause.cause, location, cause.joining_cop)
|
243
253
|
else
|
244
254
|
handle_error(cause, location, error.cop)
|
245
255
|
end
|
data/lib/rubocop/cop/util.rb
CHANGED
@@ -20,6 +20,10 @@ module RuboCop
|
|
20
20
|
|
21
21
|
# @deprecated Use `ProcessedSource#line_with_comment?`, `contains_comment?` or similar
|
22
22
|
def comment_lines?(node)
|
23
|
+
warn Rainbow(<<~WARNING).yellow, uplevel: 1
|
24
|
+
`comment_lines?` is deprecated. Use `ProcessedSource#line_with_comment?`, `contains_comment?` or similar instead.
|
25
|
+
WARNING
|
26
|
+
|
23
27
|
processed_source[line_range(node)].any? { |line| comment_line?(line) }
|
24
28
|
end
|
25
29
|
|
@@ -173,7 +177,9 @@ module RuboCop
|
|
173
177
|
def same_line?(node1, node2)
|
174
178
|
line1 = line(node1)
|
175
179
|
line2 = line(node2)
|
176
|
-
|
180
|
+
return false unless line1 && line2
|
181
|
+
|
182
|
+
line1 == line2
|
177
183
|
end
|
178
184
|
|
179
185
|
def indent(node, offset: 0)
|
@@ -306,7 +306,7 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
306
306
|
filename = "#{department_to_basename(department)}.adoc"
|
307
307
|
content = +"=== Department xref:#{filename}[#{type_title}]\n\n"
|
308
308
|
cops_of_department(department).each do |cop|
|
309
|
-
anchor = cop.cop_name.
|
309
|
+
anchor = cop.cop_name.delete('/').downcase
|
310
310
|
content << "* xref:#{filename}##{anchor}[#{cop.cop_name}]\n"
|
311
311
|
end
|
312
312
|
|
@@ -22,26 +22,9 @@ module RuboCop
|
|
22
22
|
module Base
|
23
23
|
attr_accessor :origin
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@expression ||= origin.adjust(begin_pos: ts, end_pos: ts + full_length)
|
29
|
-
end
|
30
|
-
# Please remove this `else` branch when support for regexp_parser 1.8 will be dropped.
|
31
|
-
# It's for compatibility with regexp_parser 1.8 and will never be maintained.
|
32
|
-
else
|
33
|
-
attr_accessor :source
|
34
|
-
|
35
|
-
def start_index
|
36
|
-
# ts is a byte index; convert it to a character index
|
37
|
-
@start_index ||= source.byteslice(0, ts).length
|
38
|
-
end
|
39
|
-
|
40
|
-
# Shortcut to `loc.expression`
|
41
|
-
def expression
|
42
|
-
end_pos = start_index + full_length
|
43
|
-
@expression ||= origin.adjust(begin_pos: start_index, end_pos: end_pos)
|
44
|
-
end
|
25
|
+
# Shortcut to `loc.expression`
|
26
|
+
def expression
|
27
|
+
@expression ||= origin.adjust(begin_pos: ts, end_pos: ts + full_length)
|
45
28
|
end
|
46
29
|
|
47
30
|
# @returns a location map like `parser` does, with:
|
@@ -69,8 +52,8 @@ module RuboCop
|
|
69
52
|
|
70
53
|
body = expression.adjust(end_pos: -q.text.length)
|
71
54
|
q.origin = origin
|
72
|
-
q.source = source if q.respond_to?(:source=) # for regexp_parser 1.8
|
73
55
|
q_loc = q.expression
|
56
|
+
|
74
57
|
{ body: body, quantifier: q_loc }
|
75
58
|
end
|
76
59
|
end
|
@@ -52,7 +52,9 @@ module RuboCop
|
|
52
52
|
|
53
53
|
template = File.read(TEMPLATE_PATH, encoding: Encoding::UTF_8)
|
54
54
|
erb = ERB.new(template)
|
55
|
-
html = erb.result(context.binding).lines.map
|
55
|
+
html = erb.result(context.binding).lines.map do |line|
|
56
|
+
line.match?(/\A\s*\z/) ? "\n" : line
|
57
|
+
end.join
|
56
58
|
|
57
59
|
output.write html
|
58
60
|
end
|
data/lib/rubocop/lsp/routes.rb
CHANGED
@@ -235,7 +235,7 @@ module RuboCop
|
|
235
235
|
def to_range(location)
|
236
236
|
{
|
237
237
|
start: { character: location[:start_column] - 1, line: location[:start_line] - 1 },
|
238
|
-
end: { character: location[:last_column]
|
238
|
+
end: { character: location[:last_column], line: location[:last_line] - 1 }
|
239
239
|
}
|
240
240
|
end
|
241
241
|
end
|
@@ -50,6 +50,26 @@ RSpec.shared_context 'isolated environment' do # rubocop:disable Metrics/BlockLe
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
# Workaround for https://github.com/rubocop/rubocop/issues/12978,
|
54
|
+
# there should already be no gemfile in the temp directory
|
55
|
+
RSpec.shared_context 'isolated bundler' do
|
56
|
+
around do |example|
|
57
|
+
# No bundler env and reset cached gemfile path
|
58
|
+
Bundler.with_unbundled_env do
|
59
|
+
old_values = Bundler.instance_variables.to_h do |name|
|
60
|
+
[name, Bundler.instance_variable_get(name)]
|
61
|
+
end
|
62
|
+
Bundler.instance_variables.each { |name| Bundler.remove_instance_variable(name) }
|
63
|
+
example.call
|
64
|
+
ensure
|
65
|
+
Bundler.instance_variables.each { |name| Bundler.remove_instance_variable(name) }
|
66
|
+
old_values.each do |name, value|
|
67
|
+
Bundler.instance_variable_set(name, value)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
53
73
|
RSpec.shared_context 'maintain registry' do
|
54
74
|
around(:each) { |example| RuboCop::Cop::Registry.with_temporary_global { example.run } }
|
55
75
|
|
@@ -13,6 +13,7 @@ RSpec.configure do |config|
|
|
13
13
|
config.include HostEnvironmentSimulatorHelper
|
14
14
|
config.include_context 'config', :config
|
15
15
|
config.include_context 'isolated environment', :isolated_environment
|
16
|
+
config.include_context 'isolated bundler', :isolated_bundler
|
16
17
|
config.include_context 'lsp', :lsp
|
17
18
|
config.include_context 'maintain registry', :restore_registry
|
18
19
|
config.include_context 'ruby 2.0', :ruby20
|
data/lib/rubocop/server/cache.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'digest'
|
3
4
|
require 'pathname'
|
4
5
|
require_relative '../cache_config'
|
5
6
|
require_relative '../config_finder'
|
@@ -19,6 +20,7 @@ module RuboCop
|
|
19
20
|
# @api private
|
20
21
|
class Cache
|
21
22
|
GEMFILE_NAMES = %w[Gemfile gems.rb].freeze
|
23
|
+
LOCKFILE_NAMES = %w[Gemfile.lock gems.locked].freeze
|
22
24
|
|
23
25
|
class << self
|
24
26
|
attr_accessor :cache_root_path
|
@@ -41,6 +43,14 @@ module RuboCop
|
|
41
43
|
@project_dir_cache_key ||= project_dir[1..].tr('/', '+')
|
42
44
|
end
|
43
45
|
|
46
|
+
def restart_key
|
47
|
+
lockfile_path = LOCKFILE_NAMES.map do |lockfile_name|
|
48
|
+
Pathname(project_dir).join(lockfile_name)
|
49
|
+
end.find(&:exist?)
|
50
|
+
|
51
|
+
Digest::SHA1.hexdigest(lockfile_path&.read || RuboCop::Version::STRING)
|
52
|
+
end
|
53
|
+
|
44
54
|
def dir
|
45
55
|
Pathname.new(File.join(cache_path, project_dir_cache_key)).tap do |d|
|
46
56
|
d.mkpath unless d.exist?
|
@@ -41,7 +41,7 @@ module RuboCop
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def incompatible_version?
|
44
|
-
Cache.version_path.read !=
|
44
|
+
Cache.version_path.read != Cache.restart_key
|
45
45
|
end
|
46
46
|
|
47
47
|
def stderr
|
@@ -54,7 +54,7 @@ module RuboCop
|
|
54
54
|
end
|
55
55
|
|
56
56
|
status = Cache.status_path.read
|
57
|
-
raise "RuboCop server: '#{status}' is not a valid status!"
|
57
|
+
raise "RuboCop server: '#{status}' is not a valid status!" unless /\A\d+\z/.match?(status)
|
58
58
|
|
59
59
|
status.to_i
|
60
60
|
end
|
data/lib/rubocop/server/core.rb
CHANGED
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
@@ -169,6 +169,7 @@ require_relative 'rubocop/cop/bundler/gem_version'
|
|
169
169
|
require_relative 'rubocop/cop/bundler/insecure_protocol_source'
|
170
170
|
require_relative 'rubocop/cop/bundler/ordered_gems'
|
171
171
|
|
172
|
+
require_relative 'rubocop/cop/gemspec/add_runtime_dependency'
|
172
173
|
require_relative 'rubocop/cop/gemspec/dependency_version'
|
173
174
|
require_relative 'rubocop/cop/gemspec/deprecated_attribute_assignment'
|
174
175
|
require_relative 'rubocop/cop/gemspec/development_dependencies'
|
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.65.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: 2024-
|
13
|
+
date: 2024-07-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
97
|
+
version: '2.4'
|
98
98
|
- - "<"
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '3.0'
|
@@ -104,7 +104,7 @@ dependencies:
|
|
104
104
|
requirements:
|
105
105
|
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version: '
|
107
|
+
version: '2.4'
|
108
108
|
- - "<"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3.0'
|
@@ -270,6 +270,7 @@ files:
|
|
270
270
|
- lib/rubocop/cop/documentation.rb
|
271
271
|
- lib/rubocop/cop/exclude_limit.rb
|
272
272
|
- lib/rubocop/cop/force.rb
|
273
|
+
- lib/rubocop/cop/gemspec/add_runtime_dependency.rb
|
273
274
|
- lib/rubocop/cop/gemspec/dependency_version.rb
|
274
275
|
- lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb
|
275
276
|
- lib/rubocop/cop/gemspec/development_dependencies.rb
|
@@ -1034,9 +1035,9 @@ licenses:
|
|
1034
1035
|
- MIT
|
1035
1036
|
metadata:
|
1036
1037
|
homepage_uri: https://rubocop.org/
|
1037
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.
|
1038
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.65.0
|
1038
1039
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1039
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
1040
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.65/
|
1040
1041
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1041
1042
|
rubygems_mfa_required: 'true'
|
1042
1043
|
post_install_message:
|