rubocop 0.76.0 → 0.77.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 +2 -2
- data/config/default.yml +252 -239
- data/lib/rubocop.rb +27 -20
- data/lib/rubocop/ast/node.rb +1 -1
- data/lib/rubocop/ast/node/block_node.rb +2 -0
- data/lib/rubocop/cli.rb +11 -230
- data/lib/rubocop/cli/command.rb +21 -0
- data/lib/rubocop/cli/command/auto_genenerate_config.rb +105 -0
- data/lib/rubocop/cli/command/base.rb +33 -0
- data/lib/rubocop/cli/command/execute_runner.rb +76 -0
- data/lib/rubocop/cli/command/init_dotfile.rb +45 -0
- data/lib/rubocop/cli/command/show_cops.rb +73 -0
- data/lib/rubocop/cli/command/version.rb +17 -0
- data/lib/rubocop/cli/environment.rb +21 -0
- data/lib/rubocop/config_obsoletion.rb +62 -9
- data/lib/rubocop/config_validator.rb +1 -3
- data/lib/rubocop/cop/bundler/gem_comment.rb +4 -4
- data/lib/rubocop/cop/cop.rb +19 -0
- data/lib/rubocop/cop/correctors/space_corrector.rb +1 -2
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +59 -0
- data/lib/rubocop/cop/layout/{align_arguments.rb → argument_alignment.rb} +1 -1
- data/lib/rubocop/cop/layout/{align_array.rb → array_alignment.rb} +1 -1
- data/lib/rubocop/cop/layout/{indent_assignment.rb → assignment_indentation.rb} +1 -1
- data/lib/rubocop/cop/layout/extra_spacing.rb +1 -1
- data/lib/rubocop/cop/layout/{indent_first_argument.rb → first_argument_indentation.rb} +3 -3
- data/lib/rubocop/cop/layout/{indent_first_array_element.rb → first_array_element_indentation.rb} +4 -4
- data/lib/rubocop/cop/layout/{indent_first_hash_element.rb → first_hash_element_indentation.rb} +3 -3
- data/lib/rubocop/cop/layout/{indent_first_parameter.rb → first_parameter_indentation.rb} +3 -3
- data/lib/rubocop/cop/layout/{align_hash.rb → hash_alignment.rb} +2 -2
- data/lib/rubocop/cop/layout/{indent_heredoc.rb → heredoc_indentation.rb} +1 -1
- data/lib/rubocop/cop/layout/{leading_blank_lines.rb → leading_empty_lines.rb} +1 -1
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +1 -1
- data/lib/rubocop/cop/layout/{align_parameters.rb → parameter_alignment.rb} +1 -1
- data/lib/rubocop/cop/layout/space_around_keyword.rb +12 -0
- data/lib/rubocop/cop/layout/space_around_operators.rb +1 -1
- data/lib/rubocop/cop/layout/{trailing_blank_lines.rb → trailing_empty_lines.rb} +1 -1
- data/lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb +1 -1
- data/lib/rubocop/cop/lint/{duplicated_key.rb → duplicate_hash_key.rb} +1 -1
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -1
- data/lib/rubocop/cop/lint/{multiple_compare.rb → multiple_comparison.rb} +1 -1
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -1
- data/lib/rubocop/cop/lint/{string_conversion_in_interpolation.rb → redundant_string_coercion.rb} +1 -1
- data/lib/rubocop/cop/lint/redundant_with_index.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_with_object.rb +2 -2
- data/lib/rubocop/cop/lint/{handle_exceptions.rb → suppressed_exception.rb} +1 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +57 -23
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
- data/lib/rubocop/cop/metrics/line_length.rb +41 -38
- data/lib/rubocop/cop/metrics/method_length.rb +1 -1
- data/lib/rubocop/cop/mixin/{hash_alignment.rb → hash_alignment_styles.rb} +1 -1
- data/lib/rubocop/cop/mixin/nil_methods.rb +4 -4
- data/lib/rubocop/cop/naming/{uncommunicative_block_param_name.rb → block_parameter_name.rb} +3 -3
- data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +5 -5
- data/lib/rubocop/cop/naming/{uncommunicative_method_param_name.rb → method_parameter_name.rb} +3 -3
- data/lib/rubocop/cop/naming/predicate_name.rb +6 -6
- data/lib/rubocop/cop/style/alias.rb +1 -1
- data/lib/rubocop/cop/style/array_join.rb +1 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +1 -1
- data/lib/rubocop/cop/style/even_odd.rb +1 -1
- data/lib/rubocop/cop/style/ip_addresses.rb +4 -4
- data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +5 -5
- data/lib/rubocop/cop/style/next.rb +5 -5
- data/lib/rubocop/cop/style/numeric_literals.rb +7 -3
- data/lib/rubocop/cop/style/option_hash.rb +3 -3
- data/lib/rubocop/cop/style/redundant_parentheses.rb +3 -3
- data/lib/rubocop/cop/style/redundant_return.rb +2 -8
- data/lib/rubocop/cop/style/redundant_sort.rb +1 -1
- data/lib/rubocop/cop/style/trivial_accessors.rb +5 -5
- data/lib/rubocop/cop/team.rb +5 -0
- data/lib/rubocop/formatter/clang_style_formatter.rb +1 -3
- data/lib/rubocop/formatter/tap_formatter.rb +1 -3
- data/lib/rubocop/processed_source.rb +1 -1
- data/lib/rubocop/rake_task.rb +1 -0
- data/lib/rubocop/result_cache.rb +21 -7
- data/lib/rubocop/runner.rb +13 -1
- data/lib/rubocop/version.rb +1 -1
- metadata +30 -22
- data/lib/rubocop/cop/mixin/safe_mode.rb +0 -24
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
class CLI
|
5
|
+
# Home of subcommands in the CLI.
|
6
|
+
module Command
|
7
|
+
class << self
|
8
|
+
# Find the command with a given name and run it in an environment.
|
9
|
+
def run(env, name)
|
10
|
+
class_for(name).new(env).run
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def class_for(name)
|
16
|
+
Base.by_command_name(name)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
class CLI
|
5
|
+
module Command
|
6
|
+
# Generate a configuration file acting as a TODO list.
|
7
|
+
class AutoGenerateConfig < Base
|
8
|
+
self.command_name = :auto_gen_config
|
9
|
+
|
10
|
+
PHASE_1 = 'Phase 1 of 2: run Metrics/LineLength cop'
|
11
|
+
PHASE_2 = 'Phase 2 of 2: run all cops'
|
12
|
+
|
13
|
+
PHASE_1_OVERRIDDEN =
|
14
|
+
'(skipped because the default Metrics/LineLength:Max is overridden)'
|
15
|
+
PHASE_1_DISABLED =
|
16
|
+
'(skipped because Metrics/LineLength is disabled)'
|
17
|
+
|
18
|
+
def run
|
19
|
+
add_formatter
|
20
|
+
reset_config_and_auto_gen_file
|
21
|
+
line_length_contents = maybe_run_line_length_cop
|
22
|
+
run_all_cops(line_length_contents)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def maybe_run_line_length_cop
|
28
|
+
if !line_length_enabled?(@config_store.for(Dir.pwd))
|
29
|
+
skip_line_length_cop(PHASE_1_DISABLED)
|
30
|
+
elsif !same_max_line_length?(
|
31
|
+
@config_store.for(Dir.pwd), ConfigLoader.default_configuration
|
32
|
+
)
|
33
|
+
skip_line_length_cop(PHASE_1_OVERRIDDEN)
|
34
|
+
else
|
35
|
+
run_line_length_cop
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def skip_line_length_cop(reason)
|
40
|
+
puts Rainbow("#{PHASE_1} #{reason}").yellow
|
41
|
+
''
|
42
|
+
end
|
43
|
+
|
44
|
+
def line_length_enabled?(config)
|
45
|
+
line_length_cop(config)['Enabled']
|
46
|
+
end
|
47
|
+
|
48
|
+
def same_max_line_length?(config1, config2)
|
49
|
+
max_line_length(config1) == max_line_length(config2)
|
50
|
+
end
|
51
|
+
|
52
|
+
def max_line_length(config)
|
53
|
+
line_length_cop(config)['Max']
|
54
|
+
end
|
55
|
+
|
56
|
+
def line_length_cop(config)
|
57
|
+
config.for_cop('Metrics/LineLength')
|
58
|
+
end
|
59
|
+
|
60
|
+
# Do an initial run with only Metrics/LineLength so that cops that
|
61
|
+
# depend on Metrics/LineLength:Max get the correct value for that
|
62
|
+
# parameter.
|
63
|
+
def run_line_length_cop
|
64
|
+
puts Rainbow(PHASE_1).yellow
|
65
|
+
@options[:only] = ['Metrics/LineLength']
|
66
|
+
execute_runner
|
67
|
+
@options.delete(:only)
|
68
|
+
@config_store = ConfigStore.new
|
69
|
+
# Save the todo configuration of the LineLength cop.
|
70
|
+
IO.read(ConfigLoader::AUTO_GENERATED_FILE)
|
71
|
+
.lines
|
72
|
+
.drop_while { |line| line.start_with?('#') }
|
73
|
+
.join
|
74
|
+
end
|
75
|
+
|
76
|
+
def run_all_cops(line_length_contents)
|
77
|
+
puts Rainbow(PHASE_2).yellow
|
78
|
+
result = execute_runner
|
79
|
+
# This run was made with the current maximum length allowed, so append
|
80
|
+
# the saved setting for LineLength.
|
81
|
+
File.open(ConfigLoader::AUTO_GENERATED_FILE, 'a') do |f|
|
82
|
+
f.write(line_length_contents)
|
83
|
+
end
|
84
|
+
result
|
85
|
+
end
|
86
|
+
|
87
|
+
def reset_config_and_auto_gen_file
|
88
|
+
@config_store = ConfigStore.new
|
89
|
+
@config_store.options_config = @options[:config] if @options[:config]
|
90
|
+
File.open(ConfigLoader::AUTO_GENERATED_FILE, 'w') {}
|
91
|
+
ConfigLoader.add_inheritance_from_auto_generated_file
|
92
|
+
end
|
93
|
+
|
94
|
+
def add_formatter
|
95
|
+
@options[:formatters] << [Formatter::DisabledConfigFormatter,
|
96
|
+
ConfigLoader::AUTO_GENERATED_FILE]
|
97
|
+
end
|
98
|
+
|
99
|
+
def execute_runner
|
100
|
+
Environment.new(@options, @config_store, @paths).run(:execute_runner)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
class CLI
|
5
|
+
module Command
|
6
|
+
# A subcommand in the CLI.
|
7
|
+
class Base
|
8
|
+
attr_reader :env
|
9
|
+
|
10
|
+
@subclasses = []
|
11
|
+
|
12
|
+
class << self
|
13
|
+
attr_accessor :command_name
|
14
|
+
|
15
|
+
def inherited(subclass)
|
16
|
+
@subclasses << subclass
|
17
|
+
end
|
18
|
+
|
19
|
+
def by_command_name(name)
|
20
|
+
@subclasses.detect { |s| s.command_name == name }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(env)
|
25
|
+
@env = env
|
26
|
+
@options = env.options
|
27
|
+
@config_store = env.config_store
|
28
|
+
@paths = env.paths
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
class CLI
|
5
|
+
module Command
|
6
|
+
# Run all the selected cops and report the result.
|
7
|
+
class ExecuteRunner < Base
|
8
|
+
include Formatter::TextUtil
|
9
|
+
|
10
|
+
self.command_name = :execute_runner
|
11
|
+
|
12
|
+
def run
|
13
|
+
execute_runner(@paths)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def execute_runner(paths)
|
19
|
+
runner = Runner.new(@options, @config_store)
|
20
|
+
|
21
|
+
all_passed = runner.run(paths)
|
22
|
+
display_warning_summary(runner.warnings)
|
23
|
+
display_error_summary(runner.errors)
|
24
|
+
maybe_print_corrected_source
|
25
|
+
|
26
|
+
all_pass_or_excluded = all_passed || @options[:auto_gen_config]
|
27
|
+
|
28
|
+
if runner.aborting?
|
29
|
+
STATUS_INTERRUPTED
|
30
|
+
elsif all_pass_or_excluded && runner.errors.empty?
|
31
|
+
STATUS_SUCCESS
|
32
|
+
else
|
33
|
+
STATUS_OFFENSES
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def display_warning_summary(warnings)
|
38
|
+
return if warnings.empty?
|
39
|
+
|
40
|
+
warn Rainbow("\n#{pluralize(warnings.size, 'warning')}:").yellow
|
41
|
+
|
42
|
+
warnings.each { |warning| warn warning }
|
43
|
+
end
|
44
|
+
|
45
|
+
def display_error_summary(errors)
|
46
|
+
return if errors.empty?
|
47
|
+
|
48
|
+
warn Rainbow("\n#{pluralize(errors.size, 'error')} occurred:").red
|
49
|
+
|
50
|
+
errors.each { |error| warn error }
|
51
|
+
|
52
|
+
warn <<~WARNING
|
53
|
+
Errors are usually caused by RuboCop bugs.
|
54
|
+
Please, report your problems to RuboCop's issue tracker.
|
55
|
+
#{Gem.loaded_specs['rubocop'].metadata['bug_tracker_uri']}
|
56
|
+
|
57
|
+
Mention the following information in the issue report:
|
58
|
+
#{RuboCop::Version.version(true)}
|
59
|
+
WARNING
|
60
|
+
end
|
61
|
+
|
62
|
+
def maybe_print_corrected_source
|
63
|
+
# If we are asked to autocorrect source code read from stdin, the only
|
64
|
+
# reasonable place to write it is to stdout
|
65
|
+
# Unfortunately, we also write other information to stdout
|
66
|
+
# So a delimiter is needed for tools to easily identify where the
|
67
|
+
# autocorrected source begins
|
68
|
+
return unless @options[:stdin] && @options[:auto_correct]
|
69
|
+
|
70
|
+
puts '=' * 20
|
71
|
+
print @options[:stdin]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
class CLI
|
5
|
+
module Command
|
6
|
+
# Generate a .rubocop.yml file in the current directory.
|
7
|
+
class InitDotfile < Base
|
8
|
+
DOTFILE = ConfigLoader::DOTFILE
|
9
|
+
|
10
|
+
self.command_name = :init
|
11
|
+
|
12
|
+
def run
|
13
|
+
path = File.expand_path(DOTFILE)
|
14
|
+
|
15
|
+
if File.exist?(DOTFILE)
|
16
|
+
warn Rainbow("#{DOTFILE} already exists at #{path}").red
|
17
|
+
|
18
|
+
STATUS_ERROR
|
19
|
+
else
|
20
|
+
description = <<~DESC
|
21
|
+
# The behavior of RuboCop can be controlled via the .rubocop.yml
|
22
|
+
# configuration file. It makes it possible to enable/disable
|
23
|
+
# certain cops (checks) and to alter their behavior if they accept
|
24
|
+
# any parameters. The file can be placed either in your home
|
25
|
+
# directory or in some project directory.
|
26
|
+
#
|
27
|
+
# RuboCop will start looking for the configuration file in the directory
|
28
|
+
# where the inspected file is and continue its way up to the root directory.
|
29
|
+
#
|
30
|
+
# See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md
|
31
|
+
DESC
|
32
|
+
|
33
|
+
File.open(DOTFILE, 'w') do |f|
|
34
|
+
f.write(description)
|
35
|
+
end
|
36
|
+
|
37
|
+
puts "Writing new #{DOTFILE} to #{path}"
|
38
|
+
|
39
|
+
STATUS_SUCCESS
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
class CLI
|
5
|
+
module Command
|
6
|
+
# Shows the given cops, or all cops by default, and their configurations
|
7
|
+
# for the current directory.
|
8
|
+
class ShowCops < Base
|
9
|
+
self.command_name = :show_cops
|
10
|
+
|
11
|
+
def run
|
12
|
+
print_available_cops
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def print_available_cops
|
18
|
+
# Load the configs so the require()s are done for custom cops
|
19
|
+
@config_store.for(Dir.pwd)
|
20
|
+
registry = Cop::Cop.registry
|
21
|
+
show_all = @options[:show_cops].empty?
|
22
|
+
|
23
|
+
if show_all
|
24
|
+
puts "# Available cops (#{registry.length}) " \
|
25
|
+
"+ config for #{Dir.pwd}: "
|
26
|
+
end
|
27
|
+
|
28
|
+
registry.departments.sort!.each do |department|
|
29
|
+
print_cops_of_department(registry, department, show_all)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def print_cops_of_department(registry, department, show_all)
|
34
|
+
selected_cops = if show_all
|
35
|
+
cops_of_department(registry, department)
|
36
|
+
else
|
37
|
+
selected_cops_of_department(registry, department)
|
38
|
+
end
|
39
|
+
|
40
|
+
if show_all
|
41
|
+
puts "# Department '#{department}' (#{selected_cops.length}):"
|
42
|
+
end
|
43
|
+
|
44
|
+
print_cop_details(selected_cops)
|
45
|
+
end
|
46
|
+
|
47
|
+
def print_cop_details(cops)
|
48
|
+
cops.each do |cop|
|
49
|
+
puts '# Supports --auto-correct' if cop.new.support_autocorrect?
|
50
|
+
puts "#{cop.cop_name}:"
|
51
|
+
puts config_lines(cop)
|
52
|
+
puts
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def selected_cops_of_department(cops, department)
|
57
|
+
cops_of_department(cops, department).select do |cop|
|
58
|
+
@options[:show_cops].include?(cop.cop_name)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def cops_of_department(cops, department)
|
63
|
+
cops.with_department(department).sort!
|
64
|
+
end
|
65
|
+
|
66
|
+
def config_lines(cop)
|
67
|
+
cnf = @config_store.for(Dir.pwd).for_cop(cop)
|
68
|
+
cnf.to_yaml.lines.to_a.drop(1).map { |line| ' ' + line }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
class CLI
|
5
|
+
module Command
|
6
|
+
# Display version.
|
7
|
+
class Version < Base
|
8
|
+
self.command_name = :version
|
9
|
+
|
10
|
+
def run
|
11
|
+
puts RuboCop::Version.version(false) if @options[:version]
|
12
|
+
puts RuboCop::Version.version(true) if @options[:verbose_version]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
class CLI
|
5
|
+
# Execution environment for a CLI command.
|
6
|
+
class Environment
|
7
|
+
attr_reader :options, :config_store, :paths
|
8
|
+
|
9
|
+
def initialize(options, config_store, paths)
|
10
|
+
@options = options
|
11
|
+
@config_store = config_store
|
12
|
+
@paths = paths
|
13
|
+
end
|
14
|
+
|
15
|
+
# Run a command in this environment.
|
16
|
+
def run(name)
|
17
|
+
Command.run(self, name)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -4,22 +4,39 @@ module RuboCop
|
|
4
4
|
# This class handles obsolete configuration.
|
5
5
|
class ConfigObsoletion
|
6
6
|
RENAMED_COPS = {
|
7
|
+
'Layout/AlignArguments' => 'Layout/ArgumentAlignment',
|
8
|
+
'Layout/AlignArray' => 'Layout/ArrayAlignment',
|
9
|
+
'Layout/AlignHash' => 'Layout/HashAlignment',
|
10
|
+
'Layout/AlignParameters' => 'Layout/ParameterAlignment',
|
11
|
+
'Layout/IndentArray' => 'Layout/FirstArrayElementIndentation',
|
12
|
+
'Layout/IndentAssignment' => 'Layout/AssignmentIndentation',
|
13
|
+
'Layout/IndentFirstArgument' => 'Layout/FirstArgumentIndentation',
|
14
|
+
'Layout/IndentFirstArrayElement' => 'Layout/FirstArrayElementIndentation',
|
15
|
+
'Layout/IndentFirstHashElement' => 'Layout/FirstHashElementIndentation',
|
16
|
+
'Layout/IndentFirstParameter' => 'Layout/FirstParameterIndentation',
|
17
|
+
'Layout/IndentHash' => 'Layout/FirstHashElementIndentation',
|
18
|
+
'Layout/IndentHeredoc' => 'Layout/HeredocIndentation',
|
19
|
+
'Layout/LeadingBlankLines' => 'Layout/LeadingEmptyLines',
|
20
|
+
'Layout/TrailingBlankLines' => 'Layout/TrailingEmptyLines',
|
21
|
+
'Lint/DuplicatedKey' => 'Lint/DuplicateHashKey',
|
22
|
+
'Lint/HandleExceptions' => 'Lint/SuppressedException',
|
23
|
+
'Lint/MultipleCompare' => 'Lint/MultipleComparison',
|
24
|
+
'Lint/StringConversionInInterpolation' => 'Lint/RedundantStringCoercion',
|
7
25
|
'Lint/UnneededCopDisableDirective' => 'Lint/RedundantCopDisableDirective',
|
8
26
|
'Lint/UnneededCopEnableDirective' => 'Lint/RedundantCopEnableDirective',
|
9
27
|
'Lint/UnneededRequireStatement' => 'Lint/RedundantRequireStatement',
|
10
28
|
'Lint/UnneededSplatExpansion' => 'Lint/RedundantSplatExpansion',
|
11
|
-
'
|
12
|
-
'
|
29
|
+
'Naming/UncommunicativeBlockParamName' => 'Naming/BlockParameterName',
|
30
|
+
'Naming/UncommunicativeMethodParamName' => 'Naming/MethodParameterName',
|
13
31
|
'Style/DeprecatedHashMethods' => 'Style/PreferredHashMethods',
|
32
|
+
'Style/MethodCallParentheses' => 'Style/MethodCallWithoutArgsParentheses',
|
14
33
|
'Style/OpMethod' => 'Naming/BinaryOperatorParameterName',
|
34
|
+
'Style/SingleSpaceBeforeFirstArg' => 'Layout/SpaceBeforeFirstArg',
|
15
35
|
'Style/UnneededCapitalW' => 'Style/RedundantCapitalW',
|
16
36
|
'Style/UnneededCondition' => 'Style/RedundantCondition',
|
17
37
|
'Style/UnneededInterpolation' => 'Style/RedundantInterpolation',
|
18
38
|
'Style/UnneededPercentQ' => 'Style/RedundantPercentQ',
|
19
|
-
'Style/UnneededSort' => 'Style/RedundantSort'
|
20
|
-
'Layout/FirstParameterIndentation' => 'Layout/IndentFirstArgument',
|
21
|
-
'Layout/IndentArray' => 'Layout/IndentFirstArrayElement',
|
22
|
-
'Layout/IndentHash' => 'Layout/IndentFirstHashElement'
|
39
|
+
'Style/UnneededSort' => 'Style/RedundantSort'
|
23
40
|
}.map do |old_name, new_name|
|
24
41
|
[old_name, "The `#{old_name}` cop has been renamed to `#{new_name}`."]
|
25
42
|
end
|
@@ -41,9 +58,10 @@ module RuboCop
|
|
41
58
|
end
|
42
59
|
|
43
60
|
REMOVED_COPS = {
|
44
|
-
'Rails/DefaultScope' => nil,
|
45
61
|
'Layout/SpaceAfterControlKeyword' => 'Layout/SpaceAroundKeyword',
|
46
62
|
'Layout/SpaceBeforeModifierKeyword' => 'Layout/SpaceAroundKeyword',
|
63
|
+
'Lint/RescueWithoutErrorClass' => 'Style/RescueStandardError',
|
64
|
+
'Rails/DefaultScope' => nil,
|
47
65
|
'Style/SpaceAfterControlKeyword' => 'Layout/SpaceAroundKeyword',
|
48
66
|
'Style/SpaceBeforeModifierKeyword' => 'Layout/SpaceAroundKeyword',
|
49
67
|
'Style/TrailingComma' => 'Style/TrailingCommaInArguments, ' \
|
@@ -51,8 +69,7 @@ module RuboCop
|
|
51
69
|
'Style/TrailingCommaInHashLiteral',
|
52
70
|
'Style/TrailingCommaInLiteral' => 'Style/TrailingCommaInArrayLiteral ' \
|
53
71
|
'and/or ' \
|
54
|
-
'Style/TrailingCommaInHashLiteral'
|
55
|
-
'Lint/RescueWithoutErrorClass' => 'Style/RescueStandardError'
|
72
|
+
'Style/TrailingCommaInHashLiteral'
|
56
73
|
}.map do |old_name, other_cops|
|
57
74
|
if other_cops
|
58
75
|
more = ". Please use #{other_cops} instead".gsub(%r{[A-Z]\w+/\w+},
|
@@ -140,6 +157,42 @@ module RuboCop
|
|
140
157
|
parameters: 'SafeMode',
|
141
158
|
alternative: '`SafeMode` has been removed. ' \
|
142
159
|
'Use `SafeAutoCorrect` instead.'
|
160
|
+
},
|
161
|
+
{
|
162
|
+
cops: 'Bundler/GemComment',
|
163
|
+
parameters: 'Whitelist',
|
164
|
+
alternative: '`Whitelist` has been renamed to `IgnoredGems`.'
|
165
|
+
},
|
166
|
+
{
|
167
|
+
cops: %w[
|
168
|
+
Lint/SafeNavigationChain Lint/SafeNavigationConsistency
|
169
|
+
Style/NestedParenthesizedCalls Style/SafeNavigation
|
170
|
+
Style/TrivialAccessors
|
171
|
+
],
|
172
|
+
parameters: 'Whitelist',
|
173
|
+
alternative: '`Whitelist` has been renamed to `AllowedMethods`.'
|
174
|
+
},
|
175
|
+
{
|
176
|
+
cops: 'Style/IpAddresses',
|
177
|
+
parameters: 'Whitelist',
|
178
|
+
alternative: '`Whitelist` has been renamed to `AllowedAddresses`.'
|
179
|
+
},
|
180
|
+
{
|
181
|
+
cops: 'Naming/HeredocDelimiterNaming',
|
182
|
+
parameters: 'Blacklist',
|
183
|
+
alternative: '`Blacklist` has been renamed to `ForbiddenDelimiters`.'
|
184
|
+
},
|
185
|
+
{
|
186
|
+
cops: 'Naming/PredicateName',
|
187
|
+
parameters: 'NamePrefixBlacklist',
|
188
|
+
alternative: '`NamePrefixBlacklist` has been renamed to ' \
|
189
|
+
'`ForbiddenPrefixes`.'
|
190
|
+
},
|
191
|
+
{
|
192
|
+
cops: 'Naming/PredicateName',
|
193
|
+
parameters: 'NameWhitelist',
|
194
|
+
alternative: '`NameWhitelist` has been renamed to ' \
|
195
|
+
'`AllowedMethods`.'
|
143
196
|
}
|
144
197
|
].freeze
|
145
198
|
|