rubocop 0.86.0 → 0.87.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +46 -4
  4. data/lib/rubocop.rb +8 -1
  5. data/lib/rubocop/cli.rb +0 -2
  6. data/lib/rubocop/cli/command/auto_genenerate_config.rb +40 -5
  7. data/lib/rubocop/cli/command/show_cops.rb +1 -1
  8. data/lib/rubocop/config_loader.rb +21 -62
  9. data/lib/rubocop/config_obsoletion.rb +0 -1
  10. data/lib/rubocop/cop/autocorrect_logic.rb +13 -23
  11. data/lib/rubocop/cop/base.rb +399 -0
  12. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +10 -20
  13. data/lib/rubocop/cop/commissioner.rb +48 -50
  14. data/lib/rubocop/cop/cop.rb +85 -236
  15. data/lib/rubocop/cop/corrector.rb +38 -115
  16. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +1 -1
  17. data/lib/rubocop/cop/generator.rb +1 -1
  18. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +11 -14
  19. data/lib/rubocop/cop/layout/case_indentation.rb +18 -19
  20. data/lib/rubocop/cop/layout/class_structure.rb +2 -37
  21. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +1 -8
  22. data/lib/rubocop/cop/layout/first_argument_indentation.rb +4 -0
  23. data/lib/rubocop/cop/layout/hash_alignment.rb +1 -2
  24. data/lib/rubocop/cop/layout/multiline_block_layout.rb +0 -1
  25. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +19 -25
  26. data/lib/rubocop/cop/legacy/corrections_proxy.rb +49 -0
  27. data/lib/rubocop/cop/legacy/corrector.rb +29 -0
  28. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +4 -4
  29. data/lib/rubocop/cop/lint/interpolation_check.rb +13 -0
  30. data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
  31. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +2 -2
  32. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +8 -3
  33. data/lib/rubocop/cop/lint/rand_one.rb +1 -1
  34. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +27 -23
  35. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +2 -2
  36. data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +8 -0
  37. data/lib/rubocop/cop/lint/syntax.rb +11 -26
  38. data/lib/rubocop/cop/lint/unused_method_argument.rb +1 -1
  39. data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -1
  40. data/lib/rubocop/cop/metrics/block_length.rb +22 -0
  41. data/lib/rubocop/cop/metrics/class_length.rb +25 -2
  42. data/lib/rubocop/cop/metrics/method_length.rb +23 -0
  43. data/lib/rubocop/cop/metrics/module_length.rb +25 -2
  44. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +129 -0
  45. data/lib/rubocop/cop/mixin/allowed_methods.rb +19 -0
  46. data/lib/rubocop/cop/mixin/auto_corrector.rb +12 -0
  47. data/lib/rubocop/cop/mixin/code_length.rb +4 -0
  48. data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -1
  49. data/lib/rubocop/cop/mixin/enforce_superclass.rb +3 -1
  50. data/lib/rubocop/cop/mixin/nil_methods.rb +3 -5
  51. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +6 -1
  52. data/lib/rubocop/cop/mixin/surrounding_space.rb +7 -2
  53. data/lib/rubocop/cop/mixin/too_many_lines.rb +3 -13
  54. data/lib/rubocop/cop/mixin/uncommunicative_name.rb +4 -2
  55. data/lib/rubocop/cop/mixin/visibility_help.rb +50 -0
  56. data/lib/rubocop/cop/naming/ascii_identifiers.rb +27 -4
  57. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +2 -2
  58. data/lib/rubocop/cop/naming/method_name.rb +1 -1
  59. data/lib/rubocop/cop/naming/method_parameter_name.rb +1 -1
  60. data/lib/rubocop/cop/naming/predicate_name.rb +3 -5
  61. data/lib/rubocop/cop/naming/variable_name.rb +1 -1
  62. data/lib/rubocop/cop/naming/variable_number.rb +1 -1
  63. data/lib/rubocop/cop/offense.rb +16 -2
  64. data/lib/rubocop/cop/style/accessor_grouping.rb +140 -0
  65. data/lib/rubocop/cop/style/bisected_attr_accessor.rb +145 -0
  66. data/lib/rubocop/cop/style/class_vars.rb +21 -0
  67. data/lib/rubocop/cop/style/date_time.rb +1 -1
  68. data/lib/rubocop/cop/style/dir.rb +2 -2
  69. data/lib/rubocop/cop/style/empty_literal.rb +5 -5
  70. data/lib/rubocop/cop/style/expand_path_arguments.rb +2 -2
  71. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +12 -0
  72. data/lib/rubocop/cop/style/multiline_block_chain.rb +10 -1
  73. data/lib/rubocop/cop/style/mutable_constant.rb +4 -4
  74. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +2 -5
  75. data/lib/rubocop/cop/style/proc.rb +1 -1
  76. data/lib/rubocop/cop/style/random_with_offset.rb +4 -10
  77. data/lib/rubocop/cop/style/redundant_assignment.rb +117 -0
  78. data/lib/rubocop/cop/style/redundant_exception.rb +14 -10
  79. data/lib/rubocop/cop/style/redundant_fetch_block.rb +26 -7
  80. data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
  81. data/lib/rubocop/cop/style/redundant_parentheses.rb +7 -1
  82. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +2 -1
  83. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +2 -2
  84. data/lib/rubocop/cop/style/rescue_standard_error.rb +1 -1
  85. data/lib/rubocop/cop/style/signal_exception.rb +1 -1
  86. data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
  87. data/lib/rubocop/cop/style/struct_inheritance.rb +2 -2
  88. data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
  89. data/lib/rubocop/cop/style/trivial_accessors.rb +8 -7
  90. data/lib/rubocop/cop/style/zero_length_predicate.rb +2 -2
  91. data/lib/rubocop/cop/team.rb +97 -81
  92. data/lib/rubocop/cop/utils/format_string.rb +1 -2
  93. data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
  94. data/lib/rubocop/name_similarity.rb +1 -3
  95. data/lib/rubocop/options.rb +15 -8
  96. data/lib/rubocop/rake_task.rb +6 -9
  97. data/lib/rubocop/rspec/cop_helper.rb +4 -4
  98. data/lib/rubocop/rspec/expect_offense.rb +22 -17
  99. data/lib/rubocop/rspec/shared_contexts.rb +7 -7
  100. data/lib/rubocop/runner.rb +31 -29
  101. data/lib/rubocop/target_ruby.rb +1 -1
  102. data/lib/rubocop/version.rb +1 -1
  103. metadata +16 -7
  104. data/lib/rubocop/cop/mixin/classish_length.rb +0 -37
