rubocop 1.48.0 → 1.48.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +1 -0
- data/lib/rubocop/config.rb +2 -2
- data/lib/rubocop/cop/gemspec/dependency_version.rb +1 -1
- data/lib/rubocop/cop/layout/block_end_newline.rb +7 -21
- data/lib/rubocop/cop/lint/syntax.rb +4 -0
- data/lib/rubocop/cop/lint/useless_rescue.rb +4 -1
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +1 -0
- data/lib/rubocop/cop/naming/method_name.rb +2 -2
- data/lib/rubocop/cop/style/accessor_grouping.rb +4 -4
- data/lib/rubocop/rspec/support.rb +1 -0
- data/lib/rubocop/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39e28428d694fdd8cf940d5e3494f62a0266b3ffd41e823cf50131d16b45cf2a
|
4
|
+
data.tar.gz: 75eadde7a899742fcb5f08c4b3cd845658dd64087dd80c0dad1bda5fef30804a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21bba5ce4024ff5c66695c56e4261fbefdedc8b293396b8d0687f836d4a56d0f53ae307435cb714a3e4b059def785a1d9862504910f94fe1815223b6036b727b
|
7
|
+
data.tar.gz: aec136f1e174b57ba2ae6307a3fdeda0257614bcaaf77a6d5c5eca9733cfd185970dd998ecc95a6691d9aa8310419cd69679ba9b021f5b8284b9d12ef675dcc0
|
data/config/default.yml
CHANGED
data/lib/rubocop/config.rb
CHANGED
@@ -304,8 +304,8 @@ module RuboCop
|
|
304
304
|
end
|
305
305
|
|
306
306
|
def enable_cop?(qualified_cop_name, cop_options)
|
307
|
-
# If the cop is explicitly enabled
|
308
|
-
return true if cop_options['Enabled'] == true
|
307
|
+
# If the cop is explicitly enabled or `Lint/Syntax`, the other checks can be skipped.
|
308
|
+
return true if cop_options['Enabled'] == true || qualified_cop_name == 'Lint/Syntax'
|
309
309
|
|
310
310
|
department = department_of(qualified_cop_name)
|
311
311
|
cop_enabled = cop_options.fetch('Enabled') { !for_all_cops['DisabledByDefault'] }
|
@@ -36,17 +36,19 @@ module RuboCop
|
|
36
36
|
# If the end is on its own line, there is no offense
|
37
37
|
return if begins_its_line?(node.loc.end)
|
38
38
|
|
39
|
-
|
39
|
+
offense_range = offense_range(node)
|
40
|
+
return if offense_range.source.lstrip.start_with?(';')
|
41
|
+
|
42
|
+
register_offense(node, offense_range)
|
40
43
|
end
|
41
44
|
|
42
45
|
alias on_numblock on_block
|
43
46
|
|
44
47
|
private
|
45
48
|
|
46
|
-
def register_offense(node)
|
49
|
+
def register_offense(node, offense_range)
|
47
50
|
add_offense(node.loc.end, message: message(node)) do |corrector|
|
48
|
-
|
49
|
-
replacement = replacement(node)
|
51
|
+
replacement = "\n#{offense_range.source.lstrip}"
|
50
52
|
|
51
53
|
if (heredoc = last_heredoc_argument(node.body))
|
52
54
|
corrector.remove(offense_range)
|
@@ -72,23 +74,7 @@ module RuboCop
|
|
72
74
|
end
|
73
75
|
|
74
76
|
def offense_range(node)
|
75
|
-
|
76
|
-
node.source_range.source_buffer,
|
77
|
-
node.children.compact.last.source_range.end_pos,
|
78
|
-
end_of_method_chain(node).source_range.end_pos
|
79
|
-
)
|
80
|
-
end
|
81
|
-
|
82
|
-
def replacement(node)
|
83
|
-
end_with_method_chain = node.loc.end.join(end_of_method_chain(node).source_range.end)
|
84
|
-
|
85
|
-
"\n#{end_with_method_chain.source.strip}"
|
86
|
-
end
|
87
|
-
|
88
|
-
def end_of_method_chain(node)
|
89
|
-
return node unless node.parent&.call_type?
|
90
|
-
|
91
|
-
end_of_method_chain(node.parent)
|
77
|
+
node.children.compact.last.source_range.end.join(node.loc.end)
|
92
78
|
end
|
93
79
|
end
|
94
80
|
end
|
@@ -56,11 +56,13 @@ module RuboCop
|
|
56
56
|
|
57
57
|
private
|
58
58
|
|
59
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
59
60
|
def only_reraising?(resbody_node)
|
60
61
|
return false if use_exception_variable_in_ensure?(resbody_node)
|
61
62
|
|
62
63
|
body = resbody_node.body
|
63
|
-
|
64
|
+
|
65
|
+
return false if body.nil? || !body.send_type? || !body.method?(:raise) || body.receiver
|
64
66
|
return true unless body.arguments?
|
65
67
|
return false if body.arguments.size > 1
|
66
68
|
|
@@ -68,6 +70,7 @@ module RuboCop
|
|
68
70
|
|
69
71
|
exception_objects(resbody_node).include?(exception_name)
|
70
72
|
end
|
73
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
71
74
|
|
72
75
|
def use_exception_variable_in_ensure?(resbody_node)
|
73
76
|
return false unless (exception_variable = resbody_node.exception_variable)
|
@@ -100,6 +100,7 @@ module RuboCop
|
|
100
100
|
last_pair = node.parent.pairs.last
|
101
101
|
return unless last_pair.key.source == last_pair.value.source
|
102
102
|
return unless (dispatch_node = find_ancestor_method_dispatch_node(node))
|
103
|
+
return if dispatch_node.assignment_method?
|
103
104
|
return if dispatch_node.parenthesized?
|
104
105
|
return if dispatch_node.parent && parentheses?(dispatch_node.parent)
|
105
106
|
return if last_expression?(dispatch_node) && !method_dispatch_as_argument?(dispatch_node)
|
@@ -10,8 +10,8 @@ module RuboCop
|
|
10
10
|
#
|
11
11
|
# Naming/MethodName:
|
12
12
|
# AllowedPatterns:
|
13
|
-
# - '\
|
14
|
-
# - '\
|
13
|
+
# - '\AonSelectionBulkChange\z'
|
14
|
+
# - '\AonSelectionCleared\z'
|
15
15
|
#
|
16
16
|
# Method names matching patterns are always allowed.
|
17
17
|
#
|
@@ -70,7 +70,7 @@ module RuboCop
|
|
70
70
|
|
71
71
|
def check(send_node)
|
72
72
|
return if previous_line_comment?(send_node) || !groupable_accessor?(send_node)
|
73
|
-
return unless (grouped_style? &&
|
73
|
+
return unless (grouped_style? && groupable_sibling_accessors(send_node).size > 1) ||
|
74
74
|
(separated_style? && send_node.arguments.size > 1)
|
75
75
|
|
76
76
|
message = message(send_node)
|
@@ -127,12 +127,12 @@ module RuboCop
|
|
127
127
|
style == :separated
|
128
128
|
end
|
129
129
|
|
130
|
-
def
|
130
|
+
def groupable_sibling_accessors(send_node)
|
131
131
|
send_node.parent.each_child_node(:send).select do |sibling|
|
132
132
|
sibling.attribute_accessor? &&
|
133
133
|
sibling.method?(send_node.method_name) &&
|
134
134
|
node_visibility(sibling) == node_visibility(send_node) &&
|
135
|
-
!previous_line_comment?(sibling)
|
135
|
+
groupable_accessor?(sibling) && !previous_line_comment?(sibling)
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -143,7 +143,7 @@ module RuboCop
|
|
143
143
|
|
144
144
|
def preferred_accessors(node)
|
145
145
|
if grouped_style?
|
146
|
-
accessors =
|
146
|
+
accessors = groupable_sibling_accessors(node)
|
147
147
|
group_accessors(node, accessors) if node.loc == accessors.first.loc
|
148
148
|
else
|
149
149
|
separate_accessors(node)
|
data/lib/rubocop/version.rb
CHANGED
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.48.
|
4
|
+
version: 1.48.1
|
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: 2023-03-
|
13
|
+
date: 2023-03-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -991,7 +991,7 @@ metadata:
|
|
991
991
|
documentation_uri: https://docs.rubocop.org/rubocop/1.48/
|
992
992
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
993
993
|
rubygems_mfa_required: 'true'
|
994
|
-
post_install_message:
|
994
|
+
post_install_message:
|
995
995
|
rdoc_options: []
|
996
996
|
require_paths:
|
997
997
|
- lib
|
@@ -1006,8 +1006,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1006
1006
|
- !ruby/object:Gem::Version
|
1007
1007
|
version: '0'
|
1008
1008
|
requirements: []
|
1009
|
-
rubygems_version: 3.
|
1010
|
-
signing_key:
|
1009
|
+
rubygems_version: 3.1.2
|
1010
|
+
signing_key:
|
1011
1011
|
specification_version: 4
|
1012
1012
|
summary: Automatic Ruby code style checking tool.
|
1013
1013
|
test_files: []
|