rubocop 1.63.0 → 1.64.1
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 +1 -2
- data/config/default.yml +18 -3
- data/lib/rubocop/cached_data.rb +11 -3
- data/lib/rubocop/cli/command/show_docs_url.rb +2 -2
- data/lib/rubocop/cli.rb +4 -0
- data/lib/rubocop/config.rb +2 -3
- data/lib/rubocop/cop/base.rb +9 -14
- data/lib/rubocop/cop/bundler/gem_version.rb +3 -5
- data/lib/rubocop/cop/documentation.rb +16 -6
- data/lib/rubocop/cop/force.rb +12 -0
- data/lib/rubocop/cop/gemspec/dependency_version.rb +3 -5
- data/lib/rubocop/cop/internal_affairs/example_description.rb +1 -1
- data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/empty_comment.rb +3 -1
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -0
- data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +3 -4
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +3 -1
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
- data/lib/rubocop/cop/lint/empty_conditional_body.rb +1 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +21 -14
- data/lib/rubocop/cop/lint/mixed_case_range.rb +9 -4
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +1 -1
- data/lib/rubocop/cop/lint/unreachable_code.rb +4 -2
- data/lib/rubocop/cop/lint/unreachable_loop.rb +8 -2
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +5 -5
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +9 -2
- data/lib/rubocop/cop/security/compound_hash.rb +2 -2
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +50 -0
- data/lib/rubocop/cop/style/arguments_forwarding.rb +5 -2
- data/lib/rubocop/cop/style/conditional_assignment.rb +1 -1
- data/lib/rubocop/cop/style/copyright.rb +15 -10
- data/lib/rubocop/cop/style/documentation.rb +24 -24
- data/lib/rubocop/cop/style/documentation_method.rb +20 -0
- data/lib/rubocop/cop/style/eval_with_location.rb +1 -1
- data/lib/rubocop/cop/style/hash_syntax.rb +18 -0
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +5 -3
- data/lib/rubocop/cop/style/map_into_array.rb +3 -3
- data/lib/rubocop/cop/style/numeric_predicate.rb +10 -2
- data/lib/rubocop/cop/style/one_line_conditional.rb +1 -1
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +4 -1
- data/lib/rubocop/cop/style/require_order.rb +1 -1
- data/lib/rubocop/cop/style/send.rb +4 -4
- data/lib/rubocop/cop/style/send_with_literal_method_name.rb +90 -0
- data/lib/rubocop/cop/style/special_global_vars.rb +1 -2
- data/lib/rubocop/cop/style/super_arguments.rb +156 -0
- data/lib/rubocop/cop/style/symbol_proc.rb +32 -5
- data/lib/rubocop/cop/style/top_level_method_definition.rb +1 -1
- data/lib/rubocop/cop/team.rb +2 -0
- data/lib/rubocop/formatter/disabled_config_formatter.rb +13 -9
- data/lib/rubocop/formatter/formatter_set.rb +7 -1
- data/lib/rubocop/lockfile.rb +25 -6
- data/lib/rubocop/lsp/routes.rb +10 -13
- data/lib/rubocop/lsp/server.rb +2 -0
- data/lib/rubocop/lsp.rb +9 -2
- data/lib/rubocop/options.rb +3 -3
- data/lib/rubocop/rake_task.rb +1 -1
- data/lib/rubocop/runner.rb +5 -4
- data/lib/rubocop/version.rb +4 -4
- data/lib/rubocop.rb +2 -0
- metadata +10 -8
@@ -0,0 +1,156 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
# Checks for redundant argument forwarding when calling super
|
7
|
+
# with arguments identical to the method definition.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# # bad
|
11
|
+
# def method(*args, **kwargs)
|
12
|
+
# super(*args, **kwargs)
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# # good - implicitly passing all arguments
|
16
|
+
# def method(*args, **kwargs)
|
17
|
+
# super
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# # good - forwarding a subset of the arguments
|
21
|
+
# def method(*args, **kwargs)
|
22
|
+
# super(*args)
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# # good - forwarding no arguments
|
26
|
+
# def method(*args, **kwargs)
|
27
|
+
# super()
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# # good - assigning to the block variable before calling super
|
31
|
+
# def method(&block)
|
32
|
+
# # Assigning to the block variable would pass the old value to super,
|
33
|
+
# # under this circumstance the block must be referenced explicitly.
|
34
|
+
# block ||= proc { 'fallback behavior' }
|
35
|
+
# super(&block)
|
36
|
+
# end
|
37
|
+
class SuperArguments < Base
|
38
|
+
extend AutoCorrector
|
39
|
+
|
40
|
+
DEF_TYPES = %i[def defs].freeze
|
41
|
+
ASSIGN_TYPES = %i[or_asgn lvasgn].freeze
|
42
|
+
|
43
|
+
MSG = 'Call `super` without arguments and parentheses when the signature is identical.'
|
44
|
+
|
45
|
+
def on_super(super_node)
|
46
|
+
def_node = super_node.ancestors.find do |node|
|
47
|
+
# You can't implicitly call super when dynamically defining methods
|
48
|
+
break if define_method?(node)
|
49
|
+
|
50
|
+
break node if DEF_TYPES.include?(node.type)
|
51
|
+
end
|
52
|
+
return unless def_node
|
53
|
+
return unless arguments_identical?(def_node, def_node.arguments.argument_list,
|
54
|
+
super_node.arguments)
|
55
|
+
|
56
|
+
add_offense(super_node) { |corrector| corrector.replace(super_node, 'super') }
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
62
|
+
def arguments_identical?(def_node, def_args, super_args)
|
63
|
+
super_args = preprocess_super_args(super_args)
|
64
|
+
return false if def_args.size != super_args.size
|
65
|
+
|
66
|
+
def_args.zip(super_args).each do |def_arg, super_arg|
|
67
|
+
next if positional_arg_same?(def_arg, super_arg)
|
68
|
+
next if positional_rest_arg_same(def_arg, super_arg)
|
69
|
+
next if keyword_arg_same?(def_arg, super_arg)
|
70
|
+
next if keyword_rest_arg_same?(def_arg, super_arg)
|
71
|
+
next if block_arg_same?(def_node, def_arg, super_arg)
|
72
|
+
next if forward_arg_same?(def_arg, super_arg)
|
73
|
+
|
74
|
+
return false
|
75
|
+
end
|
76
|
+
true
|
77
|
+
end
|
78
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
79
|
+
|
80
|
+
def positional_arg_same?(def_arg, super_arg)
|
81
|
+
return false unless def_arg.arg_type? || def_arg.optarg_type?
|
82
|
+
return false unless super_arg.lvar_type?
|
83
|
+
|
84
|
+
def_arg.name == super_arg.children.first
|
85
|
+
end
|
86
|
+
|
87
|
+
def positional_rest_arg_same(def_arg, super_arg)
|
88
|
+
return false unless def_arg.restarg_type?
|
89
|
+
# anonymous forwarding
|
90
|
+
return true if def_arg.name.nil? && super_arg.forwarded_restarg_type?
|
91
|
+
return false unless super_arg.splat_type?
|
92
|
+
return false unless (lvar_node = super_arg.children.first).lvar_type?
|
93
|
+
|
94
|
+
def_arg.name == lvar_node.children.first
|
95
|
+
end
|
96
|
+
|
97
|
+
def keyword_arg_same?(def_arg, super_arg)
|
98
|
+
return false unless def_arg.kwarg_type? || def_arg.kwoptarg_type?
|
99
|
+
return false unless (pair_node = super_arg).pair_type?
|
100
|
+
return false unless (sym_node = pair_node.key).sym_type?
|
101
|
+
return false unless (lvar_node = pair_node.value).lvar_type?
|
102
|
+
return false unless sym_node.source == lvar_node.source
|
103
|
+
|
104
|
+
def_arg.name == sym_node.value
|
105
|
+
end
|
106
|
+
|
107
|
+
def keyword_rest_arg_same?(def_arg, super_arg)
|
108
|
+
return false unless def_arg.kwrestarg_type?
|
109
|
+
# anonymous forwarding
|
110
|
+
return true if def_arg.name.nil? && super_arg.forwarded_kwrestarg_type?
|
111
|
+
return false unless super_arg.kwsplat_type?
|
112
|
+
return false unless (lvar_node = super_arg.children.first).lvar_type?
|
113
|
+
|
114
|
+
def_arg.name == lvar_node.children.first
|
115
|
+
end
|
116
|
+
|
117
|
+
def block_arg_same?(def_node, def_arg, super_arg)
|
118
|
+
return false unless def_arg.blockarg_type? && super_arg.block_pass_type?
|
119
|
+
# anonymous forwarding
|
120
|
+
return true if (block_pass_child = super_arg.children.first).nil? && def_arg.name.nil?
|
121
|
+
|
122
|
+
block_arg_name = block_pass_child.children.first
|
123
|
+
def_arg.name == block_arg_name && !block_reassigned?(def_node, block_arg_name)
|
124
|
+
end
|
125
|
+
|
126
|
+
# Reassigning the block argument will still pass along the original block to super
|
127
|
+
# https://bugs.ruby-lang.org/issues/20505
|
128
|
+
def block_reassigned?(def_node, block_arg_name)
|
129
|
+
def_node.each_node(*ASSIGN_TYPES).any? do |assign_node|
|
130
|
+
assign_node.name == block_arg_name
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def forward_arg_same?(def_arg, super_arg)
|
135
|
+
def_arg.forward_arg_type? && super_arg.forwarded_args_type?
|
136
|
+
end
|
137
|
+
|
138
|
+
def define_method?(node)
|
139
|
+
return false unless node.block_type?
|
140
|
+
|
141
|
+
node.method?(:define_method) || node.method?(:define_singleton_method)
|
142
|
+
end
|
143
|
+
|
144
|
+
def preprocess_super_args(super_args)
|
145
|
+
super_args.flat_map do |node|
|
146
|
+
if node.hash_type? && !node.braces?
|
147
|
+
node.children
|
148
|
+
else
|
149
|
+
node
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -120,6 +120,23 @@ module RuboCop
|
|
120
120
|
# # good
|
121
121
|
# something.map { |s| s.upcase }
|
122
122
|
#
|
123
|
+
# @example AllCops:ActiveSupportExtensionsEnabled: false (default)
|
124
|
+
# # bad
|
125
|
+
# ->(x) { x.foo }
|
126
|
+
# proc { |x| x.foo }
|
127
|
+
# Proc.new { |x| x.foo }
|
128
|
+
#
|
129
|
+
# # good
|
130
|
+
# lambda(&:foo)
|
131
|
+
# proc(&:foo)
|
132
|
+
# Proc.new(&:foo)
|
133
|
+
#
|
134
|
+
# @example AllCops:ActiveSupportExtensionsEnabled: true
|
135
|
+
# # good
|
136
|
+
# ->(x) { x.foo }
|
137
|
+
# proc { |x| x.foo }
|
138
|
+
# Proc.new { |x| x.foo }
|
139
|
+
#
|
123
140
|
class SymbolProc < Base
|
124
141
|
include CommentsHelp
|
125
142
|
include RangeHelp
|
@@ -129,6 +146,7 @@ module RuboCop
|
|
129
146
|
|
130
147
|
MSG = 'Pass `&:%<method>s` as an argument to `%<block_method>s` instead of a block.'
|
131
148
|
SUPER_TYPES = %i[super zsuper].freeze
|
149
|
+
LAMBDA_OR_PROC = %i[lambda proc].freeze
|
132
150
|
|
133
151
|
# @!method proc_node?(node)
|
134
152
|
def_node_matcher :proc_node?, '(send (const {nil? cbase} :Proc) :new)'
|
@@ -151,13 +169,12 @@ module RuboCop
|
|
151
169
|
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
152
170
|
def on_block(node)
|
153
171
|
symbol_proc?(node) do |dispatch_node, arguments_node, method_name|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
172
|
+
if active_support_extensions_enabled?
|
173
|
+
return if proc_node?(dispatch_node)
|
174
|
+
return if LAMBDA_OR_PROC.include?(dispatch_node.method_name)
|
175
|
+
end
|
158
176
|
return if unsafe_hash_usage?(dispatch_node)
|
159
177
|
return if unsafe_array_usage?(dispatch_node)
|
160
|
-
return if %i[lambda proc].include?(dispatch_node.method_name)
|
161
178
|
return if allowed_method_name?(dispatch_node.method_name)
|
162
179
|
return if allow_if_method_has_argument?(node.send_node)
|
163
180
|
return if node.block_type? && destructuring_block_argument?(arguments_node)
|
@@ -206,6 +223,8 @@ module RuboCop
|
|
206
223
|
end
|
207
224
|
|
208
225
|
def autocorrect_without_args(corrector, node)
|
226
|
+
autocorrect_lambda_block(corrector, node) if node.send_node.lambda_literal?
|
227
|
+
|
209
228
|
corrector.replace(block_range_with_space(node), "(&:#{node.body.method_name})")
|
210
229
|
end
|
211
230
|
|
@@ -218,6 +237,14 @@ module RuboCop
|
|
218
237
|
corrector.remove(block_range_with_space(node))
|
219
238
|
end
|
220
239
|
|
240
|
+
def autocorrect_lambda_block(corrector, node)
|
241
|
+
send_node_loc = node.send_node.loc
|
242
|
+
corrector.replace(send_node_loc.selector, 'lambda')
|
243
|
+
|
244
|
+
range = range_between(send_node_loc.selector.end_pos, node.loc.begin.end_pos - 2)
|
245
|
+
corrector.remove(range)
|
246
|
+
end
|
247
|
+
|
221
248
|
def block_range_with_space(node)
|
222
249
|
block_range = range_between(begin_pos_for_replacement(node), node.loc.end.end_pos)
|
223
250
|
range_with_surrounding_space(block_range, side: :left)
|
data/lib/rubocop/cop/team.rb
CHANGED
@@ -116,20 +116,24 @@ module RuboCop
|
|
116
116
|
def set_max(cfg, cop_name)
|
117
117
|
return unless cfg[:exclude_limit]
|
118
118
|
|
119
|
-
|
120
|
-
@config_for_pwd.for_cop(cop_name)['Max'] != default_config(cop_name)['Max']
|
121
|
-
if !max_set_in_user_config &&
|
122
|
-
# In case auto_gen_only_exclude is set, only modify the maximum if the files are not
|
123
|
-
# excluded one by one.
|
124
|
-
(!@options[:auto_gen_only_exclude] ||
|
125
|
-
@files_with_offenses[cop_name].size > @exclude_limit)
|
126
|
-
cfg.merge!(cfg[:exclude_limit])
|
127
|
-
end
|
119
|
+
cfg.merge!(cfg[:exclude_limit]) if should_set_max?(cop_name)
|
128
120
|
|
129
121
|
# Remove already used exclude_limit.
|
130
122
|
cfg.reject! { |key| key == :exclude_limit }
|
131
123
|
end
|
132
124
|
|
125
|
+
def should_set_max?(cop_name)
|
126
|
+
max_set_in_user_config =
|
127
|
+
@config_for_pwd.for_cop(cop_name)['Max'] != default_config(cop_name)['Max']
|
128
|
+
|
129
|
+
max_allowed = !max_set_in_user_config && !no_exclude_limit?
|
130
|
+
return false unless max_allowed
|
131
|
+
|
132
|
+
# In case auto_gen_only_exclude is set, only modify the maximum if the files are not
|
133
|
+
# excluded one by one.
|
134
|
+
!@options[:auto_gen_only_exclude] || @files_with_offenses[cop_name].size > @exclude_limit
|
135
|
+
end
|
136
|
+
|
133
137
|
def output_cop_comments(output_buffer, cfg, cop_name, offense_count)
|
134
138
|
output_buffer.puts "# Offense count: #{offense_count}" if show_offense_counts?
|
135
139
|
|
@@ -27,6 +27,7 @@ module RuboCop
|
|
27
27
|
'[t]ap' => 'TapFormatter',
|
28
28
|
'[w]orst' => 'WorstOffendersFormatter'
|
29
29
|
}.freeze
|
30
|
+
BUILTIN_FORMATTER_NAMES = BUILTIN_FORMATTERS_FOR_KEYS.keys.map { |key| key.delete('[]') }
|
30
31
|
|
31
32
|
FORMATTER_APIS = %i[started finished].freeze
|
32
33
|
|
@@ -88,7 +89,12 @@ module RuboCop
|
|
88
89
|
/^\[#{specified_key}\]/.match?(key) || specified_key == key.delete('[]')
|
89
90
|
end
|
90
91
|
|
91
|
-
|
92
|
+
if matching_keys.empty?
|
93
|
+
similar_name = NameSimilarity.find_similar_name(specified_key, BUILTIN_FORMATTER_NAMES)
|
94
|
+
suggestion = %( Did you mean? "#{similar_name}") if similar_name
|
95
|
+
|
96
|
+
raise Rainbow(%(Formatter "#{specified_key}" not found.#{suggestion})).red
|
97
|
+
end
|
92
98
|
|
93
99
|
raise %(Cannot determine formatter for "#{specified_key}") if matching_keys.size > 1
|
94
100
|
|
data/lib/rubocop/lockfile.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
begin
|
4
|
+
# We might not be running with `bundle exec`, so we need to pull in Bundler ourselves,
|
5
|
+
# in order to use `Bundler::LockfileParser`.
|
6
|
+
require 'bundler'
|
7
|
+
rescue LoadError
|
8
|
+
nil
|
9
|
+
end
|
10
|
+
|
3
11
|
module RuboCop
|
4
12
|
# Encapsulation of a lockfile for use when checking for gems.
|
5
13
|
# Does not actually resolve gems, just parses the lockfile.
|
@@ -7,7 +15,11 @@ module RuboCop
|
|
7
15
|
class Lockfile
|
8
16
|
# @param [String, Pathname, nil] lockfile_path
|
9
17
|
def initialize(lockfile_path = nil)
|
10
|
-
lockfile_path ||=
|
18
|
+
lockfile_path ||= begin
|
19
|
+
::Bundler.default_lockfile if bundler_lock_parser_defined?
|
20
|
+
rescue ::Bundler::GemfileNotFound
|
21
|
+
nil # We might not be a folder with a Gemfile, but that's okay.
|
22
|
+
end
|
11
23
|
|
12
24
|
@lockfile_path = lockfile_path
|
13
25
|
end
|
@@ -59,12 +71,19 @@ module RuboCop
|
|
59
71
|
# @return [Bundler::LockfileParser, nil]
|
60
72
|
def parser
|
61
73
|
return @parser if defined?(@parser)
|
62
|
-
return unless @lockfile_path
|
63
74
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
75
|
+
@parser = if @lockfile_path && File.exist?(@lockfile_path) && bundler_lock_parser_defined?
|
76
|
+
begin
|
77
|
+
lockfile = ::Bundler.read_file(@lockfile_path)
|
78
|
+
::Bundler::LockfileParser.new(lockfile) if lockfile
|
79
|
+
rescue ::Bundler::BundlerError
|
80
|
+
nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def bundler_lock_parser_defined?
|
86
|
+
Object.const_defined?(:Bundler) && Bundler.const_defined?(:LockfileParser)
|
68
87
|
end
|
69
88
|
end
|
70
89
|
end
|
data/lib/rubocop/lsp/routes.rb
CHANGED
@@ -45,10 +45,6 @@ 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: LanguageServer::Protocol::Interface::DiagnosticOptions.new(
|
49
|
-
inter_file_dependencies: false,
|
50
|
-
workspace_diagnostics: false
|
51
|
-
),
|
52
48
|
text_document_sync: LanguageServer::Protocol::Interface::TextDocumentSyncOptions.new(
|
53
49
|
change: LanguageServer::Protocol::Constant::TextDocumentSyncKind::FULL,
|
54
50
|
open_close: true
|
@@ -60,8 +56,9 @@ module RuboCop
|
|
60
56
|
|
61
57
|
handle 'initialized' do |_request|
|
62
58
|
version = RuboCop::Version::STRING
|
59
|
+
yjit = Object.const_defined?('RubyVM::YJIT') && RubyVM::YJIT.enabled? ? ' +YJIT' : ''
|
63
60
|
|
64
|
-
Logger.log("RuboCop #{version} language server initialized, PID #{Process.pid}")
|
61
|
+
Logger.log("RuboCop #{version} language server#{yjit} initialized, PID #{Process.pid}")
|
65
62
|
end
|
66
63
|
|
67
64
|
handle 'shutdown' do |request|
|
@@ -72,12 +69,6 @@ module RuboCop
|
|
72
69
|
end
|
73
70
|
end
|
74
71
|
|
75
|
-
handle 'textDocument/diagnostic' do |request|
|
76
|
-
doc = request[:params][:textDocument]
|
77
|
-
result = diagnostic(doc[:uri], doc[:text])
|
78
|
-
@server.write(result)
|
79
|
-
end
|
80
|
-
|
81
72
|
handle 'textDocument/didChange' do |request|
|
82
73
|
params = request[:params]
|
83
74
|
result = diagnostic(params[:textDocument][:uri], params[:contentChanges][0][:text])
|
@@ -126,6 +117,12 @@ module RuboCop
|
|
126
117
|
end
|
127
118
|
|
128
119
|
uri = request[:params][:arguments][0][:uri]
|
120
|
+
formatted = nil
|
121
|
+
|
122
|
+
# The `workspace/executeCommand` is an LSP method triggered by intentional user actions,
|
123
|
+
# so the user's intention for autocorrection is respected.
|
124
|
+
LSP.disable { formatted = format_file(uri, command: command) }
|
125
|
+
|
129
126
|
@server.write(
|
130
127
|
id: request[:id],
|
131
128
|
method: 'workspace/applyEdit',
|
@@ -133,7 +130,7 @@ module RuboCop
|
|
133
130
|
label: label,
|
134
131
|
edit: {
|
135
132
|
changes: {
|
136
|
-
uri =>
|
133
|
+
uri => formatted
|
137
134
|
}
|
138
135
|
}
|
139
136
|
}
|
@@ -238,7 +235,7 @@ module RuboCop
|
|
238
235
|
def to_range(location)
|
239
236
|
{
|
240
237
|
start: { character: location[:start_column] - 1, line: location[:start_line] - 1 },
|
241
|
-
end: { character: location[:last_column]
|
238
|
+
end: { character: location[:last_column], line: location[:last_line] - 1 }
|
242
239
|
}
|
243
240
|
end
|
244
241
|
end
|
data/lib/rubocop/lsp/server.rb
CHANGED
data/lib/rubocop/lsp.rb
CHANGED
@@ -22,8 +22,15 @@ module RuboCop
|
|
22
22
|
# Disable LSP.
|
23
23
|
#
|
24
24
|
# @return [void]
|
25
|
-
def disable
|
26
|
-
|
25
|
+
def disable(&block)
|
26
|
+
if block
|
27
|
+
original = @enabled
|
28
|
+
@enabled = false
|
29
|
+
yield
|
30
|
+
@enabled = original
|
31
|
+
else
|
32
|
+
@enabled = false
|
33
|
+
end
|
27
34
|
end
|
28
35
|
end
|
29
36
|
end
|
data/lib/rubocop/options.rb
CHANGED
@@ -573,7 +573,7 @@ module RuboCop
|
|
573
573
|
'cops. Only valid for --format junit.'],
|
574
574
|
display_only_fail_level_offenses:
|
575
575
|
['Only output offense messages at',
|
576
|
-
'the specified --fail-level or above'],
|
576
|
+
'the specified --fail-level or above.'],
|
577
577
|
display_only_correctable: ['Only output correctable offense messages.'],
|
578
578
|
display_only_safe_correctable: ['Only output safe-correctable offense messages',
|
579
579
|
'when combined with --display-only-correctable.'],
|
@@ -636,8 +636,8 @@ module RuboCop
|
|
636
636
|
raise_cop_error: ['Raise cop-related errors with cause and location.',
|
637
637
|
'This is used to prevent cops from failing silently.',
|
638
638
|
'Default is false.'],
|
639
|
-
profile: 'Profile rubocop',
|
640
|
-
memory: 'Profile rubocop memory usage'
|
639
|
+
profile: 'Profile rubocop.',
|
640
|
+
memory: 'Profile rubocop memory usage.'
|
641
641
|
}.freeze
|
642
642
|
end
|
643
643
|
# rubocop:enable Metrics/ModuleLength
|
data/lib/rubocop/rake_task.rb
CHANGED
@@ -44,7 +44,7 @@ module RuboCop
|
|
44
44
|
def run_cli(verbose, options)
|
45
45
|
# We lazy-load RuboCop so that the task doesn't dramatically impact the
|
46
46
|
# load time of your Rakefile.
|
47
|
-
|
47
|
+
require_relative '../rubocop'
|
48
48
|
|
49
49
|
cli = CLI.new
|
50
50
|
puts 'Running RuboCop...' if verbose
|
data/lib/rubocop/runner.rb
CHANGED
@@ -20,10 +20,11 @@ module RuboCop
|
|
20
20
|
message = 'Infinite loop detected'
|
21
21
|
message += " in #{path}" if path
|
22
22
|
message += " and caused by #{root_cause}" if root_cause
|
23
|
-
message +=
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
message += "\n"
|
24
|
+
hint = 'Hint: Please update to the latest RuboCop version if not already in use, ' \
|
25
|
+
"and report a bug if the issue still occurs on this version.\n" \
|
26
|
+
'Please check the latest version at https://rubygems.org/gems/rubocop.'
|
27
|
+
super(Rainbow(message).red + Rainbow(hint).yellow)
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
data/lib/rubocop/version.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
# This module holds the RuboCop version information.
|
5
5
|
module Version
|
6
|
-
STRING = '1.
|
6
|
+
STRING = '1.64.1'
|
7
7
|
|
8
8
|
MSG = '%<version>s (using %<parser_version>s, ' \
|
9
9
|
'rubocop-ast %<rubocop_ast_version>s, ' \
|
@@ -42,9 +42,9 @@ module RuboCop
|
|
42
42
|
# @api private
|
43
43
|
def self.parser_version
|
44
44
|
config_path = ConfigFinder.find_config_path(Dir.pwd)
|
45
|
-
yaml =
|
46
|
-
|
47
|
-
|
45
|
+
yaml = Util.silence_warnings do
|
46
|
+
ConfigLoader.load_yaml_configuration(config_path)
|
47
|
+
end
|
48
48
|
|
49
49
|
if yaml.dig('AllCops', 'ParserEngine') == 'parser_prism'
|
50
50
|
require 'prism'
|
data/lib/rubocop.rb
CHANGED
@@ -666,6 +666,7 @@ require_relative 'rubocop/cop/style/select_by_regexp'
|
|
666
666
|
require_relative 'rubocop/cop/style/self_assignment'
|
667
667
|
require_relative 'rubocop/cop/style/semicolon'
|
668
668
|
require_relative 'rubocop/cop/style/send'
|
669
|
+
require_relative 'rubocop/cop/style/send_with_literal_method_name'
|
669
670
|
require_relative 'rubocop/cop/style/signal_exception'
|
670
671
|
require_relative 'rubocop/cop/style/single_argument_dig'
|
671
672
|
require_relative 'rubocop/cop/style/single_line_block_params'
|
@@ -682,6 +683,7 @@ require_relative 'rubocop/cop/style/string_literals_in_interpolation'
|
|
682
683
|
require_relative 'rubocop/cop/style/string_methods'
|
683
684
|
require_relative 'rubocop/cop/style/strip'
|
684
685
|
require_relative 'rubocop/cop/style/struct_inheritance'
|
686
|
+
require_relative 'rubocop/cop/style/super_arguments'
|
685
687
|
require_relative 'rubocop/cop/style/super_with_args_parentheses'
|
686
688
|
require_relative 'rubocop/cop/style/swap_values'
|
687
689
|
require_relative 'rubocop/cop/style/symbol_array'
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.64.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
8
8
|
- Jonas Arvidsson
|
9
9
|
- Yuji Nakayama
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-05-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -885,6 +885,7 @@ files:
|
|
885
885
|
- lib/rubocop/cop/style/self_assignment.rb
|
886
886
|
- lib/rubocop/cop/style/semicolon.rb
|
887
887
|
- lib/rubocop/cop/style/send.rb
|
888
|
+
- lib/rubocop/cop/style/send_with_literal_method_name.rb
|
888
889
|
- lib/rubocop/cop/style/signal_exception.rb
|
889
890
|
- lib/rubocop/cop/style/single_argument_dig.rb
|
890
891
|
- lib/rubocop/cop/style/single_line_block_params.rb
|
@@ -904,6 +905,7 @@ files:
|
|
904
905
|
- lib/rubocop/cop/style/string_methods.rb
|
905
906
|
- lib/rubocop/cop/style/strip.rb
|
906
907
|
- lib/rubocop/cop/style/struct_inheritance.rb
|
908
|
+
- lib/rubocop/cop/style/super_arguments.rb
|
907
909
|
- lib/rubocop/cop/style/super_with_args_parentheses.rb
|
908
910
|
- lib/rubocop/cop/style/swap_values.rb
|
909
911
|
- lib/rubocop/cop/style/symbol_array.rb
|
@@ -1032,12 +1034,12 @@ licenses:
|
|
1032
1034
|
- MIT
|
1033
1035
|
metadata:
|
1034
1036
|
homepage_uri: https://rubocop.org/
|
1035
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.
|
1037
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.64.1
|
1036
1038
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1037
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
1039
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.64/
|
1038
1040
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1039
1041
|
rubygems_mfa_required: 'true'
|
1040
|
-
post_install_message:
|
1042
|
+
post_install_message:
|
1041
1043
|
rdoc_options: []
|
1042
1044
|
require_paths:
|
1043
1045
|
- lib
|
@@ -1052,8 +1054,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1052
1054
|
- !ruby/object:Gem::Version
|
1053
1055
|
version: '0'
|
1054
1056
|
requirements: []
|
1055
|
-
rubygems_version: 3.
|
1056
|
-
signing_key:
|
1057
|
+
rubygems_version: 3.3.7
|
1058
|
+
signing_key:
|
1057
1059
|
specification_version: 4
|
1058
1060
|
summary: Automatic Ruby code style checking tool.
|
1059
1061
|
test_files: []
|