rubocop 1.66.0 → 1.67.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 +1 -1
- data/config/default.yml +15 -6
- data/config/internal_affairs.yml +11 -0
- data/lib/rubocop/cli/command/auto_generate_config.rb +6 -7
- data/lib/rubocop/cli/command/lsp.rb +2 -2
- data/lib/rubocop/comment_config.rb +4 -8
- data/lib/rubocop/config.rb +4 -16
- data/lib/rubocop/config_loader.rb +14 -8
- data/lib/rubocop/config_loader_resolver.rb +3 -3
- data/lib/rubocop/config_validator.rb +7 -10
- data/lib/rubocop/cop/base.rb +6 -2
- data/lib/rubocop/cop/bundler/gem_version.rb +1 -0
- data/lib/rubocop/cop/cop.rb +8 -0
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/cop_description.rb +0 -4
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +6 -21
- data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +8 -1
- data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +0 -5
- data/lib/rubocop/cop/internal_affairs.rb +16 -0
- data/lib/rubocop/cop/layout/access_modifier_indentation.rb +5 -1
- data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +1 -1
- data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +8 -0
- data/lib/rubocop/cop/layout/indentation_width.rb +4 -5
- data/lib/rubocop/cop/layout/leading_comment_space.rb +28 -1
- data/lib/rubocop/cop/lint/ambiguous_range.rb +4 -1
- data/lib/rubocop/cop/lint/big_decimal_new.rb +4 -7
- data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_set_element.rb +74 -0
- data/lib/rubocop/cop/lint/ensure_return.rb +0 -3
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +1 -1
- data/lib/rubocop/cop/lint/float_comparison.rb +1 -1
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +10 -4
- data/lib/rubocop/cop/lint/it_without_arguments_in_block.rb +5 -14
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +25 -2
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +5 -6
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +1 -1
- data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +105 -41
- data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
- data/lib/rubocop/cop/lint/uri_regexp.rb +25 -7
- data/lib/rubocop/cop/mixin/percent_array.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +3 -2
- data/lib/rubocop/cop/naming/inclusive_language.rb +12 -3
- data/lib/rubocop/cop/naming/predicate_name.rb +1 -1
- data/lib/rubocop/cop/offense.rb +2 -2
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +12 -2
- data/lib/rubocop/cop/style/accessor_grouping.rb +10 -2
- data/lib/rubocop/cop/style/arguments_forwarding.rb +46 -6
- data/lib/rubocop/cop/style/block_delimiters.rb +14 -1
- data/lib/rubocop/cop/style/collection_compact.rb +10 -10
- data/lib/rubocop/cop/style/combinable_loops.rb +7 -0
- data/lib/rubocop/cop/style/commented_keyword.rb +7 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +1 -1
- data/lib/rubocop/cop/style/data_inheritance.rb +1 -1
- data/lib/rubocop/cop/style/empty_else.rb +1 -0
- data/lib/rubocop/cop/style/empty_literal.rb +1 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +1 -1
- data/lib/rubocop/cop/style/guard_clause.rb +1 -1
- data/lib/rubocop/cop/style/hash_each_methods.rb +6 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +2 -2
- data/lib/rubocop/cop/style/if_inside_else.rb +1 -1
- data/lib/rubocop/cop/style/if_with_semicolon.rb +16 -5
- data/lib/rubocop/cop/style/lambda.rb +1 -1
- data/lib/rubocop/cop/style/magic_comment_format.rb +3 -8
- data/lib/rubocop/cop/style/map_into_array.rb +54 -10
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +12 -7
- data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
- data/lib/rubocop/cop/style/nested_modifier.rb +1 -1
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +1 -1
- data/lib/rubocop/cop/style/one_line_conditional.rb +4 -0
- data/lib/rubocop/cop/style/operator_method_call.rb +25 -6
- data/lib/rubocop/cop/style/redundant_begin.rb +4 -0
- data/lib/rubocop/cop/style/redundant_condition.rb +1 -1
- data/lib/rubocop/cop/style/redundant_interpolation_unfreeze.rb +1 -1
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +3 -3
- data/lib/rubocop/cop/style/redundant_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/require_order.rb +1 -1
- data/lib/rubocop/cop/style/rescue_modifier.rb +13 -1
- data/lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb +54 -12
- data/lib/rubocop/cop/style/safe_navigation.rb +92 -50
- data/lib/rubocop/cop/style/select_by_regexp.rb +9 -6
- data/lib/rubocop/cop/style/semicolon.rb +1 -1
- data/lib/rubocop/cop/style/struct_inheritance.rb +1 -1
- data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/team.rb +8 -1
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cops_documentation_generator.rb +73 -34
- data/lib/rubocop/file_finder.rb +9 -4
- data/lib/rubocop/lsp/runtime.rb +2 -0
- data/lib/rubocop/lsp/server.rb +0 -1
- data/lib/rubocop/rspec/expect_offense.rb +1 -0
- data/lib/rubocop/runner.rb +3 -0
- data/lib/rubocop/server/cache.rb +6 -1
- data/lib/rubocop/server/core.rb +1 -0
- data/lib/rubocop/target_ruby.rb +12 -12
- data/lib/rubocop/version.rb +3 -1
- data/lib/rubocop/yaml_duplication_checker.rb +20 -26
- data/lib/rubocop.rb +2 -0
- metadata +12 -10
data/lib/rubocop/target_ruby.rb
CHANGED
@@ -53,8 +53,6 @@ module RuboCop
|
|
53
53
|
class GemspecFile < Source
|
54
54
|
extend NodePattern::Macros
|
55
55
|
|
56
|
-
GEMSPEC_EXTENSION = '.gemspec'
|
57
|
-
|
58
56
|
# @!method required_ruby_version(node)
|
59
57
|
def_node_search :required_ruby_version, <<~PATTERN
|
60
58
|
(send _ :required_ruby_version= $_)
|
@@ -68,7 +66,7 @@ module RuboCop
|
|
68
66
|
PATTERN
|
69
67
|
|
70
68
|
def name
|
71
|
-
"`required_ruby_version` parameter (in #{
|
69
|
+
"`required_ruby_version` parameter (in #{gemspec_filepath})"
|
72
70
|
end
|
73
71
|
|
74
72
|
private
|
@@ -83,16 +81,18 @@ module RuboCop
|
|
83
81
|
find_minimal_known_ruby(right_hand_side)
|
84
82
|
end
|
85
83
|
|
86
|
-
def gemspec_filename
|
87
|
-
@gemspec_filename ||= begin
|
88
|
-
basename = Pathname.new(@config.base_dir_for_path_parameters).basename.to_s
|
89
|
-
"#{basename}#{GEMSPEC_EXTENSION}"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
84
|
def gemspec_filepath
|
94
|
-
@gemspec_filepath
|
95
|
-
|
85
|
+
return @gemspec_filepath if defined?(@gemspec_filepath)
|
86
|
+
|
87
|
+
@gemspec_filepath =
|
88
|
+
@config.traverse_directories_upwards(@config.base_dir_for_path_parameters) do |dir|
|
89
|
+
# NOTE: Can't use `dir.glob` because of JRuby 9.4.8.0 incompatibility:
|
90
|
+
# https://github.com/jruby/jruby/issues/8358
|
91
|
+
candidates = Pathname.glob("#{dir}/*.gemspec")
|
92
|
+
# Bundler will use a gemspec whatever the filename is, as long as its the only one in
|
93
|
+
# the folder.
|
94
|
+
break candidates.first if candidates.one?
|
95
|
+
end
|
96
96
|
end
|
97
97
|
|
98
98
|
def version_from_gemspec_file(file)
|
data/lib/rubocop/version.rb
CHANGED
@@ -3,10 +3,11 @@
|
|
3
3
|
module RuboCop
|
4
4
|
# This module holds the RuboCop version information.
|
5
5
|
module Version
|
6
|
-
STRING = '1.
|
6
|
+
STRING = '1.67.0'
|
7
7
|
|
8
8
|
MSG = '%<version>s (using %<parser_version>s, ' \
|
9
9
|
'rubocop-ast %<rubocop_ast_version>s, ' \
|
10
|
+
'analyzing as Ruby %<target_ruby_version>s, ' \
|
10
11
|
'running on %<ruby_engine>s %<ruby_version>s)%<server_mode>s [%<ruby_platform>s]'
|
11
12
|
|
12
13
|
CANONICAL_FEATURE_NAMES = {
|
@@ -22,6 +23,7 @@ module RuboCop
|
|
22
23
|
if debug
|
23
24
|
verbose_version = format(MSG, version: STRING, parser_version: parser_version,
|
24
25
|
rubocop_ast_version: RuboCop::AST::Version::STRING,
|
26
|
+
target_ruby_version: TargetRuby.new(Config.new).version,
|
25
27
|
ruby_engine: RUBY_ENGINE, ruby_version: RUBY_VERSION,
|
26
28
|
server_mode: server_mode,
|
27
29
|
ruby_platform: RUBY_PLATFORM)
|
@@ -5,36 +5,30 @@ module RuboCop
|
|
5
5
|
# @api private
|
6
6
|
module YAMLDuplicationChecker
|
7
7
|
def self.check(yaml_string, filename, &on_duplicated)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
YAML.parse(yaml_string, filename: filename)
|
13
|
-
else
|
14
|
-
YAML.parse(yaml_string, filename)
|
15
|
-
end
|
16
|
-
return unless tree
|
17
|
-
|
18
|
-
traverse(tree, &on_duplicated)
|
8
|
+
handler = DuplicationCheckHandler.new(&on_duplicated)
|
9
|
+
parser = Psych::Parser.new(handler)
|
10
|
+
parser.parse(yaml_string, filename)
|
11
|
+
parser.handler.root.children[0]
|
19
12
|
end
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
yield(exist, key) if exist
|
27
|
-
keys << key
|
28
|
-
traverse(value, &on_duplicated)
|
29
|
-
end
|
30
|
-
else
|
31
|
-
children = tree.children
|
32
|
-
return unless children
|
14
|
+
class DuplicationCheckHandler < Psych::TreeBuilder # :nodoc:
|
15
|
+
def initialize(&block)
|
16
|
+
super()
|
17
|
+
@block = block
|
18
|
+
end
|
33
19
|
|
34
|
-
|
20
|
+
def end_mapping
|
21
|
+
mapping_node = super
|
22
|
+
# OPTIMIZE: Use a hash for faster lookup since there can
|
23
|
+
# be quite a few keys at the top-level.
|
24
|
+
keys = {}
|
25
|
+
mapping_node.children.each_slice(2) do |key, _value|
|
26
|
+
duplicate = keys[key.value]
|
27
|
+
@block.call(duplicate, key) if duplicate
|
28
|
+
keys[key.value] = key
|
29
|
+
end
|
30
|
+
mapping_node
|
35
31
|
end
|
36
32
|
end
|
37
|
-
|
38
|
-
private_class_method :traverse
|
39
33
|
end
|
40
34
|
end
|
data/lib/rubocop.rb
CHANGED
@@ -312,6 +312,7 @@ require_relative 'rubocop/cop/lint/duplicate_methods'
|
|
312
312
|
require_relative 'rubocop/cop/lint/duplicate_regexp_character_class_element'
|
313
313
|
require_relative 'rubocop/cop/lint/duplicate_require'
|
314
314
|
require_relative 'rubocop/cop/lint/duplicate_rescue_exception'
|
315
|
+
require_relative 'rubocop/cop/lint/duplicate_set_element'
|
315
316
|
require_relative 'rubocop/cop/lint/each_with_object_argument'
|
316
317
|
require_relative 'rubocop/cop/lint/else_layout'
|
317
318
|
require_relative 'rubocop/cop/lint/empty_block'
|
@@ -750,6 +751,7 @@ require_relative 'rubocop/config_store'
|
|
750
751
|
require_relative 'rubocop/config_validator'
|
751
752
|
require_relative 'rubocop/feature_loader'
|
752
753
|
require_relative 'rubocop/lockfile'
|
754
|
+
require_relative 'rubocop/lsp'
|
753
755
|
require_relative 'rubocop/target_finder'
|
754
756
|
require_relative 'rubocop/directive_comment'
|
755
757
|
require_relative 'rubocop/comment_config'
|
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.67.0
|
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-10-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -114,7 +114,7 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.32.
|
117
|
+
version: 1.32.2
|
118
118
|
- - "<"
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '2.0'
|
@@ -124,7 +124,7 @@ dependencies:
|
|
124
124
|
requirements:
|
125
125
|
- - ">="
|
126
126
|
- !ruby/object:Gem::Version
|
127
|
-
version: 1.32.
|
127
|
+
version: 1.32.2
|
128
128
|
- - "<"
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '2.0'
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- assets/output.css.erb
|
180
180
|
- assets/output.html.erb
|
181
181
|
- config/default.yml
|
182
|
+
- config/internal_affairs.yml
|
182
183
|
- config/obsoletion.yml
|
183
184
|
- exe/rubocop
|
184
185
|
- lib/rubocop.rb
|
@@ -425,6 +426,7 @@ files:
|
|
425
426
|
- lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb
|
426
427
|
- lib/rubocop/cop/lint/duplicate_require.rb
|
427
428
|
- lib/rubocop/cop/lint/duplicate_rescue_exception.rb
|
429
|
+
- lib/rubocop/cop/lint/duplicate_set_element.rb
|
428
430
|
- lib/rubocop/cop/lint/each_with_object_argument.rb
|
429
431
|
- lib/rubocop/cop/lint/else_layout.rb
|
430
432
|
- lib/rubocop/cop/lint/empty_block.rb
|
@@ -1017,12 +1019,12 @@ licenses:
|
|
1017
1019
|
- MIT
|
1018
1020
|
metadata:
|
1019
1021
|
homepage_uri: https://rubocop.org/
|
1020
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.
|
1022
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.67.0
|
1021
1023
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1022
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
1024
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.67/
|
1023
1025
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1024
1026
|
rubygems_mfa_required: 'true'
|
1025
|
-
post_install_message:
|
1027
|
+
post_install_message:
|
1026
1028
|
rdoc_options: []
|
1027
1029
|
require_paths:
|
1028
1030
|
- lib
|
@@ -1037,8 +1039,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1037
1039
|
- !ruby/object:Gem::Version
|
1038
1040
|
version: '0'
|
1039
1041
|
requirements: []
|
1040
|
-
rubygems_version: 3.
|
1041
|
-
signing_key:
|
1042
|
+
rubygems_version: 3.3.7
|
1043
|
+
signing_key:
|
1042
1044
|
specification_version: 4
|
1043
1045
|
summary: Automatic Ruby code style checking tool.
|
1044
1046
|
test_files: []
|