rubocop 1.69.2 → 1.70.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/config/default.yml +19 -2
- data/lib/rubocop/cli/command/execute_runner.rb +3 -3
- data/lib/rubocop/config.rb +13 -4
- data/lib/rubocop/config_loader.rb +4 -0
- data/lib/rubocop/config_loader_resolver.rb +14 -3
- data/lib/rubocop/config_validator.rb +18 -8
- data/lib/rubocop/cop/base.rb +6 -0
- data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/cop_enabled.rb +85 -0
- data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +4 -3
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/layout/argument_alignment.rb +1 -7
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +1 -0
- data/lib/rubocop/cop/layout/extra_spacing.rb +1 -1
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +2 -7
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -7
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +1 -6
- data/lib/rubocop/cop/layout/hash_alignment.rb +6 -4
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +1 -0
- data/lib/rubocop/cop/layout/line_continuation_spacing.rb +7 -1
- data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/line_length.rb +1 -0
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +24 -0
- data/lib/rubocop/cop/layout/redundant_line_break.rb +1 -1
- data/lib/rubocop/cop/layout/space_after_method_name.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_operators.rb +3 -3
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +5 -3
- data/lib/rubocop/cop/lint/constant_reassignment.rb +152 -0
- data/lib/rubocop/cop/lint/duplicate_set_element.rb +20 -7
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +11 -3
- data/lib/rubocop/cop/lint/nested_method_definition.rb +5 -1
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +4 -3
- data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +6 -14
- data/lib/rubocop/cop/lint/shared_mutable_default.rb +65 -0
- data/lib/rubocop/cop/lint/syntax.rb +4 -1
- data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +1 -4
- data/lib/rubocop/cop/lint/void.rb +3 -2
- data/lib/rubocop/cop/metrics/method_length.rb +8 -1
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +7 -7
- data/lib/rubocop/cop/mixin/comments_help.rb +2 -0
- data/lib/rubocop/cop/mixin/dig_help.rb +1 -1
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +26 -16
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +1 -1
- data/lib/rubocop/cop/mixin/string_literals_help.rb +1 -1
- data/lib/rubocop/cop/naming/block_forwarding.rb +1 -1
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +32 -1
- data/lib/rubocop/cop/style/and_or.rb +1 -1
- data/lib/rubocop/cop/style/arguments_forwarding.rb +1 -4
- data/lib/rubocop/cop/style/class_and_module_children.rb +5 -2
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +3 -6
- data/lib/rubocop/cop/style/empty_else.rb +4 -2
- data/lib/rubocop/cop/style/empty_literal.rb +1 -1
- data/lib/rubocop/cop/style/empty_method.rb +1 -1
- data/lib/rubocop/cop/style/exact_regexp_match.rb +2 -9
- data/lib/rubocop/cop/style/exponential_notation.rb +1 -1
- data/lib/rubocop/cop/style/float_division.rb +8 -4
- data/lib/rubocop/cop/style/hash_except.rb +54 -67
- data/lib/rubocop/cop/style/hash_syntax.rb +5 -2
- data/lib/rubocop/cop/style/it_assignment.rb +36 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +11 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +2 -0
- data/lib/rubocop/cop/style/missing_else.rb +2 -0
- data/lib/rubocop/cop/style/multiple_comparison.rb +26 -20
- data/lib/rubocop/cop/style/mutable_constant.rb +1 -1
- data/lib/rubocop/cop/style/object_then.rb +13 -15
- data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +5 -3
- data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
- data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +2 -1
- data/lib/rubocop/cop/style/redundant_initialize.rb +12 -3
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +7 -3
- data/lib/rubocop/cop/style/redundant_parentheses.rb +1 -4
- data/lib/rubocop/cop/style/redundant_regexp_argument.rb +3 -0
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +6 -5
- data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
- data/lib/rubocop/cop/style/send_with_literal_method_name.rb +2 -1
- data/lib/rubocop/cop/style/single_line_do_end_block.rb +1 -2
- data/lib/rubocop/cop/style/single_line_methods.rb +2 -3
- data/lib/rubocop/cop/style/slicing_with_range.rb +40 -11
- data/lib/rubocop/cop/style/super_arguments.rb +63 -15
- data/lib/rubocop/cop/style/yoda_condition.rb +8 -4
- data/lib/rubocop/cop/style/yoda_expression.rb +1 -0
- data/lib/rubocop/cop/util.rb +9 -2
- data/lib/rubocop/formatter/formatter_set.rb +1 -1
- data/lib/rubocop/lsp/diagnostic.rb +189 -0
- data/lib/rubocop/lsp/logger.rb +2 -2
- data/lib/rubocop/lsp/routes.rb +7 -23
- data/lib/rubocop/lsp/runtime.rb +15 -49
- data/lib/rubocop/lsp/stdin_runner.rb +83 -0
- data/lib/rubocop/path_util.rb +11 -8
- data/lib/rubocop/rspec/shared_contexts.rb +4 -1
- data/lib/rubocop/runner.rb +5 -6
- data/lib/rubocop/target_ruby.rb +15 -0
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +3 -0
- data/lib/ruby_lsp/rubocop/addon.rb +78 -0
- data/lib/ruby_lsp/rubocop/wraps_built_in_lsp_runtime.rb +50 -0
- metadata +12 -4
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../rubocop'
|
4
|
+
require_relative '../../rubocop/lsp/logger'
|
5
|
+
require_relative 'wraps_built_in_lsp_runtime'
|
6
|
+
|
7
|
+
module RubyLsp
|
8
|
+
module RuboCop
|
9
|
+
# A Ruby LSP add-on for RuboCop.
|
10
|
+
class Addon < RubyLsp::Addon
|
11
|
+
def initializer
|
12
|
+
@wraps_built_in_lsp_runtime = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def name
|
16
|
+
'RuboCop'
|
17
|
+
end
|
18
|
+
|
19
|
+
def activate(global_state, message_queue)
|
20
|
+
::RuboCop::LSP::Logger.log(
|
21
|
+
"Activating RuboCop LSP addon #{::RuboCop::Version::STRING}.", prefix: '[RuboCop]'
|
22
|
+
)
|
23
|
+
|
24
|
+
::RuboCop::LSP.enable
|
25
|
+
@wraps_built_in_lsp_runtime = WrapsBuiltinLspRuntime.new
|
26
|
+
|
27
|
+
global_state.register_formatter('rubocop', @wraps_built_in_lsp_runtime)
|
28
|
+
|
29
|
+
register_additional_file_watchers(global_state, message_queue)
|
30
|
+
|
31
|
+
::RuboCop::LSP::Logger.log(
|
32
|
+
"Initialized RuboCop LSP addon #{::RuboCop::Version::STRING}.", prefix: '[RuboCop]'
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def deactivate
|
37
|
+
@wraps_built_in_lsp_runtime = nil
|
38
|
+
end
|
39
|
+
|
40
|
+
# rubocop:disable Layout/LineLength, Metrics/MethodLength
|
41
|
+
def register_additional_file_watchers(global_state, message_queue)
|
42
|
+
return unless global_state.supports_watching_files
|
43
|
+
|
44
|
+
message_queue << Request.new(
|
45
|
+
id: 'rubocop-file-watcher',
|
46
|
+
method: 'client/registerCapability',
|
47
|
+
params: Interface::RegistrationParams.new(
|
48
|
+
registrations: [
|
49
|
+
Interface::Registration.new(
|
50
|
+
id: 'workspace/didChangeWatchedFilesRuboCop',
|
51
|
+
method: 'workspace/didChangeWatchedFiles',
|
52
|
+
register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new(
|
53
|
+
watchers: [
|
54
|
+
Interface::FileSystemWatcher.new(
|
55
|
+
glob_pattern: '**/.rubocop{,_todo}.yml',
|
56
|
+
kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE
|
57
|
+
)
|
58
|
+
]
|
59
|
+
)
|
60
|
+
)
|
61
|
+
]
|
62
|
+
)
|
63
|
+
)
|
64
|
+
end
|
65
|
+
# rubocop:enable Layout/LineLength, Metrics/MethodLength
|
66
|
+
|
67
|
+
def workspace_did_change_watched_files(changes)
|
68
|
+
return unless changes.any? { |change| change[:uri].end_with?('.rubocop.yml') }
|
69
|
+
|
70
|
+
@wraps_built_in_lsp_runtime.init!
|
71
|
+
|
72
|
+
::RuboCop::LSP::Logger(<<~MESSAGE, prefix: '[RuboCop]')
|
73
|
+
Re-initialized RuboCop LSP addon #{::RuboCop::Version::STRING} due to .rubocop.yml file change.
|
74
|
+
MESSAGE
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../rubocop/lsp/runtime'
|
4
|
+
|
5
|
+
module RubyLsp
|
6
|
+
module RuboCop
|
7
|
+
# Wrap RuboCop's built-in runtime for Ruby LSP's add-on.
|
8
|
+
class WrapsBuiltinLspRuntime
|
9
|
+
include RubyLsp::Requests::Support::Formatter
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
init!
|
13
|
+
end
|
14
|
+
|
15
|
+
def init!
|
16
|
+
config = ::RuboCop::ConfigStore.new
|
17
|
+
|
18
|
+
@runtime = ::RuboCop::LSP::Runtime.new(config)
|
19
|
+
end
|
20
|
+
|
21
|
+
def run_diagnostic(uri, document)
|
22
|
+
@runtime.offenses(uri_to_path(uri), document.source, document.encoding)
|
23
|
+
end
|
24
|
+
|
25
|
+
def run_formatting(uri, document)
|
26
|
+
@runtime.format(uri_to_path(uri), document.source, command: 'rubocop.formatAutocorrects')
|
27
|
+
end
|
28
|
+
|
29
|
+
def run_range_formatting(_uri, _partial_source, _base_indentation)
|
30
|
+
# Not yet supported. Should return the formatted version of `partial_source` which is
|
31
|
+
# a partial selection of the entire document. For example, it should not try to add
|
32
|
+
# a frozen_string_literal magic comment and all style corrections should start from
|
33
|
+
# the `base_indentation`.
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
# duplicated from: lib/standard/lsp/routes.rb
|
40
|
+
# modified to incorporate Ruby LSP's to_standardized_path method
|
41
|
+
def uri_to_path(uri)
|
42
|
+
if uri.respond_to?(:to_standardized_path) && (standardized_path = uri.to_standardized_path)
|
43
|
+
standardized_path
|
44
|
+
else
|
45
|
+
uri.to_s.delete_prefix('file://')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
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.70.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:
|
13
|
+
date: 2025-01-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -266,6 +266,7 @@ files:
|
|
266
266
|
- lib/rubocop/cop/ignored_node.rb
|
267
267
|
- lib/rubocop/cop/internal_affairs.rb
|
268
268
|
- lib/rubocop/cop/internal_affairs/cop_description.rb
|
269
|
+
- lib/rubocop/cop/internal_affairs/cop_enabled.rb
|
269
270
|
- lib/rubocop/cop/internal_affairs/create_empty_file.rb
|
270
271
|
- lib/rubocop/cop/internal_affairs/empty_line_between_expect_offense_and_correction.rb
|
271
272
|
- lib/rubocop/cop/internal_affairs/example_description.rb
|
@@ -411,6 +412,7 @@ files:
|
|
411
412
|
- lib/rubocop/cop/lint/circular_argument_reference.rb
|
412
413
|
- lib/rubocop/cop/lint/constant_definition_in_block.rb
|
413
414
|
- lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb
|
415
|
+
- lib/rubocop/cop/lint/constant_reassignment.rb
|
414
416
|
- lib/rubocop/cop/lint/constant_resolution.rb
|
415
417
|
- lib/rubocop/cop/lint/debugger.rb
|
416
418
|
- lib/rubocop/cop/lint/deprecated_class_methods.rb
|
@@ -510,6 +512,7 @@ files:
|
|
510
512
|
- lib/rubocop/cop/lint/shadowed_argument.rb
|
511
513
|
- lib/rubocop/cop/lint/shadowed_exception.rb
|
512
514
|
- lib/rubocop/cop/lint/shadowing_outer_local_variable.rb
|
515
|
+
- lib/rubocop/cop/lint/shared_mutable_default.rb
|
513
516
|
- lib/rubocop/cop/lint/struct_new_override.rb
|
514
517
|
- lib/rubocop/cop/lint/suppressed_exception.rb
|
515
518
|
- lib/rubocop/cop/lint/symbol_conversion.rb
|
@@ -770,6 +773,7 @@ files:
|
|
770
773
|
- lib/rubocop/cop/style/inverse_methods.rb
|
771
774
|
- lib/rubocop/cop/style/invertible_unless_condition.rb
|
772
775
|
- lib/rubocop/cop/style/ip_addresses.rb
|
776
|
+
- lib/rubocop/cop/style/it_assignment.rb
|
773
777
|
- lib/rubocop/cop/style/keyword_arguments_merging.rb
|
774
778
|
- lib/rubocop/cop/style/keyword_parameters_order.rb
|
775
779
|
- lib/rubocop/cop/style/lambda.rb
|
@@ -985,11 +989,13 @@ files:
|
|
985
989
|
- lib/rubocop/formatter/worst_offenders_formatter.rb
|
986
990
|
- lib/rubocop/lockfile.rb
|
987
991
|
- lib/rubocop/lsp.rb
|
992
|
+
- lib/rubocop/lsp/diagnostic.rb
|
988
993
|
- lib/rubocop/lsp/logger.rb
|
989
994
|
- lib/rubocop/lsp/routes.rb
|
990
995
|
- lib/rubocop/lsp/runtime.rb
|
991
996
|
- lib/rubocop/lsp/server.rb
|
992
997
|
- lib/rubocop/lsp/severity.rb
|
998
|
+
- lib/rubocop/lsp/stdin_runner.rb
|
993
999
|
- lib/rubocop/magic_comment.rb
|
994
1000
|
- lib/rubocop/name_similarity.rb
|
995
1001
|
- lib/rubocop/options.rb
|
@@ -1030,14 +1036,16 @@ files:
|
|
1030
1036
|
- lib/rubocop/version.rb
|
1031
1037
|
- lib/rubocop/warning.rb
|
1032
1038
|
- lib/rubocop/yaml_duplication_checker.rb
|
1039
|
+
- lib/ruby_lsp/rubocop/addon.rb
|
1040
|
+
- lib/ruby_lsp/rubocop/wraps_built_in_lsp_runtime.rb
|
1033
1041
|
homepage: https://github.com/rubocop/rubocop
|
1034
1042
|
licenses:
|
1035
1043
|
- MIT
|
1036
1044
|
metadata:
|
1037
1045
|
homepage_uri: https://rubocop.org/
|
1038
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.
|
1046
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.70.0
|
1039
1047
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1040
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
1048
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.70/
|
1041
1049
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1042
1050
|
rubygems_mfa_required: 'true'
|
1043
1051
|
post_install_message:
|