rubocop 0.86.0 → 0.87.1
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 +46 -4
- data/lib/rubocop.rb +8 -1
- data/lib/rubocop/cli.rb +0 -2
- data/lib/rubocop/cli/command/auto_genenerate_config.rb +40 -5
- data/lib/rubocop/cli/command/show_cops.rb +1 -1
- data/lib/rubocop/config_loader.rb +21 -62
- data/lib/rubocop/config_obsoletion.rb +0 -1
- data/lib/rubocop/cop/autocorrect_logic.rb +13 -23
- data/lib/rubocop/cop/base.rb +399 -0
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +10 -20
- data/lib/rubocop/cop/commissioner.rb +48 -50
- data/lib/rubocop/cop/cop.rb +85 -236
- data/lib/rubocop/cop/corrector.rb +38 -115
- data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +1 -1
- data/lib/rubocop/cop/generator.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +11 -14
- data/lib/rubocop/cop/layout/case_indentation.rb +18 -19
- data/lib/rubocop/cop/layout/class_structure.rb +2 -37
- data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +1 -8
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +4 -0
- data/lib/rubocop/cop/layout/hash_alignment.rb +1 -2
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +0 -1
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +19 -25
- data/lib/rubocop/cop/legacy/corrections_proxy.rb +49 -0
- data/lib/rubocop/cop/legacy/corrector.rb +29 -0
- data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +4 -4
- data/lib/rubocop/cop/lint/interpolation_check.rb +13 -0
- data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +2 -2
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +8 -3
- data/lib/rubocop/cop/lint/rand_one.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +27 -23
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +2 -2
- data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +8 -0
- data/lib/rubocop/cop/lint/syntax.rb +11 -26
- data/lib/rubocop/cop/lint/unused_method_argument.rb +1 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -1
- data/lib/rubocop/cop/metrics/block_length.rb +22 -0
- data/lib/rubocop/cop/metrics/class_length.rb +25 -2
- data/lib/rubocop/cop/metrics/method_length.rb +23 -0
- data/lib/rubocop/cop/metrics/module_length.rb +25 -2
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +129 -0
- data/lib/rubocop/cop/mixin/allowed_methods.rb +19 -0
- data/lib/rubocop/cop/mixin/auto_corrector.rb +12 -0
- data/lib/rubocop/cop/mixin/code_length.rb +4 -0
- data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -1
- data/lib/rubocop/cop/mixin/enforce_superclass.rb +3 -1
- data/lib/rubocop/cop/mixin/nil_methods.rb +3 -5
- data/lib/rubocop/cop/mixin/ordered_gem_node.rb +6 -1
- data/lib/rubocop/cop/mixin/surrounding_space.rb +7 -2
- data/lib/rubocop/cop/mixin/too_many_lines.rb +3 -13
- data/lib/rubocop/cop/mixin/uncommunicative_name.rb +4 -2
- data/lib/rubocop/cop/mixin/visibility_help.rb +50 -0
- data/lib/rubocop/cop/naming/ascii_identifiers.rb +27 -4
- data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +2 -2
- data/lib/rubocop/cop/naming/method_name.rb +1 -1
- data/lib/rubocop/cop/naming/method_parameter_name.rb +1 -1
- data/lib/rubocop/cop/naming/predicate_name.rb +3 -5
- data/lib/rubocop/cop/naming/variable_name.rb +1 -1
- data/lib/rubocop/cop/naming/variable_number.rb +1 -1
- data/lib/rubocop/cop/offense.rb +16 -2
- data/lib/rubocop/cop/style/accessor_grouping.rb +140 -0
- data/lib/rubocop/cop/style/bisected_attr_accessor.rb +145 -0
- data/lib/rubocop/cop/style/class_vars.rb +21 -0
- data/lib/rubocop/cop/style/date_time.rb +1 -1
- data/lib/rubocop/cop/style/dir.rb +2 -2
- data/lib/rubocop/cop/style/empty_literal.rb +5 -5
- data/lib/rubocop/cop/style/expand_path_arguments.rb +2 -2
- data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +12 -0
- data/lib/rubocop/cop/style/multiline_block_chain.rb +10 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +4 -4
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +2 -5
- data/lib/rubocop/cop/style/proc.rb +1 -1
- data/lib/rubocop/cop/style/random_with_offset.rb +4 -10
- data/lib/rubocop/cop/style/redundant_assignment.rb +117 -0
- data/lib/rubocop/cop/style/redundant_exception.rb +14 -10
- data/lib/rubocop/cop/style/redundant_fetch_block.rb +26 -7
- data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +7 -1
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +2 -1
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +2 -2
- data/lib/rubocop/cop/style/rescue_standard_error.rb +1 -1
- data/lib/rubocop/cop/style/signal_exception.rb +1 -1
- data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
- data/lib/rubocop/cop/style/struct_inheritance.rb +2 -2
- data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
- data/lib/rubocop/cop/style/trivial_accessors.rb +8 -7
- data/lib/rubocop/cop/style/zero_length_predicate.rb +2 -2
- data/lib/rubocop/cop/team.rb +97 -81
- data/lib/rubocop/cop/utils/format_string.rb +1 -2
- data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
- data/lib/rubocop/name_similarity.rb +1 -3
- data/lib/rubocop/options.rb +15 -8
- data/lib/rubocop/rake_task.rb +6 -9
- data/lib/rubocop/rspec/cop_helper.rb +4 -4
- data/lib/rubocop/rspec/expect_offense.rb +22 -17
- data/lib/rubocop/rspec/shared_contexts.rb +7 -7
- data/lib/rubocop/runner.rb +31 -29
- data/lib/rubocop/target_ruby.rb +1 -1
- data/lib/rubocop/version.rb +1 -1
- metadata +16 -7
- data/lib/rubocop/cop/mixin/classish_length.rb +0 -37
data/lib/rubocop/rake_task.rb
CHANGED
@@ -8,14 +8,11 @@ module RuboCop
|
|
8
8
|
#
|
9
9
|
# require 'rubocop/rake_task'
|
10
10
|
# RuboCop::RakeTask.new
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
attr_accessor :patterns
|
16
|
-
attr_accessor :formatters
|
17
|
-
attr_accessor :requires
|
18
|
-
attr_accessor :options
|
11
|
+
#
|
12
|
+
# Use global Rake namespace here to avoid namespace issues with custom
|
13
|
+
# rubocop-rake tasks
|
14
|
+
class RakeTask < ::Rake::TaskLib
|
15
|
+
attr_accessor :name, :verbose, :fail_on_error, :patterns, :formatters, :requires, :options
|
19
16
|
|
20
17
|
def initialize(name = :rubocop, *args, &task_block)
|
21
18
|
setup_ivars(name)
|
@@ -69,7 +66,7 @@ module RuboCop
|
|
69
66
|
task(:auto_correct, *args) do |_, task_args|
|
70
67
|
RakeFileUtils.verbose(verbose) do
|
71
68
|
yield(*[self, task_args].slice(0, task_block.arity)) if block_given?
|
72
|
-
options = full_options.unshift('--auto-correct')
|
69
|
+
options = full_options.unshift('--auto-correct-all')
|
73
70
|
options.delete('--parallel')
|
74
71
|
run_cli(verbose, options)
|
75
72
|
end
|
@@ -43,14 +43,14 @@ module CopHelper
|
|
43
43
|
processed_source = parse_source(source, file)
|
44
44
|
_investigate(cop, processed_source)
|
45
45
|
|
46
|
-
|
47
|
-
RuboCop::Cop::Corrector.new(processed_source.buffer, cop.corrections)
|
48
|
-
corrector.rewrite
|
46
|
+
@last_corrector.rewrite
|
49
47
|
end
|
50
48
|
|
51
49
|
def _investigate(cop, processed_source)
|
52
50
|
team = RuboCop::Cop::Team.new([cop], nil, raise_error: true)
|
53
|
-
team.
|
51
|
+
report = team.investigate(processed_source)
|
52
|
+
@last_corrector = report.correctors.first || RuboCop::Cop::Corrector.new(processed_source)
|
53
|
+
report.offenses
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -89,6 +89,16 @@ module RuboCop
|
|
89
89
|
# end
|
90
90
|
# RUBY
|
91
91
|
# end
|
92
|
+
#
|
93
|
+
# If you need to specify an offense on a blank line, use the empty `^{}` marker:
|
94
|
+
#
|
95
|
+
# @example `^{}` empty line offense
|
96
|
+
#
|
97
|
+
# expect_offense(<<~RUBY)
|
98
|
+
#
|
99
|
+
# ^{} Missing frozen string literal comment.
|
100
|
+
# puts 1
|
101
|
+
# RUBY
|
92
102
|
module ExpectOffense
|
93
103
|
def format_offense(source, **replacements)
|
94
104
|
replacements.each do |keyword, value|
|
@@ -100,7 +110,7 @@ module RuboCop
|
|
100
110
|
end
|
101
111
|
|
102
112
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
103
|
-
def expect_offense(source, file = nil, **replacements)
|
113
|
+
def expect_offense(source, file = nil, severity: nil, **replacements)
|
104
114
|
source = format_offense(source, **replacements)
|
105
115
|
RuboCop::Formatter::DisabledConfigFormatter
|
106
116
|
.config_to_allow_offenses = {}
|
@@ -118,11 +128,12 @@ module RuboCop
|
|
118
128
|
|
119
129
|
raise 'Error parsing example code' unless @processed_source.valid_syntax?
|
120
130
|
|
121
|
-
_investigate(cop, @processed_source)
|
131
|
+
offenses = _investigate(cop, @processed_source)
|
122
132
|
actual_annotations =
|
123
|
-
expected_annotations.with_offense_annotations(
|
133
|
+
expected_annotations.with_offense_annotations(offenses)
|
124
134
|
|
125
135
|
expect(actual_annotations.to_s).to eq(expected_annotations.to_s)
|
136
|
+
expect(offenses.map(&:severity).uniq).to eq([severity]) if severity
|
126
137
|
end
|
127
138
|
|
128
139
|
def expect_correction(correction, loop: true)
|
@@ -132,12 +143,10 @@ module RuboCop
|
|
132
143
|
new_source = loop do
|
133
144
|
iteration += 1
|
134
145
|
|
135
|
-
|
136
|
-
RuboCop::Cop::Corrector.new(@processed_source.buffer, cop.corrections)
|
137
|
-
corrected_source = corrector.rewrite
|
146
|
+
corrected_source = @last_corrector.rewrite
|
138
147
|
|
139
148
|
break corrected_source unless loop
|
140
|
-
break corrected_source if
|
149
|
+
break corrected_source if @last_corrector.empty?
|
141
150
|
break corrected_source if corrected_source == @processed_source.buffer.source
|
142
151
|
|
143
152
|
if iteration > RuboCop::Runner::MAX_ITERATIONS
|
@@ -145,9 +154,6 @@ module RuboCop
|
|
145
154
|
end
|
146
155
|
|
147
156
|
# Prepare for next loop
|
148
|
-
cop.instance_variable_set(:@corrections, [])
|
149
|
-
# Cache invalidation. This is bad!
|
150
|
-
cop.instance_variable_set(:@token_table, nil)
|
151
157
|
@processed_source = parse_source(corrected_source,
|
152
158
|
@processed_source.path)
|
153
159
|
_investigate(cop, @processed_source)
|
@@ -160,30 +166,28 @@ module RuboCop
|
|
160
166
|
def expect_no_corrections
|
161
167
|
raise '`expect_no_corrections` must follow `expect_offense`' unless @processed_source
|
162
168
|
|
163
|
-
return if
|
169
|
+
return if @last_corrector.empty?
|
164
170
|
|
165
171
|
# In order to print a nice diff, e.g. what source got corrected to,
|
166
172
|
# we need to run the actual corrections
|
167
173
|
|
168
|
-
|
169
|
-
RuboCop::Cop::Corrector.new(@processed_source.buffer, cop.corrections)
|
170
|
-
new_source = corrector.rewrite
|
174
|
+
new_source = @last_corrector.rewrite
|
171
175
|
|
172
176
|
expect(new_source).to eq(@processed_source.buffer.source)
|
173
177
|
end
|
174
178
|
|
175
179
|
def expect_no_offenses(source, file = nil)
|
176
|
-
inspect_source(source, file)
|
180
|
+
offenses = inspect_source(source, file)
|
177
181
|
|
178
182
|
expected_annotations = AnnotatedSource.parse(source)
|
179
183
|
actual_annotations =
|
180
|
-
expected_annotations.with_offense_annotations(
|
184
|
+
expected_annotations.with_offense_annotations(offenses)
|
181
185
|
expect(actual_annotations.to_s).to eq(source)
|
182
186
|
end
|
183
187
|
|
184
188
|
# Parsed representation of code annotated with the `^^^ Message` style
|
185
189
|
class AnnotatedSource
|
186
|
-
ANNOTATION_PATTERN = /\A\s
|
190
|
+
ANNOTATION_PATTERN = /\A\s*(\^+|\^{}) /.freeze
|
187
191
|
|
188
192
|
# @param annotated_source [String] string passed to the matchers
|
189
193
|
#
|
@@ -267,6 +271,7 @@ module RuboCop
|
|
267
271
|
offenses.map do |offense|
|
268
272
|
indent = ' ' * offense.column
|
269
273
|
carets = '^' * offense.column_length
|
274
|
+
carets = '^{}' if offense.column_length.zero?
|
270
275
|
|
271
276
|
[offense.line, "#{indent}#{carets} #{offense.message}\n"]
|
272
277
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'tmpdir'
|
4
|
-
require 'fileutils'
|
5
4
|
|
6
5
|
RSpec.shared_context 'isolated environment', :isolated_environment do
|
7
6
|
around do |example|
|
@@ -45,11 +44,11 @@ RSpec.shared_context 'config', :config do # rubocop:disable Metrics/BlockLength
|
|
45
44
|
let(:source) { 'code = {some: :ruby}' }
|
46
45
|
|
47
46
|
let(:cop_class) do
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
RuboCop::Cop::Cop
|
47
|
+
unless described_class.is_a?(Class) && described_class < RuboCop::Cop::Base
|
48
|
+
raise 'Specify which cop class to use (e.g `let(:cop_class) { RuboCop::Cop::Base }`, ' \
|
49
|
+
'or RuboCop::Cop::Cop for legacy)'
|
52
50
|
end
|
51
|
+
described_class
|
53
52
|
end
|
54
53
|
|
55
54
|
let(:cop_config) { {} }
|
@@ -95,8 +94,9 @@ RSpec.shared_context 'config', :config do # rubocop:disable Metrics/BlockLength
|
|
95
94
|
end
|
96
95
|
|
97
96
|
let(:cop) do
|
98
|
-
cop_class.new(config, cop_options)
|
99
|
-
|
97
|
+
cop_class.new(config, cop_options).tap do |cop|
|
98
|
+
cop.send :begin_investigation, processed_source
|
99
|
+
end
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
data/lib/rubocop/runner.rb
CHANGED
@@ -120,7 +120,8 @@ module RuboCop
|
|
120
120
|
file_offense_cache(file) do
|
121
121
|
source = get_processed_source(file)
|
122
122
|
source, offenses = do_inspection_loop(file, source)
|
123
|
-
add_redundant_disables(file, offenses.compact.sort, source)
|
123
|
+
offenses = add_redundant_disables(file, offenses.compact.sort, source)
|
124
|
+
offenses.sort.reject(&:disabled?).freeze
|
124
125
|
end
|
125
126
|
end
|
126
127
|
|
@@ -151,16 +152,30 @@ module RuboCop
|
|
151
152
|
end
|
152
153
|
|
153
154
|
def add_redundant_disables(file, offenses, source)
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
155
|
+
team_for_redundant_disables(file, offenses, source) do |team|
|
156
|
+
new_offenses, redundant_updated = inspect_file(source, team)
|
157
|
+
offenses += new_offenses
|
158
|
+
if redundant_updated
|
159
|
+
# Do one extra inspection loop if any redundant disables were
|
160
|
+
# removed. This is done in order to find rubocop:enable directives that
|
161
|
+
# have now become useless.
|
162
|
+
_source, new_offenses = do_inspection_loop(file,
|
163
|
+
get_processed_source(file))
|
164
|
+
offenses |= new_offenses
|
160
165
|
end
|
161
166
|
end
|
167
|
+
offenses
|
168
|
+
end
|
162
169
|
|
163
|
-
|
170
|
+
def team_for_redundant_disables(file, offenses, source)
|
171
|
+
return unless check_for_redundant_disables?(source)
|
172
|
+
|
173
|
+
config = @config_store.for_file(file)
|
174
|
+
team = Cop::Team.mobilize([Cop::Lint::RedundantCopDisableDirective], config, @options)
|
175
|
+
return if team.cops.empty?
|
176
|
+
|
177
|
+
team.cops.first.offenses_to_check = offenses
|
178
|
+
yield team
|
164
179
|
end
|
165
180
|
|
166
181
|
def check_for_redundant_disables?(source)
|
@@ -180,22 +195,6 @@ module RuboCop
|
|
180
195
|
@options[:except] || @options[:only]
|
181
196
|
end
|
182
197
|
|
183
|
-
def autocorrect_redundant_disables(file, source, cop, offenses)
|
184
|
-
cop.processed_source = source
|
185
|
-
|
186
|
-
team = Cop::Team.mobilize(RuboCop::Cop::Registry.new, nil, @options)
|
187
|
-
team.autocorrect(source.buffer, [cop])
|
188
|
-
|
189
|
-
return [] unless team.updated_source_file?
|
190
|
-
|
191
|
-
# Do one extra inspection loop if any redundant disables were
|
192
|
-
# removed. This is done in order to find rubocop:enable directives that
|
193
|
-
# have now become useless.
|
194
|
-
_source, new_offenses = do_inspection_loop(file,
|
195
|
-
get_processed_source(file))
|
196
|
-
new_offenses - offenses
|
197
|
-
end
|
198
|
-
|
199
198
|
def file_started(file)
|
200
199
|
puts "Scanning #{file}" if @options[:debug]
|
201
200
|
formatter_set.file_started(file,
|
@@ -293,13 +292,16 @@ module RuboCop
|
|
293
292
|
@processed_sources << checksum
|
294
293
|
end
|
295
294
|
|
296
|
-
def inspect_file(processed_source)
|
297
|
-
|
298
|
-
team = Cop::Team.mobilize(mobilized_cop_classes(config), config, @options)
|
299
|
-
offenses = team.inspect_file(processed_source)
|
295
|
+
def inspect_file(processed_source, team = mobilize_team(processed_source))
|
296
|
+
report = team.investigate(processed_source)
|
300
297
|
@errors.concat(team.errors)
|
301
298
|
@warnings.concat(team.warnings)
|
302
|
-
[offenses, team.updated_source_file?]
|
299
|
+
[report.offenses, team.updated_source_file?]
|
300
|
+
end
|
301
|
+
|
302
|
+
def mobilize_team(processed_source)
|
303
|
+
config = @config_store.for_file(processed_source.path)
|
304
|
+
Cop::Team.mobilize(mobilized_cop_classes(config), config, @options)
|
303
305
|
end
|
304
306
|
|
305
307
|
def mobilized_cop_classes(config)
|
data/lib/rubocop/target_ruby.rb
CHANGED
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: 0.
|
4
|
+
version: 0.87.1
|
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: 2020-
|
13
|
+
date: 2020-07-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parallel
|
@@ -32,14 +32,14 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 2.7.
|
35
|
+
version: 2.7.1.1
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 2.7.
|
42
|
+
version: 2.7.1.1
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: rainbow
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.0
|
97
|
+
version: 0.1.0
|
98
98
|
- - "<"
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '1.0'
|
@@ -104,7 +104,7 @@ dependencies:
|
|
104
104
|
requirements:
|
105
105
|
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version: 0.0
|
107
|
+
version: 0.1.0
|
108
108
|
- - "<"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.0'
|
@@ -202,6 +202,7 @@ files:
|
|
202
202
|
- lib/rubocop/config_validator.rb
|
203
203
|
- lib/rubocop/cop/autocorrect_logic.rb
|
204
204
|
- lib/rubocop/cop/badge.rb
|
205
|
+
- lib/rubocop/cop/base.rb
|
205
206
|
- lib/rubocop/cop/bundler/duplicated_gem.rb
|
206
207
|
- lib/rubocop/cop/bundler/gem_comment.rb
|
207
208
|
- lib/rubocop/cop/bundler/insecure_protocol_source.rb
|
@@ -331,6 +332,8 @@ files:
|
|
331
332
|
- lib/rubocop/cop/layout/space_inside_string_interpolation.rb
|
332
333
|
- lib/rubocop/cop/layout/trailing_empty_lines.rb
|
333
334
|
- lib/rubocop/cop/layout/trailing_whitespace.rb
|
335
|
+
- lib/rubocop/cop/legacy/corrections_proxy.rb
|
336
|
+
- lib/rubocop/cop/legacy/corrector.rb
|
334
337
|
- lib/rubocop/cop/lint/ambiguous_block_association.rb
|
335
338
|
- lib/rubocop/cop/lint/ambiguous_operator.rb
|
336
339
|
- lib/rubocop/cop/lint/ambiguous_regexp_literal.rb
|
@@ -428,15 +431,17 @@ files:
|
|
428
431
|
- lib/rubocop/cop/metrics/parameter_lists.rb
|
429
432
|
- lib/rubocop/cop/metrics/perceived_complexity.rb
|
430
433
|
- lib/rubocop/cop/metrics/utils/abc_size_calculator.rb
|
434
|
+
- lib/rubocop/cop/metrics/utils/code_length_calculator.rb
|
431
435
|
- lib/rubocop/cop/metrics/utils/iterating_block.rb
|
432
436
|
- lib/rubocop/cop/migration/department_name.rb
|
433
437
|
- lib/rubocop/cop/mixin/alignment.rb
|
438
|
+
- lib/rubocop/cop/mixin/allowed_methods.rb
|
434
439
|
- lib/rubocop/cop/mixin/annotation_comment.rb
|
435
440
|
- lib/rubocop/cop/mixin/array_min_size.rb
|
436
441
|
- lib/rubocop/cop/mixin/array_syntax.rb
|
442
|
+
- lib/rubocop/cop/mixin/auto_corrector.rb
|
437
443
|
- lib/rubocop/cop/mixin/check_assignment.rb
|
438
444
|
- lib/rubocop/cop/mixin/check_line_breakable.rb
|
439
|
-
- lib/rubocop/cop/mixin/classish_length.rb
|
440
445
|
- lib/rubocop/cop/mixin/code_length.rb
|
441
446
|
- lib/rubocop/cop/mixin/configurable_enforced_style.rb
|
442
447
|
- lib/rubocop/cop/mixin/configurable_formatting.rb
|
@@ -495,6 +500,7 @@ files:
|
|
495
500
|
- lib/rubocop/cop/mixin/trailing_comma.rb
|
496
501
|
- lib/rubocop/cop/mixin/uncommunicative_name.rb
|
497
502
|
- lib/rubocop/cop/mixin/unused_argument.rb
|
503
|
+
- lib/rubocop/cop/mixin/visibility_help.rb
|
498
504
|
- lib/rubocop/cop/naming/accessor_method_name.rb
|
499
505
|
- lib/rubocop/cop/naming/ascii_identifiers.rb
|
500
506
|
- lib/rubocop/cop/naming/binary_operator_parameter_name.rb
|
@@ -520,6 +526,7 @@ files:
|
|
520
526
|
- lib/rubocop/cop/security/yaml_load.rb
|
521
527
|
- lib/rubocop/cop/severity.rb
|
522
528
|
- lib/rubocop/cop/style/access_modifier_declarations.rb
|
529
|
+
- lib/rubocop/cop/style/accessor_grouping.rb
|
523
530
|
- lib/rubocop/cop/style/alias.rb
|
524
531
|
- lib/rubocop/cop/style/and_or.rb
|
525
532
|
- lib/rubocop/cop/style/array_join.rb
|
@@ -528,6 +535,7 @@ files:
|
|
528
535
|
- lib/rubocop/cop/style/auto_resource_cleanup.rb
|
529
536
|
- lib/rubocop/cop/style/bare_percent_literals.rb
|
530
537
|
- lib/rubocop/cop/style/begin_block.rb
|
538
|
+
- lib/rubocop/cop/style/bisected_attr_accessor.rb
|
531
539
|
- lib/rubocop/cop/style/block_comments.rb
|
532
540
|
- lib/rubocop/cop/style/block_delimiters.rb
|
533
541
|
- lib/rubocop/cop/style/case_equality.rb
|
@@ -639,6 +647,7 @@ files:
|
|
639
647
|
- lib/rubocop/cop/style/proc.rb
|
640
648
|
- lib/rubocop/cop/style/raise_args.rb
|
641
649
|
- lib/rubocop/cop/style/random_with_offset.rb
|
650
|
+
- lib/rubocop/cop/style/redundant_assignment.rb
|
642
651
|
- lib/rubocop/cop/style/redundant_begin.rb
|
643
652
|
- lib/rubocop/cop/style/redundant_capital_w.rb
|
644
653
|
- lib/rubocop/cop/style/redundant_condition.rb
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
# Common functionality for checking length of classes and modules.
|
6
|
-
module ClassishLength
|
7
|
-
include CodeLength
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def code_length(node)
|
12
|
-
body_line_numbers = line_range(node).to_a[1...-1]
|
13
|
-
|
14
|
-
target_line_numbers = body_line_numbers -
|
15
|
-
line_numbers_of_inner_nodes(node, :module, :class)
|
16
|
-
|
17
|
-
target_line_numbers.reduce(0) do |length, line_number|
|
18
|
-
source_line = processed_source[line_number]
|
19
|
-
next length if irrelevant_line(source_line)
|
20
|
-
|
21
|
-
length + 1
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def line_numbers_of_inner_nodes(node, *types)
|
26
|
-
line_numbers = Set.new
|
27
|
-
|
28
|
-
node.each_descendant(*types) do |inner_node|
|
29
|
-
line_range = line_range(inner_node)
|
30
|
-
line_numbers.merge(line_range)
|
31
|
-
end
|
32
|
-
|
33
|
-
line_numbers.to_a
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|