rubocop 1.70.0 → 1.71.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 +17 -0
- data/lib/rubocop/cli/command/show_cops.rb +24 -2
- data/lib/rubocop/comment_config.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/location_expression.rb +2 -1
- data/lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb +3 -2
- data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +90 -0
- data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +2 -1
- data/lib/rubocop/cop/internal_affairs/single_line_comparison.rb +5 -4
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/layout/argument_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/class_structure.rb +7 -7
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +1 -1
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +1 -0
- data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +1 -0
- data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -0
- data/lib/rubocop/cop/lint/array_literal_in_regexp.rb +119 -0
- data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_set_element.rb +1 -1
- data/lib/rubocop/cop/lint/float_comparison.rb +5 -2
- data/lib/rubocop/cop/lint/float_out_of_range.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +12 -2
- data/lib/rubocop/cop/lint/mixed_case_range.rb +1 -1
- data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -1
- data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +12 -17
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +2 -1
- data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +2 -2
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +7 -0
- data/lib/rubocop/cop/lint/shared_mutable_default.rb +3 -3
- data/lib/rubocop/cop/lint/useless_assignment.rb +1 -1
- data/lib/rubocop/cop/lint/useless_numeric_operation.rb +2 -1
- data/lib/rubocop/cop/metrics/collection_literal_length.rb +7 -0
- data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +1 -1
- data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/hash_subset.rb +170 -0
- data/lib/rubocop/cop/mixin/statement_modifier.rb +7 -2
- data/lib/rubocop/cop/mixin/trailing_comma.rb +2 -2
- data/lib/rubocop/cop/security/compound_hash.rb +1 -0
- data/lib/rubocop/cop/style/array_first_last.rb +18 -2
- data/lib/rubocop/cop/style/block_delimiters.rb +6 -19
- data/lib/rubocop/cop/style/collection_methods.rb +1 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +3 -1
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
- data/lib/rubocop/cop/style/exact_regexp_match.rb +1 -1
- data/lib/rubocop/cop/style/fetch_env_var.rb +1 -1
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
- data/lib/rubocop/cop/style/hash_each_methods.rb +1 -1
- data/lib/rubocop/cop/style/hash_except.rb +5 -131
- data/lib/rubocop/cop/style/hash_slice.rb +65 -0
- data/lib/rubocop/cop/style/map_to_set.rb +3 -2
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +2 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +1 -1
- data/lib/rubocop/cop/style/open_struct_use.rb +4 -4
- data/lib/rubocop/cop/style/raise_args.rb +1 -1
- data/lib/rubocop/cop/style/redundant_exception.rb +1 -1
- data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +27 -10
- data/lib/rubocop/cop/style/redundant_parentheses.rb +3 -0
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +1 -1
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +1 -1
- data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +1 -1
- data/lib/rubocop/cop/style/string_methods.rb +1 -1
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +4 -1
- data/lib/rubocop/cops_documentation_generator.rb +13 -13
- data/lib/rubocop/directive_comment.rb +9 -8
- data/lib/rubocop/options.rb +2 -1
- data/lib/rubocop/result_cache.rb +13 -13
- data/lib/rubocop/rspec/expect_offense.rb +6 -2
- data/lib/rubocop/target_finder.rb +1 -0
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +3 -0
- metadata +9 -8
data/lib/rubocop/result_cache.rb
CHANGED
@@ -25,16 +25,16 @@ module RuboCop
|
|
25
25
|
# cleaning should be done relatively seldom, since there is a slight risk
|
26
26
|
# that some other RuboCop process was just about to read the file, when
|
27
27
|
# there's parallel execution and the cache is shared.
|
28
|
-
def self.cleanup(config_store, verbose,
|
28
|
+
def self.cleanup(config_store, verbose, cache_root_override = nil)
|
29
29
|
return if inhibit_cleanup # OPTIMIZE: For faster testing
|
30
30
|
|
31
|
-
|
32
|
-
return unless File.exist?(
|
31
|
+
rubocop_cache_dir = cache_root(config_store, cache_root_override)
|
32
|
+
return unless File.exist?(rubocop_cache_dir)
|
33
33
|
|
34
|
-
files, dirs = Find.find(
|
34
|
+
files, dirs = Find.find(rubocop_cache_dir).partition { |path| File.file?(path) }
|
35
35
|
return unless requires_file_removal?(files.length, config_store)
|
36
36
|
|
37
|
-
remove_oldest_files(files, dirs,
|
37
|
+
remove_oldest_files(files, dirs, rubocop_cache_dir, verbose)
|
38
38
|
end
|
39
39
|
|
40
40
|
class << self
|
@@ -49,11 +49,11 @@ module RuboCop
|
|
49
49
|
file_count > 1 && file_count > config_store.for_pwd.for_all_cops['MaxFilesInCache']
|
50
50
|
end
|
51
51
|
|
52
|
-
def remove_oldest_files(files, dirs,
|
52
|
+
def remove_oldest_files(files, dirs, rubocop_cache_dir, verbose)
|
53
53
|
# Add 1 to half the number of files, so that we remove the file if
|
54
54
|
# there's only 1 left.
|
55
55
|
remove_count = (files.length / 2) + 1
|
56
|
-
puts "Removing the #{remove_count} oldest files from #{
|
56
|
+
puts "Removing the #{remove_count} oldest files from #{rubocop_cache_dir}" if verbose
|
57
57
|
sorted = files.sort_by { |path| File.mtime(path) }
|
58
58
|
remove_files(sorted, dirs, remove_count)
|
59
59
|
rescue Errno::ENOENT
|
@@ -72,9 +72,9 @@ module RuboCop
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
def self.cache_root(config_store)
|
75
|
+
def self.cache_root(config_store, cache_root_override = nil)
|
76
76
|
CacheConfig.root_dir do
|
77
|
-
config_store.for_pwd.for_all_cops['CacheRootDirectory']
|
77
|
+
cache_root_override || config_store.for_pwd.for_all_cops['CacheRootDirectory']
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -84,12 +84,12 @@ module RuboCop
|
|
84
84
|
|
85
85
|
attr_reader :path
|
86
86
|
|
87
|
-
def initialize(file, team, options, config_store,
|
88
|
-
|
89
|
-
|
87
|
+
def initialize(file, team, options, config_store, cache_root_override = nil)
|
88
|
+
cache_root_override ||= options[:cache_root] if options[:cache_root]
|
89
|
+
rubocop_cache_dir = ResultCache.cache_root(config_store, cache_root_override)
|
90
90
|
@allow_symlinks_in_cache_location =
|
91
91
|
ResultCache.allow_symlinks_in_cache_location?(config_store)
|
92
|
-
@path = File.join(
|
92
|
+
@path = File.join(rubocop_cache_dir,
|
93
93
|
rubocop_checksum,
|
94
94
|
context_checksum(team, options),
|
95
95
|
file_checksum(file, config_store))
|
@@ -190,7 +190,10 @@ module RuboCop
|
|
190
190
|
def expect_no_offenses(source, file = nil)
|
191
191
|
offenses = inspect_source(source, file)
|
192
192
|
|
193
|
-
|
193
|
+
# Since source given `expect_no_offenses` does not have annotations, we do not need to parse
|
194
|
+
# for them, and can just build an `AnnotatedSource` object from the source lines.
|
195
|
+
# This also prevents treating source lines that begin with a caret as an annotation.
|
196
|
+
expected_annotations = AnnotatedSource.new(source.each_line.to_a, [])
|
194
197
|
actual_annotations = expected_annotations.with_offense_annotations(offenses)
|
195
198
|
expect(actual_annotations.to_s).to eq(source)
|
196
199
|
end
|
@@ -221,7 +224,8 @@ module RuboCop
|
|
221
224
|
|
222
225
|
# Parsed representation of code annotated with the `^^^ Message` style
|
223
226
|
class AnnotatedSource
|
224
|
-
|
227
|
+
# Ignore escaped carets, don't treat as annotations
|
228
|
+
ANNOTATION_PATTERN = /\A\s*((?<!\\)\^+|\^{}) ?/.freeze
|
225
229
|
ABBREV = "[...]\n"
|
226
230
|
|
227
231
|
# @param annotated_source [String] string passed to the matchers
|
@@ -127,6 +127,7 @@ module RuboCop
|
|
127
127
|
if mode == :only_recognized_file_types || force_exclusion?
|
128
128
|
files.select! { |file| included_file?(file) }
|
129
129
|
end
|
130
|
+
files.reject! { |file| FileTest.directory?(file) }
|
130
131
|
|
131
132
|
force_exclusion? ? without_excluded(files) : files
|
132
133
|
end
|
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
@@ -100,6 +100,7 @@ require_relative 'rubocop/cop/mixin/frozen_string_literal'
|
|
100
100
|
require_relative 'rubocop/cop/mixin/gem_declaration'
|
101
101
|
require_relative 'rubocop/cop/mixin/gemspec_help'
|
102
102
|
require_relative 'rubocop/cop/mixin/hash_alignment_styles'
|
103
|
+
require_relative 'rubocop/cop/mixin/hash_subset'
|
103
104
|
require_relative 'rubocop/cop/mixin/hash_transform_method'
|
104
105
|
require_relative 'rubocop/cop/mixin/integer_node'
|
105
106
|
require_relative 'rubocop/cop/mixin/interpolation'
|
@@ -293,6 +294,7 @@ require_relative 'rubocop/cop/lint/ambiguous_operator'
|
|
293
294
|
require_relative 'rubocop/cop/lint/ambiguous_operator_precedence'
|
294
295
|
require_relative 'rubocop/cop/lint/ambiguous_range'
|
295
296
|
require_relative 'rubocop/cop/lint/ambiguous_regexp_literal'
|
297
|
+
require_relative 'rubocop/cop/lint/array_literal_in_regexp'
|
296
298
|
require_relative 'rubocop/cop/lint/assignment_in_condition'
|
297
299
|
require_relative 'rubocop/cop/lint/big_decimal_new'
|
298
300
|
require_relative 'rubocop/cop/lint/binary_operator_with_identical_operands'
|
@@ -559,6 +561,7 @@ require_relative 'rubocop/cop/style/hash_conversion'
|
|
559
561
|
require_relative 'rubocop/cop/style/hash_each_methods'
|
560
562
|
require_relative 'rubocop/cop/style/hash_except'
|
561
563
|
require_relative 'rubocop/cop/style/hash_like_case'
|
564
|
+
require_relative 'rubocop/cop/style/hash_slice'
|
562
565
|
require_relative 'rubocop/cop/style/hash_syntax'
|
563
566
|
require_relative 'rubocop/cop/style/hash_transform_keys'
|
564
567
|
require_relative 'rubocop/cop/style/hash_transform_values'
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.71.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
8
8
|
- Jonas Arvidsson
|
9
9
|
- Yuji Nakayama
|
10
|
-
autorequire:
|
11
10
|
bindir: exe
|
12
11
|
cert_chain: []
|
13
|
-
date: 2025-01-
|
12
|
+
date: 2025-01-22 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: json
|
@@ -283,6 +282,7 @@ files:
|
|
283
282
|
- lib/rubocop/cop/internal_affairs/node_type_predicate.rb
|
284
283
|
- lib/rubocop/cop/internal_affairs/numblock_handler.rb
|
285
284
|
- lib/rubocop/cop/internal_affairs/offense_location_keyword.rb
|
285
|
+
- lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb
|
286
286
|
- lib/rubocop/cop/internal_affairs/operator_keyword.rb
|
287
287
|
- lib/rubocop/cop/internal_affairs/processed_source_buffer_name.rb
|
288
288
|
- lib/rubocop/cop/internal_affairs/redundant_context_config_parameter.rb
|
@@ -405,6 +405,7 @@ files:
|
|
405
405
|
- lib/rubocop/cop/lint/ambiguous_operator_precedence.rb
|
406
406
|
- lib/rubocop/cop/lint/ambiguous_range.rb
|
407
407
|
- lib/rubocop/cop/lint/ambiguous_regexp_literal.rb
|
408
|
+
- lib/rubocop/cop/lint/array_literal_in_regexp.rb
|
408
409
|
- lib/rubocop/cop/lint/assignment_in_condition.rb
|
409
410
|
- lib/rubocop/cop/lint/big_decimal_new.rb
|
410
411
|
- lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb
|
@@ -595,6 +596,7 @@ files:
|
|
595
596
|
- lib/rubocop/cop/mixin/gemspec_help.rb
|
596
597
|
- lib/rubocop/cop/mixin/hash_alignment_styles.rb
|
597
598
|
- lib/rubocop/cop/mixin/hash_shorthand_syntax.rb
|
599
|
+
- lib/rubocop/cop/mixin/hash_subset.rb
|
598
600
|
- lib/rubocop/cop/mixin/hash_transform_method.rb
|
599
601
|
- lib/rubocop/cop/mixin/heredoc.rb
|
600
602
|
- lib/rubocop/cop/mixin/integer_node.rb
|
@@ -757,6 +759,7 @@ files:
|
|
757
759
|
- lib/rubocop/cop/style/hash_each_methods.rb
|
758
760
|
- lib/rubocop/cop/style/hash_except.rb
|
759
761
|
- lib/rubocop/cop/style/hash_like_case.rb
|
762
|
+
- lib/rubocop/cop/style/hash_slice.rb
|
760
763
|
- lib/rubocop/cop/style/hash_syntax.rb
|
761
764
|
- lib/rubocop/cop/style/hash_transform_keys.rb
|
762
765
|
- lib/rubocop/cop/style/hash_transform_values.rb
|
@@ -1043,12 +1046,11 @@ licenses:
|
|
1043
1046
|
- MIT
|
1044
1047
|
metadata:
|
1045
1048
|
homepage_uri: https://rubocop.org/
|
1046
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.
|
1049
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.71.0
|
1047
1050
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1048
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
1051
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.71/
|
1049
1052
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1050
1053
|
rubygems_mfa_required: 'true'
|
1051
|
-
post_install_message:
|
1052
1054
|
rdoc_options: []
|
1053
1055
|
require_paths:
|
1054
1056
|
- lib
|
@@ -1063,8 +1065,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1063
1065
|
- !ruby/object:Gem::Version
|
1064
1066
|
version: '0'
|
1065
1067
|
requirements: []
|
1066
|
-
rubygems_version: 3.
|
1067
|
-
signing_key:
|
1068
|
+
rubygems_version: 3.6.2
|
1068
1069
|
specification_version: 4
|
1069
1070
|
summary: Automatic Ruby code style checking tool.
|
1070
1071
|
test_files: []
|