rubocop 1.74.0 → 1.75.2
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 -1
- data/config/default.yml +32 -6
- data/config/obsoletion.yml +3 -1
- data/lib/rubocop/cli.rb +1 -1
- data/lib/rubocop/config.rb +35 -6
- data/lib/rubocop/config_loader.rb +4 -0
- data/lib/rubocop/config_obsoletion/renamed_cop.rb +18 -3
- data/lib/rubocop/config_obsoletion.rb +46 -2
- data/lib/rubocop/config_validator.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups.rb +2 -1
- data/lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb +6 -5
- data/lib/rubocop/cop/layout/block_alignment.rb +2 -2
- data/lib/rubocop/cop/layout/block_end_newline.rb +1 -0
- data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/else_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +3 -3
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +1 -0
- data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +1 -0
- data/lib/rubocop/cop/layout/indentation_width.rb +1 -0
- data/lib/rubocop/cop/layout/line_length.rb +5 -1
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -0
- data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +1 -0
- data/lib/rubocop/cop/layout/redundant_line_break.rb +9 -5
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +3 -5
- data/lib/rubocop/cop/layout/space_around_operators.rb +4 -1
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +1 -0
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -0
- data/lib/rubocop/cop/lint/debugger.rb +2 -2
- data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_methods.rb +2 -3
- data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +2 -2
- data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +1 -1
- data/lib/rubocop/cop/lint/raise_exception.rb +29 -10
- data/lib/rubocop/cop/lint/redundant_type_conversion.rb +7 -4
- data/lib/rubocop/cop/lint/redundant_with_index.rb +3 -0
- data/lib/rubocop/cop/lint/redundant_with_object.rb +3 -0
- data/lib/rubocop/cop/lint/return_in_void_context.rb +7 -2
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +8 -1
- data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +1 -1
- data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
- data/lib/rubocop/cop/lint/unexpected_block_arity.rb +2 -0
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -0
- data/lib/rubocop/cop/lint/unreachable_loop.rb +5 -5
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -0
- data/lib/rubocop/cop/lint/void.rb +1 -0
- data/lib/rubocop/cop/metrics/block_length.rb +1 -0
- data/lib/rubocop/cop/metrics/method_length.rb +1 -0
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -1
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +2 -2
- data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +1 -1
- data/lib/rubocop/cop/mixin/def_node.rb +1 -1
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +1 -1
- data/lib/rubocop/cop/mixin/forbidden_identifiers.rb +20 -0
- data/lib/rubocop/cop/mixin/forbidden_pattern.rb +16 -0
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +0 -1
- data/lib/rubocop/cop/mixin/method_complexity.rb +1 -0
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
- data/lib/rubocop/cop/naming/method_name.rb +64 -8
- data/lib/rubocop/cop/naming/variable_name.rb +6 -19
- data/lib/rubocop/cop/registry.rb +9 -6
- data/lib/rubocop/cop/style/array_intersect.rb +39 -28
- data/lib/rubocop/cop/style/block_delimiters.rb +2 -1
- data/lib/rubocop/cop/style/class_equality_comparison.rb +1 -1
- data/lib/rubocop/cop/style/collection_methods.rb +1 -0
- data/lib/rubocop/cop/style/combinable_loops.rb +1 -0
- data/lib/rubocop/cop/style/conditional_assignment.rb +3 -0
- data/lib/rubocop/cop/style/double_negation.rb +1 -1
- data/lib/rubocop/cop/style/empty_literal.rb +4 -0
- data/lib/rubocop/cop/style/explicit_block_argument.rb +2 -2
- data/lib/rubocop/cop/style/for.rb +1 -0
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +3 -2
- data/lib/rubocop/cop/style/global_std_stream.rb +3 -0
- data/lib/rubocop/cop/style/guard_clause.rb +2 -1
- data/lib/rubocop/cop/style/hash_each_methods.rb +3 -2
- data/lib/rubocop/cop/style/hash_fetch_chain.rb +105 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +3 -0
- data/lib/rubocop/cop/style/if_inside_else.rb +10 -13
- data/lib/rubocop/cop/style/inverse_methods.rb +1 -0
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +2 -2
- data/lib/rubocop/cop/style/ip_addresses.rb +2 -2
- data/lib/rubocop/cop/style/it_block_parameter.rb +100 -0
- data/lib/rubocop/cop/style/keyword_parameters_order.rb +1 -1
- data/lib/rubocop/cop/style/lambda.rb +1 -0
- data/lib/rubocop/cop/style/map_into_array.rb +1 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +1 -0
- data/lib/rubocop/cop/style/multiline_block_chain.rb +1 -0
- data/lib/rubocop/cop/style/next.rb +44 -0
- data/lib/rubocop/cop/style/object_then.rb +1 -0
- data/lib/rubocop/cop/style/proc.rb +1 -0
- data/lib/rubocop/cop/style/raise_args.rb +8 -8
- data/lib/rubocop/cop/style/redundant_begin.rb +1 -0
- data/lib/rubocop/cop/style/redundant_condition.rb +13 -1
- data/lib/rubocop/cop/style/redundant_format.rb +10 -3
- data/lib/rubocop/cop/style/redundant_parentheses.rb +2 -1
- data/lib/rubocop/cop/style/redundant_self.rb +1 -0
- data/lib/rubocop/cop/style/redundant_sort_by.rb +17 -1
- data/lib/rubocop/cop/style/return_nil.rb +2 -2
- data/lib/rubocop/cop/style/select_by_regexp.rb +4 -1
- data/lib/rubocop/cop/style/single_line_do_end_block.rb +3 -1
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +41 -100
- data/lib/rubocop/cop/style/super_arguments.rb +1 -2
- data/lib/rubocop/cop/style/symbol_proc.rb +2 -0
- data/lib/rubocop/cop/style/top_level_method_definition.rb +1 -0
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cop/variable_force/scope.rb +1 -1
- data/lib/rubocop/cop/variable_force/variable.rb +2 -7
- data/lib/rubocop/cop/variable_force.rb +1 -1
- data/lib/rubocop/lsp/runtime.rb +4 -4
- data/lib/rubocop/lsp/stdin_runner.rb +3 -1
- data/lib/rubocop/magic_comment.rb +8 -0
- data/lib/rubocop/rspec/cop_helper.rb +4 -1
- data/lib/rubocop/rspec/shared_contexts.rb +20 -0
- data/lib/rubocop/rspec/support.rb +2 -0
- data/lib/rubocop/runner.rb +5 -1
- data/lib/rubocop/server/cache.rb +13 -10
- data/lib/rubocop/target_finder.rb +1 -1
- data/lib/rubocop/target_ruby.rb +1 -1
- data/lib/rubocop/version.rb +14 -7
- data/lib/rubocop.rb +4 -0
- data/lib/ruby_lsp/rubocop/runtime_adapter.rb +20 -2
- metadata +10 -6
data/lib/rubocop/lsp/runtime.rb
CHANGED
@@ -30,7 +30,7 @@ module RuboCop
|
|
30
30
|
@layout_mode = false
|
31
31
|
end
|
32
32
|
|
33
|
-
def format(path, text, command:)
|
33
|
+
def format(path, text, command:, prism_result: nil)
|
34
34
|
safe_autocorrect = if command
|
35
35
|
command == 'rubocop.formatAutocorrects'
|
36
36
|
else
|
@@ -40,15 +40,15 @@ module RuboCop
|
|
40
40
|
formatting_options = { autocorrect: true, safe_autocorrect: safe_autocorrect }
|
41
41
|
formatting_options[:only] = config_only_options if @lint_mode || @layout_mode
|
42
42
|
|
43
|
-
@runner.run(path, text, formatting_options)
|
43
|
+
@runner.run(path, text, formatting_options, prism_result: prism_result)
|
44
44
|
@runner.formatted_source
|
45
45
|
end
|
46
46
|
|
47
|
-
def offenses(path, text, document_encoding = nil)
|
47
|
+
def offenses(path, text, document_encoding = nil, prism_result: nil)
|
48
48
|
diagnostic_options = {}
|
49
49
|
diagnostic_options[:only] = config_only_options if @lint_mode || @layout_mode
|
50
50
|
|
51
|
-
@runner.run(path, text, diagnostic_options)
|
51
|
+
@runner.run(path, text, diagnostic_options, prism_result: prism_result)
|
52
52
|
@runner.offenses.map do |offense|
|
53
53
|
Diagnostic.new(
|
54
54
|
document_encoding, offense, path, @cop_registry[offense.cop_name]&.first
|
@@ -41,10 +41,12 @@ module RuboCop
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# rubocop:disable Metrics/MethodLength
|
44
|
-
def run(path, contents, options)
|
44
|
+
def run(path, contents, options, prism_result: nil)
|
45
45
|
@options = options.merge(DEFAULT_RUBOCOP_OPTIONS)
|
46
46
|
@options[:stdin] = contents
|
47
47
|
|
48
|
+
@prism_result = prism_result
|
49
|
+
|
48
50
|
@offenses = []
|
49
51
|
@warnings = []
|
50
52
|
@errors = []
|
@@ -193,6 +193,10 @@ module RuboCop
|
|
193
193
|
SEPARATOR = ';'
|
194
194
|
OPERATOR = ':'
|
195
195
|
|
196
|
+
def new_frozen_string_literal(value)
|
197
|
+
"# -*- frozen_string_literal: #{value} -*-"
|
198
|
+
end
|
199
|
+
|
196
200
|
private
|
197
201
|
|
198
202
|
def extract_frozen_string_literal
|
@@ -275,6 +279,10 @@ module RuboCop
|
|
275
279
|
end
|
276
280
|
end
|
277
281
|
|
282
|
+
def new_frozen_string_literal(value)
|
283
|
+
"# frozen_string_literal: #{value}"
|
284
|
+
end
|
285
|
+
|
278
286
|
private
|
279
287
|
|
280
288
|
# Extract `frozen_string_literal`.
|
@@ -10,7 +10,10 @@ module CopHelper
|
|
10
10
|
# The minimum version Prism can parse is 3.3.
|
11
11
|
ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : RuboCop::TargetRuby::DEFAULT_VERSION
|
12
12
|
end
|
13
|
-
let(:parser_engine)
|
13
|
+
let(:parser_engine) do
|
14
|
+
# The maximum version Parser can parse is 3.4.
|
15
|
+
ruby_version >= 3.5 ? :parser_prism : ENV.fetch('PARSER_ENGINE', :parser_whitequark).to_sym
|
16
|
+
end
|
14
17
|
let(:rails_version) { false }
|
15
18
|
|
16
19
|
before(:all) do
|
@@ -178,6 +178,21 @@ RSpec.shared_context 'mock console output' do
|
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
181
|
+
RSpec.shared_context 'mock obsoletion' do
|
182
|
+
include_context 'mock console output'
|
183
|
+
|
184
|
+
let(:obsoletion_configuration_path) { 'obsoletions.yml' }
|
185
|
+
|
186
|
+
before do
|
187
|
+
RuboCop::ConfigObsoletion.reset!
|
188
|
+
allow(RuboCop::ConfigObsoletion).to receive(:files).and_return([obsoletion_configuration_path])
|
189
|
+
end
|
190
|
+
|
191
|
+
after do
|
192
|
+
RuboCop::ConfigObsoletion.reset!
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
181
196
|
RSpec.shared_context 'lsp' do
|
182
197
|
before do
|
183
198
|
RuboCop::LSP.enable
|
@@ -250,3 +265,8 @@ end
|
|
250
265
|
RSpec.shared_context 'ruby 3.4' do
|
251
266
|
let(:ruby_version) { 3.4 }
|
252
267
|
end
|
268
|
+
|
269
|
+
RSpec.shared_context 'ruby 3.5' do
|
270
|
+
# Parser supports parsing Ruby <= 3.4.
|
271
|
+
let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.5 : 3.4 }
|
272
|
+
end
|
@@ -16,6 +16,7 @@ RSpec.configure do |config|
|
|
16
16
|
config.include_context 'lsp', :lsp
|
17
17
|
config.include_context 'maintain registry', :restore_registry
|
18
18
|
config.include_context 'maintain default configuration', :restore_configuration
|
19
|
+
config.include_context 'mock obsoletion', :mock_obsoletion
|
19
20
|
config.include_context 'ruby 2.0', :ruby20
|
20
21
|
config.include_context 'ruby 2.1', :ruby21
|
21
22
|
config.include_context 'ruby 2.2', :ruby22
|
@@ -29,4 +30,5 @@ RSpec.configure do |config|
|
|
29
30
|
config.include_context 'ruby 3.2', :ruby32
|
30
31
|
config.include_context 'ruby 3.3', :ruby33
|
31
32
|
config.include_context 'ruby 3.4', :ruby34
|
33
|
+
config.include_context 'ruby 3.5', :ruby35
|
32
34
|
end
|
data/lib/rubocop/runner.rb
CHANGED
@@ -489,7 +489,11 @@ module RuboCop
|
|
489
489
|
|
490
490
|
processed_source = if @options[:stdin]
|
491
491
|
ProcessedSource.new(
|
492
|
-
@options[:stdin],
|
492
|
+
@options[:stdin],
|
493
|
+
ruby_version,
|
494
|
+
file,
|
495
|
+
parser_engine: parser_engine,
|
496
|
+
prism_result: @prism_result
|
493
497
|
)
|
494
498
|
else
|
495
499
|
begin
|
data/lib/rubocop/server/cache.rb
CHANGED
@@ -52,7 +52,8 @@ module RuboCop
|
|
52
52
|
end.find(&:exist?)
|
53
53
|
version_data = lockfile_path&.read || RuboCop::Version::STRING
|
54
54
|
config_data = Pathname(ConfigFinder.find_config_path(Dir.pwd)).read
|
55
|
-
yaml =
|
55
|
+
yaml = load_erb_templated_yaml(config_data)
|
56
|
+
|
56
57
|
inherit_from_data = inherit_from_data(yaml)
|
57
58
|
require_data = require_data(yaml)
|
58
59
|
|
@@ -76,7 +77,6 @@ module RuboCop
|
|
76
77
|
File.expand_path(File.join(cache_root_dir, 'server'))
|
77
78
|
end
|
78
79
|
|
79
|
-
# rubocop:disable Metrics/MethodLength
|
80
80
|
def cache_root_dir_from_config
|
81
81
|
CacheConfig.root_dir do
|
82
82
|
# `RuboCop::ConfigStore` has heavy dependencies, this is a lightweight implementation
|
@@ -87,13 +87,7 @@ module RuboCop
|
|
87
87
|
# Returns early if `CacheRootDirectory` is not used before requiring `erb` or `yaml`.
|
88
88
|
next unless file_contents.include?('CacheRootDirectory')
|
89
89
|
|
90
|
-
|
91
|
-
yaml_code = ERB.new(file_contents).result
|
92
|
-
|
93
|
-
require 'yaml'
|
94
|
-
config_yaml = YAML.safe_load(
|
95
|
-
yaml_code, permitted_classes: [Regexp, Symbol], aliases: true
|
96
|
-
)
|
90
|
+
config_yaml = load_erb_templated_yaml(file_contents)
|
97
91
|
|
98
92
|
# For compatibility with Ruby 3.0 or lower.
|
99
93
|
if Gem::Version.new(Psych::VERSION) < Gem::Version.new('4.0.0')
|
@@ -103,7 +97,6 @@ module RuboCop
|
|
103
97
|
config_yaml&.dig('AllCops', 'CacheRootDirectory')
|
104
98
|
end
|
105
99
|
end
|
106
|
-
# rubocop:enable Metrics/MethodLength
|
107
100
|
|
108
101
|
def port_path
|
109
102
|
dir.join('port')
|
@@ -197,6 +190,16 @@ module RuboCop
|
|
197
190
|
path.exist? ? path.read : ''
|
198
191
|
end.join
|
199
192
|
end
|
193
|
+
|
194
|
+
private
|
195
|
+
|
196
|
+
def load_erb_templated_yaml(content)
|
197
|
+
require 'erb'
|
198
|
+
yaml_code = ERB.new(content).result
|
199
|
+
|
200
|
+
require 'yaml'
|
201
|
+
YAML.safe_load(yaml_code, permitted_classes: [Regexp, Symbol], aliases: true)
|
202
|
+
end
|
200
203
|
end
|
201
204
|
end
|
202
205
|
end
|
@@ -175,7 +175,7 @@ module RuboCop
|
|
175
175
|
end
|
176
176
|
|
177
177
|
def ruby_executable?(file)
|
178
|
-
return false
|
178
|
+
return false if !File.extname(file).empty? || !File.exist?(file) || File.empty?(file)
|
179
179
|
|
180
180
|
first_line = File.open(file, &:readline)
|
181
181
|
/#!.*(#{ruby_interpreters(file).join('|')})/.match?(first_line)
|
data/lib/rubocop/target_ruby.rb
CHANGED
@@ -4,7 +4,7 @@ module RuboCop
|
|
4
4
|
# The kind of Ruby that code inspected by RuboCop is written in.
|
5
5
|
# @api private
|
6
6
|
class TargetRuby
|
7
|
-
KNOWN_RUBIES = [2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4].freeze
|
7
|
+
KNOWN_RUBIES = [2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5].freeze
|
8
8
|
DEFAULT_VERSION = 2.7
|
9
9
|
|
10
10
|
OBSOLETE_RUBIES = {
|
data/lib/rubocop/version.rb
CHANGED
@@ -3,13 +3,15 @@
|
|
3
3
|
module RuboCop
|
4
4
|
# This module holds the RuboCop version information.
|
5
5
|
module Version
|
6
|
-
STRING = '1.
|
6
|
+
STRING = '1.75.2'
|
7
7
|
|
8
8
|
MSG = '%<version>s (using %<parser_version>s, ' \
|
9
9
|
'rubocop-ast %<rubocop_ast_version>s, ' \
|
10
10
|
'analyzing as Ruby %<target_ruby_version>s, ' \
|
11
11
|
'running on %<ruby_engine>s %<ruby_version>s)%<server_mode>s [%<ruby_platform>s]'
|
12
12
|
|
13
|
+
MINIMUM_PARSABLE_PRISM_VERSION = 3.3
|
14
|
+
|
13
15
|
CANONICAL_FEATURE_NAMES = {
|
14
16
|
'Rspec' => 'RSpec', 'Graphql' => 'GraphQL', 'Md' => 'Markdown', 'Factory_bot' => 'FactoryBot',
|
15
17
|
'Thread_safety' => 'ThreadSafety', 'Rspec_rails' => 'RSpecRails'
|
@@ -20,11 +22,14 @@ module RuboCop
|
|
20
22
|
|
21
23
|
# NOTE: Marked as private but used by gems like standard.
|
22
24
|
# @api private
|
25
|
+
# rubocop:disable Metrics/MethodLength
|
23
26
|
def self.version(debug: false, env: nil)
|
24
27
|
if debug
|
25
|
-
|
28
|
+
target_ruby_version = target_ruby_version(env)
|
29
|
+
verbose_version = format(MSG, version: STRING,
|
30
|
+
parser_version: parser_version(target_ruby_version),
|
26
31
|
rubocop_ast_version: RuboCop::AST::Version::STRING,
|
27
|
-
target_ruby_version: target_ruby_version
|
32
|
+
target_ruby_version: target_ruby_version,
|
28
33
|
ruby_engine: RUBY_ENGINE, ruby_version: RUBY_VERSION,
|
29
34
|
server_mode: server_mode,
|
30
35
|
ruby_platform: RUBY_PLATFORM)
|
@@ -41,6 +46,7 @@ module RuboCop
|
|
41
46
|
STRING
|
42
47
|
end
|
43
48
|
end
|
49
|
+
# rubocop:enable Metrics/MethodLength
|
44
50
|
|
45
51
|
# @api private
|
46
52
|
def self.verbose(env: nil)
|
@@ -48,15 +54,16 @@ module RuboCop
|
|
48
54
|
end
|
49
55
|
|
50
56
|
# @api private
|
51
|
-
def self.parser_version
|
57
|
+
def self.parser_version(target_ruby_version)
|
52
58
|
config_path = ConfigFinder.find_config_path(Dir.pwd)
|
53
59
|
yaml = Util.silence_warnings do
|
54
60
|
ConfigLoader.load_yaml_configuration(config_path)
|
55
61
|
end
|
62
|
+
parser_engine = yaml.dig('AllCops', 'ParserEngine')
|
63
|
+
parser_engine_text = ", #{parser_engine}" if parser_engine
|
56
64
|
|
57
|
-
if
|
58
|
-
|
59
|
-
"Prism #{Prism::VERSION}"
|
65
|
+
if target_ruby_version >= MINIMUM_PARSABLE_PRISM_VERSION
|
66
|
+
"Parser #{Parser::VERSION}, Prism #{Prism::VERSION}#{parser_engine_text}"
|
60
67
|
else
|
61
68
|
"Parser #{Parser::VERSION}"
|
62
69
|
end
|
data/lib/rubocop.rb
CHANGED
@@ -75,6 +75,8 @@ require_relative 'rubocop/cop/mixin/allowed_identifiers'
|
|
75
75
|
require_relative 'rubocop/cop/mixin/allowed_methods'
|
76
76
|
require_relative 'rubocop/cop/mixin/allowed_pattern'
|
77
77
|
require_relative 'rubocop/cop/mixin/allowed_receivers'
|
78
|
+
require_relative 'rubocop/cop/mixin/forbidden_identifiers'
|
79
|
+
require_relative 'rubocop/cop/mixin/forbidden_pattern'
|
78
80
|
require_relative 'rubocop/cop/mixin/auto_corrector' # rubocop:todo Naming/InclusiveLanguage
|
79
81
|
require_relative 'rubocop/cop/mixin/check_assignment'
|
80
82
|
require_relative 'rubocop/cop/mixin/check_line_breakable'
|
@@ -564,6 +566,7 @@ require_relative 'rubocop/cop/style/hash_as_last_array_item'
|
|
564
566
|
require_relative 'rubocop/cop/style/hash_conversion'
|
565
567
|
require_relative 'rubocop/cop/style/hash_each_methods'
|
566
568
|
require_relative 'rubocop/cop/style/hash_except'
|
569
|
+
require_relative 'rubocop/cop/style/hash_fetch_chain'
|
567
570
|
require_relative 'rubocop/cop/style/hash_like_case'
|
568
571
|
require_relative 'rubocop/cop/style/hash_slice'
|
569
572
|
require_relative 'rubocop/cop/style/hash_syntax'
|
@@ -583,6 +586,7 @@ require_relative 'rubocop/cop/style/inline_comment'
|
|
583
586
|
require_relative 'rubocop/cop/style/invertible_unless_condition'
|
584
587
|
require_relative 'rubocop/cop/style/ip_addresses'
|
585
588
|
require_relative 'rubocop/cop/style/it_assignment'
|
589
|
+
require_relative 'rubocop/cop/style/it_block_parameter'
|
586
590
|
require_relative 'rubocop/cop/style/keyword_arguments_merging'
|
587
591
|
require_relative 'rubocop/cop/style/keyword_parameters_order'
|
588
592
|
require_relative 'rubocop/cop/style/lambda'
|
@@ -16,11 +16,21 @@ module RubyLsp
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def run_diagnostic(uri, document)
|
19
|
-
@runtime.offenses(
|
19
|
+
@runtime.offenses(
|
20
|
+
uri_to_path(uri),
|
21
|
+
document.source,
|
22
|
+
document.encoding,
|
23
|
+
prism_result: prism_result(document)
|
24
|
+
)
|
20
25
|
end
|
21
26
|
|
22
27
|
def run_formatting(uri, document)
|
23
|
-
@runtime.format(
|
28
|
+
@runtime.format(
|
29
|
+
uri_to_path(uri),
|
30
|
+
document.source,
|
31
|
+
command: 'rubocop.formatAutocorrects',
|
32
|
+
prism_result: prism_result(document)
|
33
|
+
)
|
24
34
|
end
|
25
35
|
|
26
36
|
def run_range_formatting(_uri, _partial_source, _base_indentation)
|
@@ -42,6 +52,14 @@ module RubyLsp
|
|
42
52
|
uri.to_s.delete_prefix('file://')
|
43
53
|
end
|
44
54
|
end
|
55
|
+
|
56
|
+
def prism_result(document)
|
57
|
+
prism_result = document.parse_result
|
58
|
+
|
59
|
+
# NOTE: `prism_result` must be `Prism::ParseLexResult` compatible object.
|
60
|
+
# This is for compatibility parsed result unsupported.
|
61
|
+
prism_result.is_a?(Prism::ParseLexResult) ? prism_result : nil
|
62
|
+
end
|
45
63
|
end
|
46
64
|
end
|
47
65
|
end
|
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.75.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
- Yuji Nakayama
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-03
|
12
|
+
date: 2025-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -127,7 +127,7 @@ dependencies:
|
|
127
127
|
requirements:
|
128
128
|
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: 1.
|
130
|
+
version: 1.44.0
|
131
131
|
- - "<"
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '2.0'
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
requirements:
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version: 1.
|
140
|
+
version: 1.44.0
|
141
141
|
- - "<"
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: '2.0'
|
@@ -616,6 +616,8 @@ files:
|
|
616
616
|
- lib/rubocop/cop/mixin/endless_method_rewriter.rb
|
617
617
|
- lib/rubocop/cop/mixin/enforce_superclass.rb
|
618
618
|
- lib/rubocop/cop/mixin/first_element_line_break.rb
|
619
|
+
- lib/rubocop/cop/mixin/forbidden_identifiers.rb
|
620
|
+
- lib/rubocop/cop/mixin/forbidden_pattern.rb
|
619
621
|
- lib/rubocop/cop/mixin/frozen_string_literal.rb
|
620
622
|
- lib/rubocop/cop/mixin/gem_declaration.rb
|
621
623
|
- lib/rubocop/cop/mixin/gemspec_help.rb
|
@@ -784,6 +786,7 @@ files:
|
|
784
786
|
- lib/rubocop/cop/style/hash_conversion.rb
|
785
787
|
- lib/rubocop/cop/style/hash_each_methods.rb
|
786
788
|
- lib/rubocop/cop/style/hash_except.rb
|
789
|
+
- lib/rubocop/cop/style/hash_fetch_chain.rb
|
787
790
|
- lib/rubocop/cop/style/hash_like_case.rb
|
788
791
|
- lib/rubocop/cop/style/hash_slice.rb
|
789
792
|
- lib/rubocop/cop/style/hash_syntax.rb
|
@@ -803,6 +806,7 @@ files:
|
|
803
806
|
- lib/rubocop/cop/style/invertible_unless_condition.rb
|
804
807
|
- lib/rubocop/cop/style/ip_addresses.rb
|
805
808
|
- lib/rubocop/cop/style/it_assignment.rb
|
809
|
+
- lib/rubocop/cop/style/it_block_parameter.rb
|
806
810
|
- lib/rubocop/cop/style/keyword_arguments_merging.rb
|
807
811
|
- lib/rubocop/cop/style/keyword_parameters_order.rb
|
808
812
|
- lib/rubocop/cop/style/lambda.rb
|
@@ -1076,9 +1080,9 @@ licenses:
|
|
1076
1080
|
- MIT
|
1077
1081
|
metadata:
|
1078
1082
|
homepage_uri: https://rubocop.org/
|
1079
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.
|
1083
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.75.2
|
1080
1084
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1081
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
1085
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.75/
|
1082
1086
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1083
1087
|
rubygems_mfa_required: 'true'
|
1084
1088
|
rdoc_options: []
|