rubocop 1.87.0 → 1.88.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/config/default.yml +75 -71
- data/config/obsoletion.yml +21 -1
- data/lib/rubocop/cli/command/auto_generate_config.rb +6 -0
- data/lib/rubocop/cop/base.rb +17 -2
- data/lib/rubocop/cop/bundler/gem_comment.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb +5 -3
- data/lib/rubocop/cop/layout/block_alignment.rb +41 -4
- data/lib/rubocop/cop/lint/ambiguous_assignment.rb +1 -11
- data/lib/rubocop/cop/lint/ambiguous_operator_precedence.rb +1 -10
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +1 -3
- data/lib/rubocop/cop/lint/debugger.rb +0 -1
- data/lib/rubocop/cop/lint/deprecated_constants.rb +1 -7
- data/lib/rubocop/cop/lint/empty_block.rb +3 -3
- data/lib/rubocop/cop/lint/ensure_return.rb +19 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +3 -1
- data/lib/rubocop/cop/lint/float_comparison.rb +1 -0
- data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -1
- data/lib/rubocop/cop/lint/interpolation_check.rb +18 -3
- data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
- data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +11 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +8 -11
- data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +4 -4
- data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +16 -0
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +1 -1
- data/lib/rubocop/cop/lint/number_conversion.rb +13 -4
- data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +3 -0
- data/lib/rubocop/cop/lint/ordered_magic_comments.rb +7 -7
- data/lib/rubocop/cop/lint/raise_exception.rb +1 -1
- data/lib/rubocop/cop/lint/rand_one.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +4 -1
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +4 -1
- data/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb +15 -4
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +14 -7
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +4 -0
- data/lib/rubocop/cop/lint/redundant_type_conversion.rb +7 -0
- data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_with_object.rb +5 -0
- data/lib/rubocop/cop/lint/refinement_import_methods.rb +8 -1
- data/lib/rubocop/cop/lint/regexp_as_condition.rb +9 -1
- data/lib/rubocop/cop/lint/require_parentheses.rb +13 -4
- data/lib/rubocop/cop/lint/require_range_parentheses.rb +2 -1
- data/lib/rubocop/cop/lint/require_relative_self_path.rb +5 -5
- data/lib/rubocop/cop/lint/rescue_type.rb +1 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -0
- data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -1
- data/lib/rubocop/cop/lint/script_permission.rb +5 -1
- data/lib/rubocop/cop/lint/self_assignment.rb +24 -1
- data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +1 -1
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +14 -0
- data/lib/rubocop/cop/lint/shared_mutable_default.rb +3 -1
- data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +12 -0
- data/lib/rubocop/cop/lint/symbol_conversion.rb +21 -4
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +28 -1
- data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
- data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +4 -1
- data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +3 -1
- data/lib/rubocop/cop/lint/useless_assignment.rb +10 -5
- data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +7 -3
- data/lib/rubocop/cop/lint/useless_setter_call.rb +4 -1
- data/lib/rubocop/cop/lint/useless_times.rb +22 -1
- data/lib/rubocop/cop/metrics/collection_literal_length.rb +1 -1
- data/lib/rubocop/cop/style/alias.rb +1 -1
- data/lib/rubocop/cop/style/and_or.rb +1 -1
- data/lib/rubocop/cop/style/array_first_last.rb +12 -1
- data/lib/rubocop/cop/style/array_intersect.rb +4 -0
- data/lib/rubocop/cop/style/array_intersect_with_single_element.rb +3 -0
- data/lib/rubocop/cop/style/block_delimiters.rb +16 -2
- data/lib/rubocop/cop/style/case_equality.rb +14 -2
- data/lib/rubocop/cop/style/class_equality_comparison.rb +21 -13
- data/lib/rubocop/cop/style/class_methods_definitions.rb +11 -5
- data/lib/rubocop/cop/style/colon_method_call.rb +13 -6
- data/lib/rubocop/cop/style/combinable_loops.rb +5 -0
- data/lib/rubocop/cop/style/comparable_clamp.rb +12 -1
- data/lib/rubocop/cop/style/concat_array_literals.rb +5 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +6 -1
- data/lib/rubocop/cop/style/constant_visibility.rb +4 -1
- data/lib/rubocop/cop/style/date_time.rb +2 -2
- data/lib/rubocop/cop/style/dig_chain.rb +5 -0
- data/lib/rubocop/cop/style/fetch_env_var.rb +1 -1
- data/lib/rubocop/cop/style/file_write.rb +17 -14
- data/lib/rubocop/cop/style/hash_slice.rb +16 -0
- data/lib/rubocop/cop/style/if_unless_modifier.rb +1 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +105 -11
- data/lib/rubocop/cop/style/parallel_assignment.rb +8 -1
- data/lib/rubocop/cop/style/redundant_format.rb +1 -0
- data/lib/rubocop/cop/style/semicolon.rb +16 -1
- data/lib/rubocop/cop/style/while_until_do.rb +7 -0
- data/lib/rubocop/cop/style/word_array.rb +1 -0
- data/lib/rubocop/cop/style/zero_length_predicate.rb +6 -3
- data/lib/rubocop/formatter/disabled_config_formatter.rb +14 -7
- data/lib/rubocop/server/core.rb +6 -0
- data/lib/rubocop/version.rb +1 -1
- metadata +3 -3
|
@@ -128,7 +128,7 @@ module RuboCop
|
|
|
128
128
|
|
|
129
129
|
add_offense(range) do |corrector|
|
|
130
130
|
if after_expression
|
|
131
|
-
corrector
|
|
131
|
+
replace_semicolon_with_line_break(corrector, range)
|
|
132
132
|
else
|
|
133
133
|
# Prevents becoming one range instance with subsequent line when endless range
|
|
134
134
|
# without parentheses.
|
|
@@ -148,6 +148,21 @@ module RuboCop
|
|
|
148
148
|
end
|
|
149
149
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
|
150
150
|
|
|
151
|
+
def replace_semicolon_with_line_break(corrector, range)
|
|
152
|
+
# Replacing the semicolon with a newline would move the rest of the
|
|
153
|
+
# line into the body of a heredoc opened earlier on that line.
|
|
154
|
+
return if heredoc_opened_before_semicolon?(range)
|
|
155
|
+
|
|
156
|
+
corrector.replace(range, "\n")
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def heredoc_opened_before_semicolon?(semicolon_range)
|
|
160
|
+
processed_source.ast.each_descendant(:any_str).select(&:heredoc?).any? do |heredoc|
|
|
161
|
+
heredoc.first_line == semicolon_range.line &&
|
|
162
|
+
heredoc.source_range.end_pos <= semicolon_range.begin_pos
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
151
166
|
def expressions_per_line(exprs)
|
|
152
167
|
# create a map matching lines to the number of expressions on them
|
|
153
168
|
exprs_lines = exprs.map(&:last_line)
|
|
@@ -33,6 +33,7 @@ module RuboCop
|
|
|
33
33
|
|
|
34
34
|
def on_while(node)
|
|
35
35
|
return unless node.multiline? && node.do?
|
|
36
|
+
return if same_line_body?(node)
|
|
36
37
|
|
|
37
38
|
add_offense(node.loc.begin, message: format(MSG, keyword: node.keyword)) do |corrector|
|
|
38
39
|
do_range = node.condition.source_range.end.join(node.loc.begin)
|
|
@@ -41,6 +42,12 @@ module RuboCop
|
|
|
41
42
|
end
|
|
42
43
|
end
|
|
43
44
|
alias on_until on_while
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def same_line_body?(node)
|
|
49
|
+
node.body && same_line?(node.loc.begin, node.body)
|
|
50
|
+
end
|
|
44
51
|
end
|
|
45
52
|
end
|
|
46
53
|
end
|
|
@@ -9,8 +9,10 @@ module RuboCop
|
|
|
9
9
|
# `receiver.length < 1` and `receiver.size == 0` that can be
|
|
10
10
|
# replaced by `receiver.empty?` and `!receiver.empty?`.
|
|
11
11
|
#
|
|
12
|
-
# NOTE: `File`, `Tempfile`, and `
|
|
13
|
-
# so allow `size == 0` and `size.zero?`.
|
|
12
|
+
# NOTE: `File`, `Tempfile`, `StringIO`, and `File::Stat` do not have `empty?`
|
|
13
|
+
# so allow `size == 0` and `size.zero?`. Note that when a `File::Stat` object
|
|
14
|
+
# is stored in a variable (e.g. `stat = File.stat(path); stat.size.zero?`),
|
|
15
|
+
# the cop cannot detect the type and may still register a false positive.
|
|
14
16
|
#
|
|
15
17
|
# @safety
|
|
16
18
|
# This cop is unsafe because it cannot be guaranteed that the receiver
|
|
@@ -146,7 +148,8 @@ module RuboCop
|
|
|
146
148
|
# @!method non_polymorphic_collection?(node)
|
|
147
149
|
def_node_matcher :non_polymorphic_collection?, <<~PATTERN
|
|
148
150
|
{(send (send (send (const {nil? cbase} :File) :stat _) ...) ...)
|
|
149
|
-
(send (send (send (const {nil? cbase} {:File :Tempfile :StringIO}) {:new :open} ...) ...) ...)
|
|
151
|
+
(send (send (send (const {nil? cbase} {:File :Tempfile :StringIO}) {:new :open} ...) ...) ...)
|
|
152
|
+
(send (send (send (const (const {nil? cbase} :File) :Stat) :new ...) ...) ...)}
|
|
150
153
|
PATTERN
|
|
151
154
|
end
|
|
152
155
|
end
|
|
@@ -91,12 +91,9 @@ module RuboCop
|
|
|
91
91
|
command = 'rubocop --auto-gen-config'
|
|
92
92
|
|
|
93
93
|
command += ' --auto-gen-only-exclude' if @options[:auto_gen_only_exclude]
|
|
94
|
-
|
|
95
|
-
if
|
|
96
|
-
|
|
97
|
-
elsif @exclude_limit_option
|
|
98
|
-
command += format(' --exclude-limit %<limit>d', limit: Integer(@exclude_limit_option))
|
|
99
|
-
end
|
|
94
|
+
command += ' --disable-pending-cops' if @options[:disable_pending_cops]
|
|
95
|
+
command += ' --enable-pending-cops' if @options[:enable_pending_cops]
|
|
96
|
+
command += exclude_limit_option
|
|
100
97
|
command += ' --no-offense-counts' unless show_offense_counts?
|
|
101
98
|
|
|
102
99
|
command += ' --no-auto-gen-timestamp' unless show_timestamp?
|
|
@@ -106,6 +103,16 @@ module RuboCop
|
|
|
106
103
|
command
|
|
107
104
|
end
|
|
108
105
|
|
|
106
|
+
def exclude_limit_option
|
|
107
|
+
if no_exclude_limit?
|
|
108
|
+
' --no-exclude-limit'
|
|
109
|
+
elsif @exclude_limit_option
|
|
110
|
+
format(' --exclude-limit %<limit>d', limit: Integer(@exclude_limit_option))
|
|
111
|
+
else
|
|
112
|
+
''
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
109
116
|
def timestamp
|
|
110
117
|
show_timestamp? ? "on #{Time.now.utc} " : ''
|
|
111
118
|
end
|
|
@@ -158,7 +165,7 @@ module RuboCop
|
|
|
158
165
|
output_buffer.puts "# Offense count: #{offense_count}" if show_offense_counts?
|
|
159
166
|
|
|
160
167
|
cop_class = Cop::Registry.global.find_by_cop_name(cop_name)
|
|
161
|
-
default_cfg = default_config(cop_name)
|
|
168
|
+
default_cfg = default_config(cop_name) || @config_for_pwd[cop_name]
|
|
162
169
|
|
|
163
170
|
if supports_safe_autocorrect?(cop_class, default_cfg)
|
|
164
171
|
output_buffer.puts '# This cop supports safe autocorrection (--autocorrect).'
|
data/lib/rubocop/server/core.rb
CHANGED
|
@@ -57,6 +57,12 @@ module RuboCop
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
Process.waitpid(pid)
|
|
60
|
+
|
|
61
|
+
# The daemon writes its pid file asynchronously after forking, so wait until
|
|
62
|
+
# the server is actually running before returning. This prevents a race where
|
|
63
|
+
# a subsequent command (e.g. `--restart-server`) observes an inconsistent
|
|
64
|
+
# state right after `--start-server` returns.
|
|
65
|
+
Server.wait_for_running_status!(true)
|
|
60
66
|
end
|
|
61
67
|
|
|
62
68
|
def write_port_and_token_files
|
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.
|
|
4
|
+
version: 1.88.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bozhidar Batsov
|
|
@@ -1119,9 +1119,9 @@ licenses:
|
|
|
1119
1119
|
- MIT
|
|
1120
1120
|
metadata:
|
|
1121
1121
|
homepage_uri: https://rubocop.org/
|
|
1122
|
-
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.
|
|
1122
|
+
changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.88.0
|
|
1123
1123
|
source_code_uri: https://github.com/rubocop/rubocop/
|
|
1124
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
|
1124
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.88/
|
|
1125
1125
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
|
1126
1126
|
rubygems_mfa_required: 'true'
|
|
1127
1127
|
rdoc_options: []
|