rubocop 1.18.2 → 1.18.3
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 -1
- data/lib/rubocop/config_loader_resolver.rb +1 -1
- data/lib/rubocop/cop/layout/hash_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +3 -8
- data/lib/rubocop/cop/layout/space_around_operators.rb +4 -0
- data/lib/rubocop/cop/lint/useless_times.rb +1 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +15 -0
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +8 -2
- data/lib/rubocop/cop/style/hash_syntax.rb +1 -1
- data/lib/rubocop/cop/style/single_line_methods.rb +11 -6
- 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: b6123e3d35feebac08e838afcff3f912fa24f7abcc71403f6368fffb346fa9bc
|
4
|
+
data.tar.gz: 40f3ff08e0efc288e7a11af7016d702f743b8ab343de0c3fd045035c7ac7605f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ac2d860eccd7ac0d655649d36f64cf52ed1587357b2ef35707a1c2ced408cf645d1a8be2dd6e660c5e338c298adef876814fdf35b22f5c71da4ec5bc830e388
|
7
|
+
data.tar.gz: adab3ee6563260ced11848bc9b1c62ff2641a28a6b4aca80cb703ef9136562bbdc6a2efff4670d12dee329cc7cf5306a8c9d11106ff13d9cbf5539b5094ba388
|
data/config/default.yml
CHANGED
@@ -1809,7 +1809,7 @@ Lint/MissingCopEnableDirective:
|
|
1809
1809
|
Lint/MissingSuper:
|
1810
1810
|
Description: >-
|
1811
1811
|
This cop checks for the presence of constructors and lifecycle callbacks
|
1812
|
-
without calls to `super
|
1812
|
+
without calls to `super`.
|
1813
1813
|
Enabled: true
|
1814
1814
|
VersionAdded: '0.89'
|
1815
1815
|
VersionChanged: '1.4'
|
@@ -23,7 +23,7 @@ module RuboCop
|
|
23
23
|
def resolve_inheritance(path, hash, file, debug) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
24
24
|
inherited_files = Array(hash['inherit_from'])
|
25
25
|
base_configs(path, inherited_files, file)
|
26
|
-
.
|
26
|
+
.each_with_index.reverse_each do |base_config, index|
|
27
27
|
override_department_setting_for_cops(base_config, hash)
|
28
28
|
override_enabled_for_disabled_departments(base_config, hash)
|
29
29
|
|
@@ -220,7 +220,7 @@ module RuboCop
|
|
220
220
|
def autocorrect_incompatible_with_other_cops?(node)
|
221
221
|
enforce_first_argument_with_fixed_indentation? &&
|
222
222
|
node.pairs.any? &&
|
223
|
-
node.parent&.call_type? && node.parent.loc.selector
|
223
|
+
node.parent&.call_type? && node.parent.loc.selector&.line == node.pairs.first.loc.line
|
224
224
|
end
|
225
225
|
|
226
226
|
def reset!
|
@@ -85,14 +85,9 @@ module RuboCop
|
|
85
85
|
private
|
86
86
|
|
87
87
|
def strings_concatenated_with_backslash?(dstr_node)
|
88
|
-
|
89
|
-
|
90
|
-
dstr_node.children.
|
91
|
-
dstr_node.children.all? { |c| c.str_type? || c.dstr_type? }
|
92
|
-
end
|
93
|
-
|
94
|
-
def single_string_literal?(dstr_node)
|
95
|
-
dstr_node.loc.respond_to?(:begin) && dstr_node.loc.begin
|
88
|
+
dstr_node.multiline? &&
|
89
|
+
dstr_node.children.all? { |c| c.str_type? || c.dstr_type? } &&
|
90
|
+
dstr_node.children.none?(&:multiline?)
|
96
91
|
end
|
97
92
|
|
98
93
|
def always_indented?(dstr_node)
|
@@ -81,7 +81,7 @@ module RuboCop
|
|
81
81
|
return if block_reassigns_arg?(node, block_arg)
|
82
82
|
|
83
83
|
source = node.body.source
|
84
|
-
source.gsub!(/\b#{block_arg}\b/, '
|
84
|
+
source.gsub!(/\b#{block_arg}\b/, '0') if block_arg
|
85
85
|
|
86
86
|
corrector.replace(node, fix_indentation(source, node.loc.column...node.body.loc.column))
|
87
87
|
end
|
@@ -135,6 +135,7 @@ module RuboCop
|
|
135
135
|
class BlockDelimiters < Base
|
136
136
|
include ConfigurableEnforcedStyle
|
137
137
|
include IgnoredMethods
|
138
|
+
include RangeHelp
|
138
139
|
extend AutoCorrector
|
139
140
|
|
140
141
|
ALWAYS_BRACES_MESSAGE = 'Prefer `{...}` over `do...end` for blocks.'
|
@@ -231,6 +232,11 @@ module RuboCop
|
|
231
232
|
corrector.insert_before(e, ' ') unless whitespace_before?(e)
|
232
233
|
corrector.insert_after(b, ' ') unless whitespace_after?(b)
|
233
234
|
corrector.replace(b, 'do')
|
235
|
+
|
236
|
+
if (comment = processed_source.comment_at_line(e.line))
|
237
|
+
move_comment_before_block(corrector, comment, loc.node, e)
|
238
|
+
end
|
239
|
+
|
234
240
|
corrector.replace(e, 'end')
|
235
241
|
end
|
236
242
|
|
@@ -252,6 +258,15 @@ module RuboCop
|
|
252
258
|
/\s/.match?(range.source_buffer.source[range.begin_pos + length, 1])
|
253
259
|
end
|
254
260
|
|
261
|
+
def move_comment_before_block(corrector, comment, block_node, closing_brace)
|
262
|
+
range = range_between(closing_brace.end_pos, comment.loc.expression.end_pos)
|
263
|
+
|
264
|
+
corrector.remove(range_with_surrounding_space(range: range, side: :right))
|
265
|
+
corrector.insert_after(closing_brace, "\n")
|
266
|
+
|
267
|
+
corrector.insert_before(block_node, "#{comment.text}\n")
|
268
|
+
end
|
269
|
+
|
255
270
|
def get_blocks(node, &block)
|
256
271
|
case node.type
|
257
272
|
when :block
|
@@ -5,11 +5,17 @@ module RuboCop
|
|
5
5
|
module Style
|
6
6
|
# This cop is designed to help you transition from mutable string literals
|
7
7
|
# to frozen string literals.
|
8
|
-
# It will add the
|
9
|
-
# files to enable frozen string literals. Frozen string literals may be
|
8
|
+
# It will add the `# frozen_string_literal: true` magic comment to the top
|
9
|
+
# of files to enable frozen string literals. Frozen string literals may be
|
10
10
|
# default in future Ruby. The comment will be added below a shebang and
|
11
11
|
# encoding comment.
|
12
12
|
#
|
13
|
+
# Note that the cop will ignore files where the comment exists but is set
|
14
|
+
# to `false` instead of `true`.
|
15
|
+
#
|
16
|
+
# To require a blank line after this comment, please see
|
17
|
+
# `Layout/EmptyLineAfterMagicComment` cop.
|
18
|
+
#
|
13
19
|
# @example EnforcedStyle: always (default)
|
14
20
|
# # The `always` style will always add the frozen string literal comment
|
15
21
|
# # to a file, regardless of the Ruby version or if `freeze` or `<<` are
|
@@ -36,6 +36,7 @@ module RuboCop
|
|
36
36
|
extend AutoCorrector
|
37
37
|
|
38
38
|
MSG = 'Avoid single-line method definitions.'
|
39
|
+
NOT_SUPPORTED_ENDLESS_METHOD_BODY_TYPES = %i[return break next].freeze
|
39
40
|
|
40
41
|
def on_def(node)
|
41
42
|
return unless node.single_line?
|
@@ -62,13 +63,10 @@ module RuboCop
|
|
62
63
|
|
63
64
|
def correct_to_endless?(body_node)
|
64
65
|
return false if target_ruby_version < 3.0
|
65
|
-
|
66
|
-
endless_method_config = config.for_cop('Style/EndlessMethod')
|
67
|
-
|
68
|
-
return false unless endless_method_config['Enabled']
|
69
|
-
return false if endless_method_config['EnforcedStyle'] == 'disallow'
|
66
|
+
return false if disallow_endless_method_style?
|
70
67
|
return false unless body_node
|
71
|
-
return false if body_node.parent.assignment_method?
|
68
|
+
return false if body_node.parent.assignment_method? ||
|
69
|
+
NOT_SUPPORTED_ENDLESS_METHOD_BODY_TYPES.include?(body_node.type)
|
72
70
|
|
73
71
|
!(body_node.begin_type? || body_node.kwbegin_type?)
|
74
72
|
end
|
@@ -129,6 +127,13 @@ module RuboCop
|
|
129
127
|
def require_parentheses?(method_body)
|
130
128
|
method_body.send_type? && !method_body.arguments.empty? && !method_body.comparison_method?
|
131
129
|
end
|
130
|
+
|
131
|
+
def disallow_endless_method_style?
|
132
|
+
endless_method_config = config.for_cop('Style/EndlessMethod')
|
133
|
+
return false unless endless_method_config['Enabled']
|
134
|
+
|
135
|
+
endless_method_config['EnforcedStyle'] == 'disallow'
|
136
|
+
end
|
132
137
|
end
|
133
138
|
end
|
134
139
|
end
|
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.18.
|
4
|
+
version: 1.18.3
|
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: 2021-07-
|
13
|
+
date: 2021-07-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parallel
|
@@ -885,7 +885,7 @@ metadata:
|
|
885
885
|
source_code_uri: https://github.com/rubocop/rubocop/
|
886
886
|
documentation_uri: https://docs.rubocop.org/rubocop/1.18/
|
887
887
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
888
|
-
post_install_message:
|
888
|
+
post_install_message:
|
889
889
|
rdoc_options: []
|
890
890
|
require_paths:
|
891
891
|
- lib
|
@@ -900,8 +900,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
900
900
|
- !ruby/object:Gem::Version
|
901
901
|
version: '0'
|
902
902
|
requirements: []
|
903
|
-
rubygems_version: 3.2
|
904
|
-
signing_key:
|
903
|
+
rubygems_version: 3.1.2
|
904
|
+
signing_key:
|
905
905
|
specification_version: 4
|
906
906
|
summary: Automatic Ruby code style checking tool.
|
907
907
|
test_files: []
|