rubocop 1.71.2 → 1.74.0
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 +3 -3
- data/config/default.yml +86 -15
- data/config/internal_affairs.yml +20 -0
- data/lib/rubocop/cli/command/suggest_extensions.rb +7 -1
- data/lib/rubocop/comment_config.rb +1 -1
- data/lib/rubocop/config.rb +4 -0
- data/lib/rubocop/config_loader.rb +44 -9
- data/lib/rubocop/config_loader_resolver.rb +24 -9
- data/lib/rubocop/config_obsoletion/extracted_cop.rb +4 -3
- data/lib/rubocop/config_obsoletion.rb +1 -1
- data/lib/rubocop/config_validator.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/example_description.rb +7 -3
- data/lib/rubocop/cop/internal_affairs/location_exists.rb +116 -0
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/node_type_group.rb +91 -0
- data/lib/rubocop/cop/internal_affairs/plugin.rb +33 -0
- data/lib/rubocop/cop/internal_affairs/undefined_config.rb +7 -1
- data/lib/rubocop/cop/internal_affairs.rb +2 -16
- data/lib/rubocop/cop/layout/block_alignment.rb +2 -0
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +4 -4
- data/lib/rubocop/cop/layout/else_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +26 -1
- data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +22 -2
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +1 -1
- data/lib/rubocop/cop/layout/line_length.rb +3 -3
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +1 -1
- data/lib/rubocop/cop/lint/cop_directive_syntax.rb +84 -0
- data/lib/rubocop/cop/lint/duplicate_methods.rb +0 -14
- data/lib/rubocop/cop/lint/empty_conditional_body.rb +14 -64
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +0 -6
- data/lib/rubocop/cop/lint/float_comparison.rb +1 -6
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +1 -1
- data/lib/rubocop/cop/lint/literal_as_condition.rb +103 -9
- data/lib/rubocop/cop/lint/mixed_case_range.rb +2 -2
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +0 -21
- data/lib/rubocop/cop/lint/redundant_type_conversion.rb +258 -0
- data/lib/rubocop/cop/lint/return_in_void_context.rb +4 -11
- data/lib/rubocop/cop/lint/shared_mutable_default.rb +12 -1
- data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +111 -0
- data/lib/rubocop/cop/lint/useless_constant_scoping.rb +71 -0
- data/lib/rubocop/cop/lint/void.rb +6 -0
- data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +7 -7
- data/lib/rubocop/cop/mixin/alignment.rb +2 -2
- data/lib/rubocop/cop/mixin/allowed_pattern.rb +4 -4
- data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +1 -1
- data/lib/rubocop/cop/mixin/comments_help.rb +1 -1
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +18 -18
- data/lib/rubocop/cop/mixin/hash_subset.rb +19 -4
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +74 -74
- data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/range_help.rb +15 -3
- data/lib/rubocop/cop/mixin/string_help.rb +1 -1
- data/lib/rubocop/cop/mixin/target_ruby_version.rb +1 -1
- data/lib/rubocop/cop/mixin/trailing_comma.rb +12 -0
- data/lib/rubocop/cop/naming/block_forwarding.rb +3 -3
- data/lib/rubocop/cop/naming/predicate_name.rb +44 -0
- data/lib/rubocop/cop/naming/variable_name.rb +64 -6
- data/lib/rubocop/cop/style/accessor_grouping.rb +19 -5
- data/lib/rubocop/cop/style/arguments_forwarding.rb +3 -3
- data/lib/rubocop/cop/style/class_and_module_children.rb +29 -7
- data/lib/rubocop/cop/style/commented_keyword.rb +10 -3
- data/lib/rubocop/cop/style/comparable_between.rb +75 -0
- data/lib/rubocop/cop/style/double_negation.rb +1 -1
- data/lib/rubocop/cop/style/endless_method.rb +163 -18
- data/lib/rubocop/cop/style/expand_path_arguments.rb +2 -7
- data/lib/rubocop/cop/style/exponential_notation.rb +2 -2
- data/lib/rubocop/cop/style/format_string_token.rb +38 -11
- data/lib/rubocop/cop/style/if_unless_modifier.rb +2 -2
- data/lib/rubocop/cop/style/inverse_methods.rb +8 -5
- data/lib/rubocop/cop/style/keyword_parameters_order.rb +13 -7
- data/lib/rubocop/cop/style/line_end_concatenation.rb +10 -4
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +3 -3
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +1 -1
- data/lib/rubocop/cop/style/multiline_block_chain.rb +1 -1
- data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -9
- data/lib/rubocop/cop/style/redundant_condition.rb +45 -0
- data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +14 -4
- data/lib/rubocop/cop/style/redundant_format.rb +250 -0
- data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +18 -4
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/rescue_modifier.rb +3 -0
- data/lib/rubocop/cop/style/single_line_methods.rb +3 -3
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +0 -6
- data/lib/rubocop/cop/style/string_concatenation.rb +1 -1
- data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +47 -6
- data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +48 -6
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cop/utils/format_string.rb +10 -5
- data/lib/rubocop/cops_documentation_generator.rb +12 -1
- data/lib/rubocop/directive_comment.rb +36 -3
- data/lib/rubocop/ext/regexp_node.rb +0 -1
- data/lib/rubocop/lsp/runtime.rb +2 -0
- data/lib/rubocop/lsp/server.rb +0 -2
- data/lib/rubocop/options.rb +26 -11
- data/lib/rubocop/path_util.rb +4 -0
- data/lib/rubocop/plugin/configuration_integrator.rb +143 -0
- data/lib/rubocop/plugin/load_error.rb +26 -0
- data/lib/rubocop/plugin/loader.rb +100 -0
- data/lib/rubocop/plugin/not_supported_error.rb +29 -0
- data/lib/rubocop/plugin.rb +46 -0
- data/lib/rubocop/rake_task.rb +4 -1
- data/lib/rubocop/rspec/cop_helper.rb +9 -0
- data/lib/rubocop/rspec/shared_contexts.rb +15 -0
- data/lib/rubocop/rspec/support.rb +1 -0
- data/lib/rubocop/server/cache.rb +35 -2
- data/lib/rubocop/server/cli.rb +2 -2
- data/lib/rubocop/version.rb +17 -2
- data/lib/rubocop.rb +6 -1
- data/lib/ruby_lsp/rubocop/addon.rb +7 -10
- data/lib/ruby_lsp/rubocop/{wraps_built_in_lsp_runtime.rb → runtime_adapter.rb} +5 -8
- metadata +37 -10
- data/lib/rubocop/cop/utils/regexp_ranges.rb +0 -113
@@ -80,6 +80,21 @@ RSpec.shared_context 'maintain registry' do
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
RSpec.shared_context 'maintain default configuration' do
|
84
|
+
around(:each) do |example|
|
85
|
+
# Make a copy of the current configuration that will not change when source hash changes
|
86
|
+
default_configuration = RuboCop::ConfigLoader.default_configuration
|
87
|
+
config = RuboCop::Config.create(
|
88
|
+
default_configuration.to_h.clone,
|
89
|
+
default_configuration.loaded_path
|
90
|
+
)
|
91
|
+
|
92
|
+
example.run
|
93
|
+
|
94
|
+
RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
83
98
|
# This context assumes nothing and defines `cop`, among others.
|
84
99
|
RSpec.shared_context 'config' do # rubocop:disable Metrics/BlockLength
|
85
100
|
### Meant to be overridden at will
|
@@ -15,6 +15,7 @@ RSpec.configure do |config|
|
|
15
15
|
config.include_context 'isolated bundler', :isolated_bundler
|
16
16
|
config.include_context 'lsp', :lsp
|
17
17
|
config.include_context 'maintain registry', :restore_registry
|
18
|
+
config.include_context 'maintain default configuration', :restore_configuration
|
18
19
|
config.include_context 'ruby 2.0', :ruby20
|
19
20
|
config.include_context 'ruby 2.1', :ruby21
|
20
21
|
config.include_context 'ruby 2.2', :ruby22
|
data/lib/rubocop/server/cache.rb
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
require 'digest'
|
4
4
|
require 'pathname'
|
5
|
+
require 'yaml'
|
5
6
|
require_relative '../cache_config'
|
6
7
|
require_relative '../config_finder'
|
8
|
+
require_relative '../path_util'
|
7
9
|
|
8
10
|
#
|
9
11
|
# This code is based on https://github.com/fohte/rubocop-daemon.
|
@@ -50,9 +52,11 @@ module RuboCop
|
|
50
52
|
end.find(&:exist?)
|
51
53
|
version_data = lockfile_path&.read || RuboCop::Version::STRING
|
52
54
|
config_data = Pathname(ConfigFinder.find_config_path(Dir.pwd)).read
|
53
|
-
|
55
|
+
yaml = YAML.safe_load(config_data, permitted_classes: [Regexp, Symbol], aliases: true)
|
56
|
+
inherit_from_data = inherit_from_data(yaml)
|
57
|
+
require_data = require_data(yaml)
|
54
58
|
|
55
|
-
Digest::SHA1.hexdigest(version_data + config_data +
|
59
|
+
Digest::SHA1.hexdigest(version_data + config_data + inherit_from_data + require_data)
|
56
60
|
end
|
57
61
|
# rubocop:enable Metrics/AbcSize
|
58
62
|
|
@@ -164,6 +168,35 @@ module RuboCop
|
|
164
168
|
def write_version_file(version)
|
165
169
|
version_path.write(version)
|
166
170
|
end
|
171
|
+
|
172
|
+
def inherit_from_data(yaml)
|
173
|
+
return '' unless (inherit_from_paths = yaml['inherit_from'])
|
174
|
+
|
175
|
+
Array(inherit_from_paths).map do |path|
|
176
|
+
next if PathUtil.remote_file?(path)
|
177
|
+
|
178
|
+
path = Pathname(path)
|
179
|
+
|
180
|
+
path.exist? ? path.read : ''
|
181
|
+
end.join
|
182
|
+
end
|
183
|
+
|
184
|
+
def require_data(yaml)
|
185
|
+
return '' unless (require_paths = yaml['require'])
|
186
|
+
|
187
|
+
Array(require_paths).map do |path|
|
188
|
+
# NOTE: This targets only relative or absolute path specifications.
|
189
|
+
# For example, specifications like `require: rubocop-performance`,
|
190
|
+
# which can be loaded from `$LOAD_PATH`, are ignored.
|
191
|
+
next unless path.start_with?('.', '/')
|
192
|
+
|
193
|
+
# NOTE: `.so` files are not typically specified, so only `.rb` files are targeted.
|
194
|
+
path = "#{path}.rb" unless path.end_with?('.rb')
|
195
|
+
path = Pathname(path)
|
196
|
+
|
197
|
+
path.exist? ? path.read : ''
|
198
|
+
end.join
|
199
|
+
end
|
167
200
|
end
|
168
201
|
end
|
169
202
|
end
|
data/lib/rubocop/server/cli.rb
CHANGED
@@ -86,7 +86,7 @@ module RuboCop
|
|
86
86
|
end
|
87
87
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
88
88
|
|
89
|
-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
89
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
90
90
|
def run_command(server_command, detach:)
|
91
91
|
case server_command
|
92
92
|
when '--server'
|
@@ -107,7 +107,7 @@ module RuboCop
|
|
107
107
|
Server::ClientCommand::Status.new.run
|
108
108
|
end
|
109
109
|
end
|
110
|
-
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
110
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
111
111
|
|
112
112
|
def fetch_cache_root_path_from(arguments)
|
113
113
|
cache_root = arguments.detect { |argument| argument.start_with?('--cache-root') }
|
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.74.0'
|
7
7
|
|
8
8
|
MSG = '%<version>s (using %<parser_version>s, ' \
|
9
9
|
'rubocop-ast %<rubocop_ast_version>s, ' \
|
@@ -63,9 +63,21 @@ module RuboCop
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# @api private
|
66
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
66
67
|
def self.extension_versions(env)
|
68
|
+
plugins = config_for_pwd(env).loaded_plugins
|
69
|
+
plugin_versions = plugins.filter_map do |plugin|
|
70
|
+
next if Plugin::BUILTIN_INTERNAL_PLUGINS.key?(plugin.about.name)
|
71
|
+
next unless (plugin_name = plugin.about.name)
|
72
|
+
|
73
|
+
" - #{plugin_name} #{plugin.about.version}"
|
74
|
+
end
|
75
|
+
|
76
|
+
# TODO: It needs to be maintained for a while to ensure compatibility with extensions that
|
77
|
+
# don't support plugins. It should be removed in future once the old style becomes obsolete.
|
67
78
|
features = config_for_pwd(env).loaded_features.sort
|
68
|
-
features.
|
79
|
+
features -= plugins.map { |plugin| plugin.about.name }
|
80
|
+
feature_versions = features.filter_map do |loaded_feature|
|
69
81
|
next unless (match = loaded_feature.match(/rubocop-(?<feature>.*)/))
|
70
82
|
|
71
83
|
# Get the expected name of the folder containing the extension code.
|
@@ -84,7 +96,10 @@ module RuboCop
|
|
84
96
|
|
85
97
|
" - #{loaded_feature} #{feature_version}"
|
86
98
|
end
|
99
|
+
|
100
|
+
plugin_versions + feature_versions
|
87
101
|
end
|
102
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
88
103
|
|
89
104
|
# @api private
|
90
105
|
def self.target_ruby_version(env)
|
data/lib/rubocop.rb
CHANGED
@@ -148,7 +148,6 @@ require_relative 'rubocop/cop/mixin/comments_help' # relies on visibility_help
|
|
148
148
|
require_relative 'rubocop/cop/mixin/def_node' # relies on visibility_help
|
149
149
|
|
150
150
|
require_relative 'rubocop/cop/utils/format_string'
|
151
|
-
require_relative 'rubocop/cop/utils/regexp_ranges'
|
152
151
|
|
153
152
|
require_relative 'rubocop/cop/migration/department_name'
|
154
153
|
|
@@ -304,6 +303,7 @@ require_relative 'rubocop/cop/lint/constant_definition_in_block'
|
|
304
303
|
require_relative 'rubocop/cop/lint/constant_overwritten_in_rescue'
|
305
304
|
require_relative 'rubocop/cop/lint/constant_reassignment'
|
306
305
|
require_relative 'rubocop/cop/lint/constant_resolution'
|
306
|
+
require_relative 'rubocop/cop/lint/cop_directive_syntax'
|
307
307
|
require_relative 'rubocop/cop/lint/debugger'
|
308
308
|
require_relative 'rubocop/cop/lint/deprecated_class_methods'
|
309
309
|
require_relative 'rubocop/cop/lint/deprecated_constants'
|
@@ -384,6 +384,7 @@ require_relative 'rubocop/cop/lint/redundant_require_statement'
|
|
384
384
|
require_relative 'rubocop/cop/lint/redundant_safe_navigation'
|
385
385
|
require_relative 'rubocop/cop/lint/redundant_splat_expansion'
|
386
386
|
require_relative 'rubocop/cop/lint/redundant_string_coercion'
|
387
|
+
require_relative 'rubocop/cop/lint/redundant_type_conversion'
|
387
388
|
require_relative 'rubocop/cop/lint/redundant_with_index'
|
388
389
|
require_relative 'rubocop/cop/lint/redundant_with_object'
|
389
390
|
require_relative 'rubocop/cop/lint/refinement_import_methods'
|
@@ -405,6 +406,7 @@ require_relative 'rubocop/cop/lint/shadowed_exception'
|
|
405
406
|
require_relative 'rubocop/cop/lint/shadowing_outer_local_variable'
|
406
407
|
require_relative 'rubocop/cop/lint/struct_new_override'
|
407
408
|
require_relative 'rubocop/cop/lint/suppressed_exception'
|
409
|
+
require_relative 'rubocop/cop/lint/suppressed_exception_in_number_conversion'
|
408
410
|
require_relative 'rubocop/cop/lint/symbol_conversion'
|
409
411
|
require_relative 'rubocop/cop/lint/syntax'
|
410
412
|
require_relative 'rubocop/cop/lint/to_enum_arguments'
|
@@ -425,6 +427,7 @@ require_relative 'rubocop/cop/lint/uri_escape_unescape'
|
|
425
427
|
require_relative 'rubocop/cop/lint/uri_regexp'
|
426
428
|
require_relative 'rubocop/cop/lint/useless_access_modifier'
|
427
429
|
require_relative 'rubocop/cop/lint/useless_assignment'
|
430
|
+
require_relative 'rubocop/cop/lint/useless_constant_scoping'
|
428
431
|
require_relative 'rubocop/cop/lint/useless_defined'
|
429
432
|
require_relative 'rubocop/cop/lint/useless_else_without_rescue'
|
430
433
|
require_relative 'rubocop/cop/lint/useless_method_definition'
|
@@ -506,6 +509,7 @@ require_relative 'rubocop/cop/style/combinable_loops'
|
|
506
509
|
require_relative 'rubocop/cop/style/command_literal'
|
507
510
|
require_relative 'rubocop/cop/style/comment_annotation'
|
508
511
|
require_relative 'rubocop/cop/style/commented_keyword'
|
512
|
+
require_relative 'rubocop/cop/style/comparable_between'
|
509
513
|
require_relative 'rubocop/cop/style/comparable_clamp'
|
510
514
|
require_relative 'rubocop/cop/style/concat_array_literals'
|
511
515
|
require_relative 'rubocop/cop/style/conditional_assignment'
|
@@ -604,6 +608,7 @@ require_relative 'rubocop/cop/style/redundant_each'
|
|
604
608
|
require_relative 'rubocop/cop/style/redundant_fetch_block'
|
605
609
|
require_relative 'rubocop/cop/style/redundant_file_extension_in_require'
|
606
610
|
require_relative 'rubocop/cop/style/redundant_filter_chain'
|
611
|
+
require_relative 'rubocop/cop/style/redundant_format'
|
607
612
|
require_relative 'rubocop/cop/style/redundant_heredoc_delimiter_quotes'
|
608
613
|
require_relative 'rubocop/cop/style/redundant_initialize'
|
609
614
|
require_relative 'rubocop/cop/style/redundant_interpolation_unfreeze'
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
require_relative '../../rubocop'
|
4
4
|
require_relative '../../rubocop/lsp/logger'
|
5
|
-
require_relative '
|
5
|
+
require_relative 'runtime_adapter'
|
6
6
|
|
7
7
|
module RubyLsp
|
8
8
|
module RuboCop
|
9
9
|
# A Ruby LSP add-on for RuboCop.
|
10
10
|
class Addon < RubyLsp::Addon
|
11
11
|
def initializer
|
12
|
-
@
|
12
|
+
@runtime_adapter = nil
|
13
13
|
end
|
14
14
|
|
15
15
|
def name
|
@@ -21,11 +21,8 @@ module RubyLsp
|
|
21
21
|
"Activating RuboCop LSP addon #{::RuboCop::Version::STRING}.", prefix: '[RuboCop]'
|
22
22
|
)
|
23
23
|
|
24
|
-
|
25
|
-
@
|
26
|
-
|
27
|
-
global_state.register_formatter('rubocop', @wraps_built_in_lsp_runtime)
|
28
|
-
|
24
|
+
@runtime_adapter = RuntimeAdapter.new
|
25
|
+
global_state.register_formatter('rubocop', @runtime_adapter)
|
29
26
|
register_additional_file_watchers(global_state, message_queue)
|
30
27
|
|
31
28
|
::RuboCop::LSP::Logger.log(
|
@@ -34,7 +31,7 @@ module RubyLsp
|
|
34
31
|
end
|
35
32
|
|
36
33
|
def deactivate
|
37
|
-
@
|
34
|
+
@runtime_adapter = nil
|
38
35
|
end
|
39
36
|
|
40
37
|
# rubocop:disable Layout/LineLength, Metrics/MethodLength
|
@@ -67,9 +64,9 @@ module RubyLsp
|
|
67
64
|
def workspace_did_change_watched_files(changes)
|
68
65
|
return unless changes.any? { |change| change[:uri].end_with?('.rubocop.yml') }
|
69
66
|
|
70
|
-
@
|
67
|
+
@runtime_adapter = RuntimeAdapter.new
|
71
68
|
|
72
|
-
::RuboCop::LSP::Logger(<<~MESSAGE, prefix: '[RuboCop]')
|
69
|
+
::RuboCop::LSP::Logger.log(<<~MESSAGE, prefix: '[RuboCop]')
|
73
70
|
Re-initialized RuboCop LSP addon #{::RuboCop::Version::STRING} due to .rubocop.yml file change.
|
74
71
|
MESSAGE
|
75
72
|
end
|
@@ -4,18 +4,15 @@ require_relative '../../rubocop/lsp/runtime'
|
|
4
4
|
|
5
5
|
module RubyLsp
|
6
6
|
module RuboCop
|
7
|
-
#
|
8
|
-
|
7
|
+
# Provides an adapter to bridge RuboCop's built-in LSP runtime with Ruby LSP's add-on.
|
8
|
+
# @api private
|
9
|
+
class RuntimeAdapter
|
9
10
|
include RubyLsp::Requests::Support::Formatter
|
10
11
|
|
11
12
|
def initialize
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
def init!
|
16
|
-
config = ::RuboCop::ConfigStore.new
|
13
|
+
config_store = ::RuboCop::ConfigStore.new
|
17
14
|
|
18
|
-
@runtime = ::RuboCop::LSP::Runtime.new(
|
15
|
+
@runtime = ::RuboCop::LSP::Runtime.new(config_store)
|
19
16
|
end
|
20
17
|
|
21
18
|
def run_diagnostic(uri, document)
|
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.74.0
|
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-
|
12
|
+
date: 2025-03-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -29,16 +29,30 @@ dependencies:
|
|
29
29
|
name: language_server-protocol
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 3.17.0
|
34
|
+
version: 3.17.0.2
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 3.17.0.2
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: lint_roller
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.1.0
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
40
54
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
55
|
+
version: 1.1.0
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: parallel
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -272,6 +286,7 @@ files:
|
|
272
286
|
- lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb
|
273
287
|
- lib/rubocop/cop/internal_affairs/inherit_deprecated_cop_class.rb
|
274
288
|
- lib/rubocop/cop/internal_affairs/lambda_or_proc.rb
|
289
|
+
- lib/rubocop/cop/internal_affairs/location_exists.rb
|
275
290
|
- lib/rubocop/cop/internal_affairs/location_expression.rb
|
276
291
|
- lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb
|
277
292
|
- lib/rubocop/cop/internal_affairs/method_name_end_with.rb
|
@@ -282,12 +297,14 @@ files:
|
|
282
297
|
- lib/rubocop/cop/internal_affairs/node_pattern_groups.rb
|
283
298
|
- lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_processor.rb
|
284
299
|
- lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb
|
300
|
+
- lib/rubocop/cop/internal_affairs/node_type_group.rb
|
285
301
|
- lib/rubocop/cop/internal_affairs/node_type_multiple_predicates.rb
|
286
302
|
- lib/rubocop/cop/internal_affairs/node_type_predicate.rb
|
287
303
|
- lib/rubocop/cop/internal_affairs/numblock_handler.rb
|
288
304
|
- lib/rubocop/cop/internal_affairs/offense_location_keyword.rb
|
289
305
|
- lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb
|
290
306
|
- lib/rubocop/cop/internal_affairs/operator_keyword.rb
|
307
|
+
- lib/rubocop/cop/internal_affairs/plugin.rb
|
291
308
|
- lib/rubocop/cop/internal_affairs/processed_source_buffer_name.rb
|
292
309
|
- lib/rubocop/cop/internal_affairs/redundant_context_config_parameter.rb
|
293
310
|
- lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb
|
@@ -419,6 +436,7 @@ files:
|
|
419
436
|
- lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb
|
420
437
|
- lib/rubocop/cop/lint/constant_reassignment.rb
|
421
438
|
- lib/rubocop/cop/lint/constant_resolution.rb
|
439
|
+
- lib/rubocop/cop/lint/cop_directive_syntax.rb
|
422
440
|
- lib/rubocop/cop/lint/debugger.rb
|
423
441
|
- lib/rubocop/cop/lint/deprecated_class_methods.rb
|
424
442
|
- lib/rubocop/cop/lint/deprecated_constants.rb
|
@@ -498,6 +516,7 @@ files:
|
|
498
516
|
- lib/rubocop/cop/lint/redundant_safe_navigation.rb
|
499
517
|
- lib/rubocop/cop/lint/redundant_splat_expansion.rb
|
500
518
|
- lib/rubocop/cop/lint/redundant_string_coercion.rb
|
519
|
+
- lib/rubocop/cop/lint/redundant_type_conversion.rb
|
501
520
|
- lib/rubocop/cop/lint/redundant_with_index.rb
|
502
521
|
- lib/rubocop/cop/lint/redundant_with_object.rb
|
503
522
|
- lib/rubocop/cop/lint/refinement_import_methods.rb
|
@@ -520,6 +539,7 @@ files:
|
|
520
539
|
- lib/rubocop/cop/lint/shared_mutable_default.rb
|
521
540
|
- lib/rubocop/cop/lint/struct_new_override.rb
|
522
541
|
- lib/rubocop/cop/lint/suppressed_exception.rb
|
542
|
+
- lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb
|
523
543
|
- lib/rubocop/cop/lint/symbol_conversion.rb
|
524
544
|
- lib/rubocop/cop/lint/syntax.rb
|
525
545
|
- lib/rubocop/cop/lint/to_enum_arguments.rb
|
@@ -540,6 +560,7 @@ files:
|
|
540
560
|
- lib/rubocop/cop/lint/uri_regexp.rb
|
541
561
|
- lib/rubocop/cop/lint/useless_access_modifier.rb
|
542
562
|
- lib/rubocop/cop/lint/useless_assignment.rb
|
563
|
+
- lib/rubocop/cop/lint/useless_constant_scoping.rb
|
543
564
|
- lib/rubocop/cop/lint/useless_defined.rb
|
544
565
|
- lib/rubocop/cop/lint/useless_else_without_rescue.rb
|
545
566
|
- lib/rubocop/cop/lint/useless_method_definition.rb
|
@@ -708,6 +729,7 @@ files:
|
|
708
729
|
- lib/rubocop/cop/style/command_literal.rb
|
709
730
|
- lib/rubocop/cop/style/comment_annotation.rb
|
710
731
|
- lib/rubocop/cop/style/commented_keyword.rb
|
732
|
+
- lib/rubocop/cop/style/comparable_between.rb
|
711
733
|
- lib/rubocop/cop/style/comparable_clamp.rb
|
712
734
|
- lib/rubocop/cop/style/concat_array_literals.rb
|
713
735
|
- lib/rubocop/cop/style/conditional_assignment.rb
|
@@ -865,6 +887,7 @@ files:
|
|
865
887
|
- lib/rubocop/cop/style/redundant_fetch_block.rb
|
866
888
|
- lib/rubocop/cop/style/redundant_file_extension_in_require.rb
|
867
889
|
- lib/rubocop/cop/style/redundant_filter_chain.rb
|
890
|
+
- lib/rubocop/cop/style/redundant_format.rb
|
868
891
|
- lib/rubocop/cop/style/redundant_freeze.rb
|
869
892
|
- lib/rubocop/cop/style/redundant_heredoc_delimiter_quotes.rb
|
870
893
|
- lib/rubocop/cop/style/redundant_initialize.rb
|
@@ -950,7 +973,6 @@ files:
|
|
950
973
|
- lib/rubocop/cop/team.rb
|
951
974
|
- lib/rubocop/cop/util.rb
|
952
975
|
- lib/rubocop/cop/utils/format_string.rb
|
953
|
-
- lib/rubocop/cop/utils/regexp_ranges.rb
|
954
976
|
- lib/rubocop/cop/variable_force.rb
|
955
977
|
- lib/rubocop/cop/variable_force/assignment.rb
|
956
978
|
- lib/rubocop/cop/variable_force/branch.rb
|
@@ -1008,6 +1030,11 @@ files:
|
|
1008
1030
|
- lib/rubocop/options.rb
|
1009
1031
|
- lib/rubocop/path_util.rb
|
1010
1032
|
- lib/rubocop/platform.rb
|
1033
|
+
- lib/rubocop/plugin.rb
|
1034
|
+
- lib/rubocop/plugin/configuration_integrator.rb
|
1035
|
+
- lib/rubocop/plugin/load_error.rb
|
1036
|
+
- lib/rubocop/plugin/loader.rb
|
1037
|
+
- lib/rubocop/plugin/not_supported_error.rb
|
1011
1038
|
- lib/rubocop/rake_task.rb
|
1012
1039
|
- lib/rubocop/remote_config.rb
|
1013
1040
|
- lib/rubocop/result_cache.rb
|
@@ -1043,15 +1070,15 @@ files:
|
|
1043
1070
|
- lib/rubocop/warning.rb
|
1044
1071
|
- lib/rubocop/yaml_duplication_checker.rb
|
1045
1072
|
- lib/ruby_lsp/rubocop/addon.rb
|
1046
|
-
- lib/ruby_lsp/rubocop/
|
1073
|
+
- lib/ruby_lsp/rubocop/runtime_adapter.rb
|
1047
1074
|
homepage: https://github.com/rubocop/rubocop
|
1048
1075
|
licenses:
|
1049
1076
|
- MIT
|
1050
1077
|
metadata:
|
1051
1078
|
homepage_uri: https://rubocop.org/
|
1052
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.
|
1079
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.74.0
|
1053
1080
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1054
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
1081
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.74/
|
1055
1082
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1056
1083
|
rubygems_mfa_required: 'true'
|
1057
1084
|
rdoc_options: []
|
@@ -1,113 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module Utils
|
6
|
-
# Helper to abstract complexity of building range pairs
|
7
|
-
# with octal escape reconstruction (needed for regexp_parser < 2.7).
|
8
|
-
class RegexpRanges
|
9
|
-
attr_reader :root
|
10
|
-
|
11
|
-
def initialize(root)
|
12
|
-
@root = root
|
13
|
-
@compound_token = []
|
14
|
-
@pairs = []
|
15
|
-
@populated = false
|
16
|
-
end
|
17
|
-
|
18
|
-
def compound_token
|
19
|
-
populate_all unless @populated
|
20
|
-
|
21
|
-
@compound_token
|
22
|
-
end
|
23
|
-
|
24
|
-
def pairs
|
25
|
-
populate_all unless @populated
|
26
|
-
|
27
|
-
@pairs
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def populate_all
|
33
|
-
populate(@root)
|
34
|
-
|
35
|
-
# If either bound is a compound the first one is an escape
|
36
|
-
# and that's all we need to work with.
|
37
|
-
# If there are any cops that wanted to operate on the compound
|
38
|
-
# expression we could wrap it with a facade class.
|
39
|
-
@pairs.map! { |pair| pair.map(&:first) }
|
40
|
-
|
41
|
-
@populated = true
|
42
|
-
end
|
43
|
-
|
44
|
-
def populate(expr)
|
45
|
-
expressions = expr.expressions.to_a
|
46
|
-
|
47
|
-
until expressions.empty?
|
48
|
-
current = expressions.shift
|
49
|
-
|
50
|
-
if escaped_octal?(current)
|
51
|
-
@compound_token << current
|
52
|
-
@compound_token.concat(pop_octal_digits(expressions))
|
53
|
-
# If we have all the digits we can discard.
|
54
|
-
end
|
55
|
-
|
56
|
-
next unless current.type == :set
|
57
|
-
|
58
|
-
process_set(expressions, current)
|
59
|
-
@compound_token.clear
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def process_set(expressions, current)
|
64
|
-
case current.token
|
65
|
-
when :range
|
66
|
-
@pairs << compose_range(expressions, current)
|
67
|
-
when :character
|
68
|
-
# Child expressions may include the range we are looking for.
|
69
|
-
populate(current)
|
70
|
-
when :intersection
|
71
|
-
# Each child expression could have child expressions that lead to ranges.
|
72
|
-
current.expressions.each do |intersected|
|
73
|
-
populate(intersected)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def compose_range(expressions, current)
|
79
|
-
range_start, range_end = current.expressions
|
80
|
-
range_start = if @compound_token.size.between?(1, 2) && octal_digit?(range_start.text)
|
81
|
-
@compound_token.dup << range_start
|
82
|
-
else
|
83
|
-
[range_start]
|
84
|
-
end
|
85
|
-
range_end = [range_end]
|
86
|
-
range_end.concat(pop_octal_digits(expressions)) if escaped_octal?(range_end.first)
|
87
|
-
[range_start, range_end]
|
88
|
-
end
|
89
|
-
|
90
|
-
def escaped_octal?(expr)
|
91
|
-
expr.text.valid_encoding? && expr.text =~ /^\\[0-7]$/
|
92
|
-
end
|
93
|
-
|
94
|
-
def octal_digit?(char)
|
95
|
-
('0'..'7').cover?(char)
|
96
|
-
end
|
97
|
-
|
98
|
-
def pop_octal_digits(expressions)
|
99
|
-
digits = []
|
100
|
-
|
101
|
-
2.times do
|
102
|
-
next unless (next_child = expressions.first)
|
103
|
-
next unless next_child.type == :literal && next_child.text =~ /^[0-7]$/
|
104
|
-
|
105
|
-
digits << expressions.shift
|
106
|
-
end
|
107
|
-
|
108
|
-
digits
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|