rubocop 1.48.1 → 1.50.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/README.md +1 -1
- data/config/default.yml +19 -7
- data/lib/rubocop/cli/command/execute_runner.rb +7 -2
- data/lib/rubocop/cli.rb +6 -6
- data/lib/rubocop/config.rb +1 -1
- data/lib/rubocop/config_loader.rb +8 -8
- data/lib/rubocop/cop/autocorrect_logic.rb +28 -12
- data/lib/rubocop/cop/cop.rb +2 -2
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/cop_description.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/inherit_deprecated_cop_class.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +29 -2
- data/lib/rubocop/cop/layout/class_structure.rb +1 -0
- data/lib/rubocop/cop/layout/empty_comment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +2 -0
- data/lib/rubocop/cop/layout/end_alignment.rb +5 -1
- data/lib/rubocop/cop/layout/extra_spacing.rb +6 -1
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +6 -1
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
- data/lib/rubocop/cop/layout/initial_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/redundant_line_break.rb +6 -7
- data/lib/rubocop/cop/layout/space_before_first_arg.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_parens.rb +2 -2
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +3 -3
- data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +102 -0
- data/lib/rubocop/cop/lint/empty_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +35 -15
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +7 -1
- data/lib/rubocop/cop/lint/unreachable_loop.rb +3 -3
- data/lib/rubocop/cop/lint/useless_method_definition.rb +10 -2
- data/lib/rubocop/cop/lint/void.rb +7 -3
- data/lib/rubocop/cop/metrics/block_nesting.rb +1 -1
- data/lib/rubocop/cop/metrics/class_length.rb +1 -0
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -1
- data/lib/rubocop/cop/mixin/comments_help.rb +1 -1
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +1 -1
- data/lib/rubocop/cop/naming/ascii_identifiers.rb +1 -1
- data/lib/rubocop/cop/naming/inclusive_language.rb +23 -4
- data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
- data/lib/rubocop/cop/style/class_equality_comparison.rb +42 -9
- data/lib/rubocop/cop/style/copyright.rb +1 -1
- data/lib/rubocop/cop/style/data_inheritance.rb +75 -0
- data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +2 -2
- data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +1 -1
- data/lib/rubocop/cop/style/double_negation.rb +2 -2
- data/lib/rubocop/cop/style/file_empty.rb +3 -3
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
- data/lib/rubocop/cop/style/hash_except.rb +4 -4
- data/lib/rubocop/cop/style/hash_syntax.rb +4 -1
- data/lib/rubocop/cop/style/if_unless_modifier.rb +38 -12
- data/lib/rubocop/cop/style/map_to_hash.rb +4 -1
- data/lib/rubocop/cop/style/map_to_set.rb +4 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +3 -7
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +43 -36
- data/lib/rubocop/cop/style/multiline_method_signature.rb +6 -3
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +2 -3
- data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +167 -0
- data/lib/rubocop/cop/style/redundant_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/redundant_percent_q.rb +1 -1
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +2 -2
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +1 -1
- data/lib/rubocop/cop/style/redundant_string_escape.rb +2 -3
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +2 -2
- data/lib/rubocop/cop/style/struct_inheritance.rb +1 -1
- data/lib/rubocop/cop/style/trailing_body_on_class.rb +1 -0
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/style/unless_logical_operators.rb +1 -0
- data/lib/rubocop/cops_documentation_generator.rb +10 -3
- data/lib/rubocop/ext/regexp_node.rb +1 -1
- data/lib/rubocop/ext/regexp_parser.rb +1 -1
- data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
- data/lib/rubocop/options.rb +4 -1
- data/lib/rubocop/result_cache.rb +1 -1
- data/lib/rubocop/server/cache.rb +1 -1
- data/lib/rubocop/server/helper.rb +1 -1
- data/lib/rubocop/server/server_command/exec.rb +1 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +3 -0
- metadata +9 -6
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'fileutils'
|
4
|
+
|
3
5
|
# Class for generating documentation of all cops departments
|
4
6
|
# @api private
|
5
7
|
class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
@@ -14,6 +16,8 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
14
16
|
@departments = departments.map(&:to_sym).sort!
|
15
17
|
@cops = RuboCop::Cop::Registry.global
|
16
18
|
@config = RuboCop::ConfigLoader.default_configuration
|
19
|
+
@docs_path = "#{Dir.pwd}/docs/modules/ROOT/pages/"
|
20
|
+
FileUtils.mkdir_p(@docs_path)
|
17
21
|
end
|
18
22
|
|
19
23
|
def call
|
@@ -27,7 +31,7 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
27
31
|
|
28
32
|
private
|
29
33
|
|
30
|
-
attr_reader :departments, :cops, :config
|
34
|
+
attr_reader :departments, :cops, :config, :docs_path
|
31
35
|
|
32
36
|
def cops_of_department(department)
|
33
37
|
cops.with_department(department).sort!
|
@@ -252,7 +256,7 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
252
256
|
content = +"= #{department}\n"
|
253
257
|
selected_cops.each { |cop| content << print_cop_with_doc(cop) }
|
254
258
|
content << footer_for_department(department)
|
255
|
-
file_name = "#{
|
259
|
+
file_name = "#{docs_path}/#{department_to_basename(department)}.adoc"
|
256
260
|
File.open(file_name, 'w') do |file|
|
257
261
|
puts "* generated #{file_name}"
|
258
262
|
file.write("#{content.strip}\n")
|
@@ -298,7 +302,10 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
298
302
|
end
|
299
303
|
|
300
304
|
def print_table_of_contents
|
301
|
-
path = "#{
|
305
|
+
path = "#{docs_path}/cops.adoc"
|
306
|
+
|
307
|
+
File.write(path, table_contents) and return unless File.exist?(path)
|
308
|
+
|
302
309
|
original = File.read(path)
|
303
310
|
content = +"// START_COP_LIST\n\n"
|
304
311
|
|
@@ -29,7 +29,7 @@ module RuboCop
|
|
29
29
|
@parsed_tree&.each_expression(true) { |e| e.origin = origin }
|
30
30
|
end
|
31
31
|
# Please remove this `else` branch when support for regexp_parser 1.8 will be dropped.
|
32
|
-
# It's for compatibility with
|
32
|
+
# It's for compatibility with regexp_parser 1.8 and will never be maintained.
|
33
33
|
else
|
34
34
|
def assign_properties(*)
|
35
35
|
super
|
@@ -28,7 +28,7 @@ module RuboCop
|
|
28
28
|
@expression ||= origin.adjust(begin_pos: ts, end_pos: ts + full_length)
|
29
29
|
end
|
30
30
|
# Please remove this `else` branch when support for regexp_parser 1.8 will be dropped.
|
31
|
-
# It's for compatibility with
|
31
|
+
# It's for compatibility with regexp_parser 1.8 and will never be maintained.
|
32
32
|
else
|
33
33
|
attr_accessor :source
|
34
34
|
|
@@ -61,7 +61,7 @@ module RuboCop
|
|
61
61
|
correctable_count,
|
62
62
|
rainbow,
|
63
63
|
# :safe_autocorrect is a derived option based on several command-line
|
64
|
-
# arguments - see
|
64
|
+
# arguments - see RuboCop::Options#add_autocorrection_options
|
65
65
|
safe_autocorrect: @options[:safe_autocorrect])
|
66
66
|
|
67
67
|
output.puts
|
data/lib/rubocop/options.rb
CHANGED
@@ -182,7 +182,10 @@ module RuboCop
|
|
182
182
|
raise OptionArgumentError, message
|
183
183
|
end
|
184
184
|
|
185
|
-
|
185
|
+
cop_names = list.empty? ? [''] : list.split(',')
|
186
|
+
cop_names.unshift('Lint/Syntax') if option == 'only' && !cop_names.include?('Lint/Syntax')
|
187
|
+
|
188
|
+
@options[:"#{option}"] = cop_names
|
186
189
|
end
|
187
190
|
end
|
188
191
|
|
data/lib/rubocop/result_cache.rb
CHANGED
@@ -86,7 +86,7 @@ module RuboCop
|
|
86
86
|
attr :path
|
87
87
|
|
88
88
|
def initialize(file, team, options, config_store, cache_root = nil)
|
89
|
-
cache_root ||= options[:cache_root]
|
89
|
+
cache_root ||= File.join(options[:cache_root], 'rubocop_cache') if options[:cache_root]
|
90
90
|
cache_root ||= ResultCache.cache_root(config_store)
|
91
91
|
@allow_symlinks_in_cache_location =
|
92
92
|
ResultCache.allow_symlinks_in_cache_location?(config_store)
|
data/lib/rubocop/server/cache.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
module RuboCop
|
13
13
|
module Server
|
14
|
-
# This module has a helper
|
14
|
+
# This module has a helper method for `RuboCop::Server::SocketReader`.
|
15
15
|
# @api private
|
16
16
|
module Helper
|
17
17
|
def self.redirect(stdin: $stdin, stdout: $stdout, stderr: $stderr, &_block)
|
@@ -21,7 +21,7 @@ module RuboCop
|
|
21
21
|
# We must pass the --color option to preserve this behavior.
|
22
22
|
@args.unshift('--color') unless %w[--color --no-color].any? { |f| @args.include?(f) }
|
23
23
|
status = RuboCop::CLI.new.run(@args)
|
24
|
-
# This status file is read by `rubocop --server` (`RuboCop::Server::
|
24
|
+
# This status file is read by `rubocop --server` (`RuboCop::Server::ClientCommand::Exec`).
|
25
25
|
# so that they use the correct exit code.
|
26
26
|
# Status is 1 when there are any issues, and 0 otherwise.
|
27
27
|
Cache.write_status_file(status)
|
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
@@ -299,6 +299,7 @@ require_relative 'rubocop/cop/lint/duplicate_case_condition'
|
|
299
299
|
require_relative 'rubocop/cop/lint/duplicate_elsif_condition'
|
300
300
|
require_relative 'rubocop/cop/lint/duplicate_hash_key'
|
301
301
|
require_relative 'rubocop/cop/lint/duplicate_magic_comment'
|
302
|
+
require_relative 'rubocop/cop/lint/duplicate_match_pattern'
|
302
303
|
require_relative 'rubocop/cop/lint/duplicate_methods'
|
303
304
|
require_relative 'rubocop/cop/lint/duplicate_regexp_character_class_element'
|
304
305
|
require_relative 'rubocop/cop/lint/duplicate_require'
|
@@ -480,6 +481,7 @@ require_relative 'rubocop/cop/style/concat_array_literals'
|
|
480
481
|
require_relative 'rubocop/cop/style/conditional_assignment'
|
481
482
|
require_relative 'rubocop/cop/style/constant_visibility'
|
482
483
|
require_relative 'rubocop/cop/style/copyright'
|
484
|
+
require_relative 'rubocop/cop/style/data_inheritance'
|
483
485
|
require_relative 'rubocop/cop/style/date_time'
|
484
486
|
require_relative 'rubocop/cop/style/def_with_parentheses'
|
485
487
|
require_relative 'rubocop/cop/style/dir'
|
@@ -563,6 +565,7 @@ require_relative 'rubocop/cop/style/redundant_fetch_block'
|
|
563
565
|
require_relative 'rubocop/cop/style/redundant_file_extension_in_require'
|
564
566
|
require_relative 'rubocop/cop/style/redundant_heredoc_delimiter_quotes'
|
565
567
|
require_relative 'rubocop/cop/style/redundant_initialize'
|
568
|
+
require_relative 'rubocop/cop/style/redundant_line_continuation'
|
566
569
|
require_relative 'rubocop/cop/style/redundant_self_assignment'
|
567
570
|
require_relative 'rubocop/cop/style/redundant_self_assignment_branch'
|
568
571
|
require_relative 'rubocop/cop/style/require_order'
|
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.50.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-04-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
requirements:
|
121
121
|
- - ">="
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: 1.
|
123
|
+
version: 1.28.0
|
124
124
|
- - "<"
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '2.0'
|
@@ -130,7 +130,7 @@ dependencies:
|
|
130
130
|
requirements:
|
131
131
|
- - ">="
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: 1.
|
133
|
+
version: 1.28.0
|
134
134
|
- - "<"
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '2.0'
|
@@ -420,6 +420,7 @@ files:
|
|
420
420
|
- lib/rubocop/cop/lint/duplicate_elsif_condition.rb
|
421
421
|
- lib/rubocop/cop/lint/duplicate_hash_key.rb
|
422
422
|
- lib/rubocop/cop/lint/duplicate_magic_comment.rb
|
423
|
+
- lib/rubocop/cop/lint/duplicate_match_pattern.rb
|
423
424
|
- lib/rubocop/cop/lint/duplicate_methods.rb
|
424
425
|
- lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb
|
425
426
|
- lib/rubocop/cop/lint/duplicate_require.rb
|
@@ -683,6 +684,7 @@ files:
|
|
683
684
|
- lib/rubocop/cop/style/conditional_assignment.rb
|
684
685
|
- lib/rubocop/cop/style/constant_visibility.rb
|
685
686
|
- lib/rubocop/cop/style/copyright.rb
|
687
|
+
- lib/rubocop/cop/style/data_inheritance.rb
|
686
688
|
- lib/rubocop/cop/style/date_time.rb
|
687
689
|
- lib/rubocop/cop/style/def_with_parentheses.rb
|
688
690
|
- lib/rubocop/cop/style/dir.rb
|
@@ -827,6 +829,7 @@ files:
|
|
827
829
|
- lib/rubocop/cop/style/redundant_heredoc_delimiter_quotes.rb
|
828
830
|
- lib/rubocop/cop/style/redundant_initialize.rb
|
829
831
|
- lib/rubocop/cop/style/redundant_interpolation.rb
|
832
|
+
- lib/rubocop/cop/style/redundant_line_continuation.rb
|
830
833
|
- lib/rubocop/cop/style/redundant_parentheses.rb
|
831
834
|
- lib/rubocop/cop/style/redundant_percent_q.rb
|
832
835
|
- lib/rubocop/cop/style/redundant_regexp_character_class.rb
|
@@ -988,7 +991,7 @@ metadata:
|
|
988
991
|
homepage_uri: https://rubocop.org/
|
989
992
|
changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
|
990
993
|
source_code_uri: https://github.com/rubocop/rubocop/
|
991
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
994
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.50/
|
992
995
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
993
996
|
rubygems_mfa_required: 'true'
|
994
997
|
post_install_message:
|
@@ -1006,7 +1009,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1006
1009
|
- !ruby/object:Gem::Version
|
1007
1010
|
version: '0'
|
1008
1011
|
requirements: []
|
1009
|
-
rubygems_version: 3.
|
1012
|
+
rubygems_version: 3.4.6
|
1010
1013
|
signing_key:
|
1011
1014
|
specification_version: 4
|
1012
1015
|
summary: Automatic Ruby code style checking tool.
|