@@ -8,14 +8,11 @@ module RuboCop
8
8
  #
9
9
  # require 'rubocop/rake_task'
10
10
  # RuboCop::RakeTask.new
11
- class RakeTask < Rake::TaskLib
12
- attr_accessor :name
13
- attr_accessor :verbose
14
- attr_accessor :fail_on_error
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
- corrector =
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.inspect_file(processed_source)
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(cop.offenses)
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
- corrector =
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 cop.corrections.empty?
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 cop.corrections.empty?
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
- corrector =
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(cop.offenses)
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*\^+ /.freeze
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
- if described_class.is_a?(Class) && described_class < RuboCop::Cop::Cop
49
- described_class
50
- else
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
- .tap { |cop| cop.processed_source = processed_source }
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
 
@@ -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
- if check_for_redundant_disables?(source)
155
- redundant_cop_disable_directive(file) do |cop|
156
- cop.check(offenses, source.disabled_line_ranges, source.comments)
157
- offenses += cop.offenses
158
- offenses += autocorrect_redundant_disables(file, source, cop,
159
- offenses)
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
- offenses.sort.reject(&:disabled?).freeze
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
- config = @config_store.for_file(processed_source.path)
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)
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # The kind of Ruby that code inspected by RuboCop is written in.
5
5
  class TargetRuby
6
- KNOWN_RUBIES = [2.4, 2.5, 2.6, 2.7].freeze
6
+ KNOWN_RUBIES = [2.4, 2.5, 2.6, 2.7, 2.8].freeze
7
7
  DEFAULT_VERSION = KNOWN_RUBIES.first
8
8
 
9
9
  OBSOLETE_RUBIES = {
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.86.0'
6
+ STRING = '0.87.1'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, '\
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
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.86.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-06-22 00:00:00.000000000 Z
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.0.1
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.0.1
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.3
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.3
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