rubocop 1.75.3 → 1.75.8
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/config/default.yml +2 -0
- data/lib/rubocop/cop/autocorrect_logic.rb +18 -10
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +49 -5
- data/lib/rubocop/cop/layout/class_structure.rb +35 -0
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +6 -2
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/hash_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/leading_comment_space.rb +13 -1
- data/lib/rubocop/cop/layout/space_after_semicolon.rb +10 -0
- data/lib/rubocop/cop/layout/space_before_brackets.rb +6 -32
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +5 -1
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +3 -0
- data/lib/rubocop/cop/lint/array_literal_in_regexp.rb +2 -3
- data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -1
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +2 -5
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_methods.rb +84 -2
- data/lib/rubocop/cop/lint/float_comparison.rb +27 -0
- data/lib/rubocop/cop/lint/literal_as_condition.rb +25 -11
- data/lib/rubocop/cop/lint/useless_assignment.rb +2 -0
- data/lib/rubocop/cop/lint/void.rb +2 -2
- data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
- data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +15 -14
- data/lib/rubocop/cop/mixin/trailing_comma.rb +6 -2
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +32 -10
- data/lib/rubocop/cop/style/arguments_forwarding.rb +4 -1
- data/lib/rubocop/cop/style/class_and_module_children.rb +12 -2
- data/lib/rubocop/cop/style/command_literal.rb +1 -1
- data/lib/rubocop/cop/style/comparable_between.rb +5 -2
- data/lib/rubocop/cop/style/data_inheritance.rb +7 -0
- data/lib/rubocop/cop/style/def_with_parentheses.rb +18 -5
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +3 -3
- data/lib/rubocop/cop/style/if_unless_modifier.rb +20 -0
- data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +4 -7
- data/lib/rubocop/cop/style/map_to_hash.rb +11 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +3 -0
- data/lib/rubocop/cop/style/multiline_if_modifier.rb +2 -0
- data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
- data/lib/rubocop/cop/style/redundant_format.rb +6 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +11 -3
- data/lib/rubocop/cop/style/regexp_literal.rb +1 -1
- data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +4 -2
- data/lib/rubocop/cop/style/string_concatenation.rb +1 -2
- data/lib/rubocop/cop/style/struct_inheritance.rb +8 -1
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +7 -1
- data/lib/rubocop/cop/team.rb +1 -1
- data/lib/rubocop/cop/variable_force/assignment.rb +7 -3
- data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -0
- data/lib/rubocop/formatter/html_formatter.rb +1 -1
- data/lib/rubocop/rspec/cop_helper.rb +2 -2
- data/lib/rubocop/rspec/shared_contexts.rb +1 -2
- data/lib/rubocop/version.rb +1 -1
- metadata +3 -3
@@ -3,7 +3,8 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Style
|
6
|
-
# Checks for inheritance from Struct.new.
|
6
|
+
# Checks for inheritance from `Struct.new`. Inheriting from `Struct.new`
|
7
|
+
# adds a superfluous level in inheritance tree.
|
7
8
|
#
|
8
9
|
# @safety
|
9
10
|
# Autocorrection is unsafe because it will change the inheritance
|
@@ -17,12 +18,18 @@ module RuboCop
|
|
17
18
|
# end
|
18
19
|
# end
|
19
20
|
#
|
21
|
+
# Person.ancestors
|
22
|
+
# # => [Person, #<Class:0x000000010b4e14a0>, Struct, (...)]
|
23
|
+
#
|
20
24
|
# # good
|
21
25
|
# Person = Struct.new(:first_name, :last_name) do
|
22
26
|
# def age
|
23
27
|
# 42
|
24
28
|
# end
|
25
29
|
# end
|
30
|
+
#
|
31
|
+
# Person.ancestors
|
32
|
+
# # => [Person, Struct, (...)]
|
26
33
|
class StructInheritance < Base
|
27
34
|
include RangeHelp
|
28
35
|
extend AutoCorrector
|
@@ -79,10 +79,16 @@ module RuboCop
|
|
79
79
|
# # bad
|
80
80
|
# method(1, 2,)
|
81
81
|
#
|
82
|
+
# # bad
|
83
|
+
# object[1, 2,]
|
84
|
+
#
|
82
85
|
# # good
|
83
86
|
# method(1, 2)
|
84
87
|
#
|
85
88
|
# # good
|
89
|
+
# object[1, 2]
|
90
|
+
#
|
91
|
+
# # good
|
86
92
|
# method(
|
87
93
|
# 1,
|
88
94
|
# 2
|
@@ -96,7 +102,7 @@ module RuboCop
|
|
96
102
|
end
|
97
103
|
|
98
104
|
def on_send(node)
|
99
|
-
return unless node.arguments? && node.parenthesized?
|
105
|
+
return unless node.arguments? && (node.parenthesized? || node.method?(:[]))
|
100
106
|
|
101
107
|
check(node, node.arguments, 'parameter of %<article>s method call',
|
102
108
|
node.last_argument.source_range.end_pos,
|
data/lib/rubocop/cop/team.rb
CHANGED
@@ -110,8 +110,13 @@ module RuboCop
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def multiple_assignment_node
|
113
|
-
return nil unless node.parent
|
114
|
-
|
113
|
+
return nil unless (candidate_mlhs_node = node.parent)
|
114
|
+
|
115
|
+
# In `(foo, bar), *baz`, the splat node must be traversed as well.
|
116
|
+
candidate_mlhs_node = candidate_mlhs_node.parent if candidate_mlhs_node.splat_type?
|
117
|
+
|
118
|
+
return nil unless candidate_mlhs_node.mlhs_type?
|
119
|
+
return nil unless (grandparent_node = node.parent.parent)
|
115
120
|
if (node = find_multiple_assignment_node(grandparent_node))
|
116
121
|
return node
|
117
122
|
end
|
@@ -139,7 +144,6 @@ module RuboCop
|
|
139
144
|
|
140
145
|
def find_multiple_assignment_node(grandparent_node)
|
141
146
|
return unless grandparent_node.type == MULTIPLE_LEFT_HAND_SIDE_TYPE
|
142
|
-
return if grandparent_node.children.any?(&:splat_type?)
|
143
147
|
|
144
148
|
parent = grandparent_node.parent
|
145
149
|
return parent if parent.type == MULTIPLE_ASSIGNMENT_TYPE
|
@@ -11,8 +11,8 @@ module CopHelper
|
|
11
11
|
ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : RuboCop::TargetRuby::DEFAULT_VERSION
|
12
12
|
end
|
13
13
|
let(:parser_engine) do
|
14
|
-
# The maximum version Parser can parse is 3.
|
15
|
-
ruby_version >= 3.
|
14
|
+
# The maximum version Parser can correctly parse is 3.3.
|
15
|
+
ruby_version >= 3.4 ? :parser_prism : ENV.fetch('PARSER_ENGINE', :parser_whitequark).to_sym
|
16
16
|
end
|
17
17
|
let(:rails_version) { false }
|
18
18
|
|
data/lib/rubocop/version.rb
CHANGED
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.75.
|
4
|
+
version: 1.75.8
|
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-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -1080,7 +1080,7 @@ licenses:
|
|
1080
1080
|
- MIT
|
1081
1081
|
metadata:
|
1082
1082
|
homepage_uri: https://rubocop.org/
|
1083
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.75.
|
1083
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.75.8
|
1084
1084
|
source_code_uri: https://github.com/rubocop/rubocop/
|
1085
1085
|
documentation_uri: https://docs.rubocop.org/rubocop/1.75/
|
1086
1086
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|