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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb25d50ecbd2f942993d245b3302d53cf3605fa362e0addf1ee088caaa22bfff
4
- data.tar.gz: 62df82b33ce3ae669b7fd23ca69f1a53f9dbbcd480d44cfff763df3c84c39585
3
+ metadata.gz: 39e28428d694fdd8cf940d5e3494f62a0266b3ffd41e823cf50131d16b45cf2a
4
+ data.tar.gz: 75eadde7a899742fcb5f08c4b3cd845658dd64087dd80c0dad1bda5fef30804a
5
5
  SHA512:
6
- metadata.gz: 563e301ae73973fd6ccb3679ce82fe15a02d6634c7993bfab9f0c15ae29687982ac63ec07f656be22273e6b5c63cd2686b678cdc3319536b51d086103ec60fcd
7
- data.tar.gz: eb24bb4636f91c76715a81896852d6620306ac45e52755cc5c2148ff0f85d1012ebe7b043076a802259bf1d130fc4296d55b70f4d99816aba39056fa05205b16
6
+ metadata.gz: 21bba5ce4024ff5c66695c56e4261fbefdedc8b293396b8d0687f836d4a56d0f53ae307435cb714a3e4b059def785a1d9862504910f94fe1815223b6036b727b
7
+ data.tar.gz: aec136f1e174b57ba2ae6307a3fdeda0257614bcaaf77a6d5c5eca9733cfd185970dd998ecc95a6691d9aa8310419cd69679ba9b021f5b8284b9d12ef675dcc0
data/config/default.yml CHANGED
@@ -1659,6 +1659,7 @@ Lint/Debugger:
1659
1659
  - Kernel.binding.remote_pry
1660
1660
  - Kernel.binding.pry_remote
1661
1661
  - Pry.rescue
1662
+ - pry
1662
1663
  Rails:
1663
1664
  - debugger
1664
1665
  - Kernel.debugger
@@ -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, the other checks can be skipped.
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'] }
@@ -94,7 +94,7 @@ module RuboCop
94
94
  private
95
95
 
96
96
  def allowed_gem?(node)
97
- allowed_gems.include?(node.first_argument.value)
97
+ allowed_gems.include?(node.first_argument.str_content)
98
98
  end
99
99
 
100
100
  def allowed_gems
@@ -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
- register_offense(node)
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
- offense_range = offense_range(node)
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
- Parser::Source::Range.new(
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
@@ -33,6 +33,10 @@ module RuboCop
33
33
  message << '.' unless message.end_with?('.')
34
34
  message
35
35
  end
36
+
37
+ def find_severity(_range, _severity)
38
+ :fatal
39
+ end
36
40
  end
37
41
  end
38
42
  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
- return false if body.nil? || !body.send_type? || !body.method?(:raise)
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
- # - '\A\s*onSelectionBulkChange\s*'
14
- # - '\A\s*onSelectionCleared\s*'
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? && sibling_accessors(send_node).size > 1) ||
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 sibling_accessors(send_node)
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 = sibling_accessors(node)
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)
@@ -25,4 +25,5 @@ RSpec.configure do |config|
25
25
  config.include_context 'ruby 3.0', :ruby30
26
26
  config.include_context 'ruby 3.1', :ruby31
27
27
  config.include_context 'ruby 3.2', :ruby32
28
+ config.include_context 'ruby 3.3', :ruby33
28
29
  end
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.48.0'
6
+ STRING = '1.48.1'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, ' \
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
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.0
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-06 00:00:00.000000000 Z
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.3.7
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: []