rubocop 0.81.0 → 0.82.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/config/default.yml +59 -13
  4. data/lib/rubocop.rb +4 -2
  5. data/lib/rubocop/ast/node.rb +1 -1
  6. data/lib/rubocop/ast/node/array_node.rb +13 -0
  7. data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +8 -0
  8. data/lib/rubocop/cli.rb +10 -4
  9. data/lib/rubocop/config.rb +9 -1
  10. data/lib/rubocop/config_loader.rb +24 -15
  11. data/lib/rubocop/config_loader_resolver.rb +1 -1
  12. data/lib/rubocop/config_obsoletion.rb +1 -0
  13. data/lib/rubocop/config_validator.rb +16 -0
  14. data/lib/rubocop/cop/badge.rb +5 -5
  15. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -1
  16. data/lib/rubocop/cop/corrector.rb +48 -24
  17. data/lib/rubocop/cop/correctors/alignment_corrector.rb +2 -2
  18. data/lib/rubocop/cop/correctors/condition_corrector.rb +1 -2
  19. data/lib/rubocop/cop/correctors/empty_line_corrector.rb +1 -1
  20. data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +3 -3
  21. data/lib/rubocop/cop/correctors/line_break_corrector.rb +2 -2
  22. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
  23. data/lib/rubocop/cop/correctors/string_literal_corrector.rb +2 -2
  24. data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +1 -1
  25. data/lib/rubocop/cop/layout/dot_position.rb +1 -1
  26. data/lib/rubocop/cop/layout/end_of_line.rb +2 -2
  27. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +16 -10
  28. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +1 -1
  29. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
  30. data/lib/rubocop/cop/layout/heredoc_indentation.rb +2 -2
  31. data/lib/rubocop/cop/layout/{tab.rb → indentation_style.rb} +48 -6
  32. data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
  33. data/lib/rubocop/cop/layout/line_length.rb +2 -2
  34. data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -1
  35. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +3 -3
  36. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +133 -0
  37. data/lib/rubocop/cop/layout/space_around_operators.rb +1 -1
  38. data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +1 -1
  39. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +2 -2
  40. data/lib/rubocop/cop/layout/space_inside_range_literal.rb +2 -2
  41. data/lib/rubocop/cop/lint/boolean_symbol.rb +2 -2
  42. data/lib/rubocop/cop/lint/debugger.rb +1 -1
  43. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
  44. data/lib/rubocop/cop/lint/inherit_exception.rb +1 -1
  45. data/lib/rubocop/cop/lint/interpolation_check.rb +1 -1
  46. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
  47. data/lib/rubocop/cop/lint/multiple_comparison.rb +1 -1
  48. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +2 -2
  49. data/lib/rubocop/cop/lint/number_conversion.rb +1 -1
  50. data/lib/rubocop/cop/lint/percent_string_array.rb +2 -2
  51. data/lib/rubocop/cop/lint/raise_exception.rb +42 -6
  52. data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -1
  53. data/lib/rubocop/cop/lint/unified_integer.rb +0 -2
  54. data/lib/rubocop/cop/lint/uri_regexp.rb +4 -4
  55. data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -1
  56. data/lib/rubocop/cop/mixin/line_length_help.rb +1 -1
  57. data/lib/rubocop/cop/mixin/statement_modifier.rb +4 -3
  58. data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
  59. data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +1 -1
  60. data/lib/rubocop/cop/naming/constant_name.rb +2 -1
  61. data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +1 -1
  62. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -1
  63. data/lib/rubocop/cop/registry.rb +11 -4
  64. data/lib/rubocop/cop/style/alias.rb +4 -4
  65. data/lib/rubocop/cop/style/and_or.rb +5 -6
  66. data/lib/rubocop/cop/style/array_join.rb +1 -1
  67. data/lib/rubocop/cop/style/case_equality.rb +24 -1
  68. data/lib/rubocop/cop/style/character_literal.rb +2 -2
  69. data/lib/rubocop/cop/style/conditional_assignment.rb +8 -8
  70. data/lib/rubocop/cop/style/copyright.rb +1 -1
  71. data/lib/rubocop/cop/style/dir.rb +1 -1
  72. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +49 -0
  73. data/lib/rubocop/cop/style/double_cop_disable_directive.rb +1 -1
  74. data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
  75. data/lib/rubocop/cop/style/each_with_object.rb +3 -3
  76. data/lib/rubocop/cop/style/empty_method.rb +1 -1
  77. data/lib/rubocop/cop/style/even_odd.rb +1 -1
  78. data/lib/rubocop/cop/style/expand_path_arguments.rb +3 -3
  79. data/lib/rubocop/cop/style/exponential_notation.rb +119 -0
  80. data/lib/rubocop/cop/style/format_string.rb +2 -2
  81. data/lib/rubocop/cop/style/hash_each_methods.rb +3 -3
  82. data/lib/rubocop/cop/style/hash_syntax.rb +3 -5
  83. data/lib/rubocop/cop/style/hash_transform_values.rb +0 -3
  84. data/lib/rubocop/cop/style/if_unless_modifier.rb +23 -3
  85. data/lib/rubocop/cop/style/lambda.rb +2 -2
  86. data/lib/rubocop/cop/style/lambda_call.rb +2 -2
  87. data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
  88. data/lib/rubocop/cop/style/module_function.rb +2 -2
  89. data/lib/rubocop/cop/style/multiline_if_modifier.rb +1 -1
  90. data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
  91. data/lib/rubocop/cop/style/mutable_constant.rb +2 -4
  92. data/lib/rubocop/cop/style/next.rb +2 -2
  93. data/lib/rubocop/cop/style/nil_comparison.rb +1 -1
  94. data/lib/rubocop/cop/style/non_nil_check.rb +4 -4
  95. data/lib/rubocop/cop/style/not.rb +1 -1
  96. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +1 -1
  97. data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
  98. data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
  99. data/lib/rubocop/cop/style/one_line_conditional.rb +1 -1
  100. data/lib/rubocop/cop/style/or_assignment.rb +1 -1
  101. data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
  102. data/lib/rubocop/cop/style/perl_backrefs.rb +2 -2
  103. data/lib/rubocop/cop/style/proc.rb +1 -1
  104. data/lib/rubocop/cop/style/raise_args.rb +1 -1
  105. data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
  106. data/lib/rubocop/cop/style/redundant_condition.rb +3 -4
  107. data/lib/rubocop/cop/style/redundant_conditional.rb +1 -1
  108. data/lib/rubocop/cop/style/redundant_exception.rb +3 -3
  109. data/lib/rubocop/cop/style/redundant_interpolation.rb +2 -2
  110. data/lib/rubocop/cop/style/redundant_percent_q.rb +2 -2
  111. data/lib/rubocop/cop/style/redundant_return.rb +5 -7
  112. data/lib/rubocop/cop/style/redundant_self.rb +1 -1
  113. data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
  114. data/lib/rubocop/cop/style/return_nil.rb +1 -1
  115. data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
  116. data/lib/rubocop/cop/style/self_assignment.rb +1 -1
  117. data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
  118. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +1 -4
  119. data/lib/rubocop/cop/style/string_hash_keys.rb +1 -1
  120. data/lib/rubocop/cop/style/symbol_array.rb +1 -1
  121. data/lib/rubocop/cop/style/symbol_literal.rb +2 -2
  122. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -2
  123. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +2 -1
  124. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +3 -0
  125. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  126. data/lib/rubocop/cop/style/unpack_first.rb +0 -4
  127. data/lib/rubocop/cop/style/variable_interpolation.rb +1 -1
  128. data/lib/rubocop/cop/style/while_until_modifier.rb +1 -1
  129. data/lib/rubocop/cop/style/word_array.rb +1 -1
  130. data/lib/rubocop/cop/style/zero_length_predicate.rb +1 -1
  131. data/lib/rubocop/formatter/formatter_set.rb +0 -1
  132. data/lib/rubocop/formatter/pacman_formatter.rb +1 -1
  133. data/lib/rubocop/options.rb +7 -1
  134. data/lib/rubocop/processed_source.rb +0 -3
  135. data/lib/rubocop/rspec/cop_helper.rb +1 -1
  136. data/lib/rubocop/rspec/expect_offense.rb +1 -1
  137. data/lib/rubocop/rspec/shared_contexts.rb +0 -4
  138. data/lib/rubocop/runner.rb +1 -1
  139. data/lib/rubocop/target_ruby.rb +2 -2
  140. data/lib/rubocop/version.rb +1 -1
  141. metadata +7 -5
  142. data/lib/rubocop/formatter/disabled_lines_formatter.rb +0 -57
@@ -69,7 +69,7 @@ module RuboCop
69
69
  regex = /#{Regexp.quote(PACMAN)}|#{Regexp.quote(PACDOT)}/
70
70
  @progress_line = @progress_line.sub(regex, character)
71
71
  output.printf("%<line>s\r", line: @progress_line)
72
- return unless @progress_line[-1] =~ /ᗣ|\./
72
+ return unless /ᗣ|\./.match?(@progress_line[-1])
73
73
 
74
74
  @repetitions += 1
75
75
  output.puts
@@ -154,6 +154,7 @@ module RuboCop
154
154
  end
155
155
  end
156
156
 
157
+ # rubocop:disable Metrics/MethodLength
157
158
  def add_boolean_flags(opts)
158
159
  option(opts, '-F', '--fail-fast')
159
160
  option(opts, '-C', '--cache FLAG')
@@ -162,6 +163,8 @@ module RuboCop
162
163
  option(opts, '-E', '--extra-details')
163
164
  option(opts, '-S', '--display-style-guide')
164
165
  option(opts, '-a', '--auto-correct')
166
+ option(opts, '--disable-pending-cops')
167
+ option(opts, '--enable-pending-cops')
165
168
  option(opts, '--ignore-disable-comments')
166
169
 
167
170
  option(opts, '--safe')
@@ -172,6 +175,7 @@ module RuboCop
172
175
  option(opts, '-V', '--verbose-version')
173
176
  option(opts, '-P', '--parallel')
174
177
  end
178
+ # rubocop:enable Metrics/MethodLength
175
179
 
176
180
  def add_aliases(opts)
177
181
  option(opts, '-l', '--lint') do
@@ -362,7 +366,7 @@ module RuboCop
362
366
  end
363
367
 
364
368
  def validate_exclude_limit_option
365
- return if @options[:exclude_limit] =~ /^\d+$/
369
+ return if /^\d+$/.match?(@options[:exclude_limit])
366
370
 
367
371
  # Emulate OptionParser's behavior to make failures consistent regardless
368
372
  # of option order.
@@ -438,7 +442,9 @@ module RuboCop
438
442
  debug: 'Display debug info.',
439
443
  display_cop_names: ['Display cop names in offense messages.',
440
444
  'Default is true.'],
445
+ disable_pending_cops: 'Run without pending cops.',
441
446
  display_style_guide: 'Display style guide URLs in offense messages.',
447
+ enable_pending_cops: 'Run with pending cops.',
442
448
  extra_details: 'Display extra details in offense messages.',
443
449
  lint: 'Run only lint cops.',
444
450
  safe: 'Run only safe cops.',
@@ -175,9 +175,6 @@ module RuboCop
175
175
  # rubocop:disable Metrics/MethodLength
176
176
  def parser_class(ruby_version)
177
177
  case ruby_version
178
- when 2.3
179
- require 'parser/ruby23'
180
- Parser::Ruby23
181
178
  when 2.4
182
179
  require 'parser/ruby24'
183
180
  Parser::Ruby24
@@ -6,7 +6,7 @@ require 'tempfile'
6
6
  module CopHelper
7
7
  extend RSpec::SharedContext
8
8
 
9
- let(:ruby_version) { 2.3 }
9
+ let(:ruby_version) { 2.4 }
10
10
  let(:rails_version) { false }
11
11
 
12
12
  def inspect_source_file(source)
@@ -153,7 +153,7 @@ module RuboCop
153
153
  annotations = []
154
154
 
155
155
  annotated_source.each_line do |source_line|
156
- if source_line =~ ANNOTATION_PATTERN
156
+ if ANNOTATION_PATTERN.match?(source_line)
157
157
  annotations << [source.size, source_line]
158
158
  else
159
159
  source << source_line
@@ -74,10 +74,6 @@ RSpec.shared_context 'mock console output' do
74
74
  end
75
75
  end
76
76
 
77
- RSpec.shared_context 'ruby 2.3', :ruby23 do
78
- let(:ruby_version) { 2.3 }
79
- end
80
-
81
77
  RSpec.shared_context 'ruby 2.4', :ruby24 do
82
78
  let(:ruby_version) { 2.4 }
83
79
  end
@@ -314,7 +314,7 @@ module RuboCop
314
314
 
315
315
  cop_classes.reject! { |c| c.match?(@options[:except]) }
316
316
 
317
- Cop::Registry.new(cop_classes)
317
+ Cop::Registry.new(cop_classes, @options)
318
318
  end
319
319
  end
320
320
 
@@ -3,11 +3,11 @@
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.3, 2.4, 2.5, 2.6, 2.7].freeze
6
+ KNOWN_RUBIES = [2.4, 2.5, 2.6, 2.7].freeze
7
7
  DEFAULT_VERSION = KNOWN_RUBIES.first
8
8
 
9
9
  OBSOLETE_RUBIES = {
10
- 1.9 => '0.50', 2.0 => '0.50', 2.1 => '0.58', 2.2 => '0.69'
10
+ 1.9 => '0.50', 2.0 => '0.50', 2.1 => '0.58', 2.2 => '0.69', 2.3 => '0.82'
11
11
  }.freeze
12
12
  private_constant :KNOWN_RUBIES, :OBSOLETE_RUBIES
13
13
 
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.81.0'
6
+ STRING = '0.82.0'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, running on ' \
9
9
  '%<ruby_engine>s %<ruby_version>s %<ruby_platform>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.81.0
4
+ version: 0.82.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: 2020-04-01 00:00:00.000000000 Z
13
+ date: 2020-04-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jaro_winkler
@@ -314,6 +314,7 @@ files:
314
314
  - lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb
315
315
  - lib/rubocop/cop/layout/heredoc_indentation.rb
316
316
  - lib/rubocop/cop/layout/indentation_consistency.rb
317
+ - lib/rubocop/cop/layout/indentation_style.rb
317
318
  - lib/rubocop/cop/layout/indentation_width.rb
318
319
  - lib/rubocop/cop/layout/initial_indentation.rb
319
320
  - lib/rubocop/cop/layout/leading_comment_space.rb
@@ -340,6 +341,7 @@ files:
340
341
  - lib/rubocop/cop/layout/space_around_block_parameters.rb
341
342
  - lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb
342
343
  - lib/rubocop/cop/layout/space_around_keyword.rb
344
+ - lib/rubocop/cop/layout/space_around_method_call_operator.rb
343
345
  - lib/rubocop/cop/layout/space_around_operators.rb
344
346
  - lib/rubocop/cop/layout/space_before_block_braces.rb
345
347
  - lib/rubocop/cop/layout/space_before_comma.rb
@@ -356,7 +358,6 @@ files:
356
358
  - lib/rubocop/cop/layout/space_inside_range_literal.rb
357
359
  - lib/rubocop/cop/layout/space_inside_reference_brackets.rb
358
360
  - lib/rubocop/cop/layout/space_inside_string_interpolation.rb
359
- - lib/rubocop/cop/layout/tab.rb
360
361
  - lib/rubocop/cop/layout/trailing_empty_lines.rb
361
362
  - lib/rubocop/cop/layout/trailing_whitespace.rb
362
363
  - lib/rubocop/cop/lint/ambiguous_block_association.rb
@@ -571,6 +572,7 @@ files:
571
572
  - lib/rubocop/cop/style/date_time.rb
572
573
  - lib/rubocop/cop/style/def_with_parentheses.rb
573
574
  - lib/rubocop/cop/style/dir.rb
575
+ - lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb
574
576
  - lib/rubocop/cop/style/documentation.rb
575
577
  - lib/rubocop/cop/style/documentation_method.rb
576
578
  - lib/rubocop/cop/style/double_cop_disable_directive.rb
@@ -588,6 +590,7 @@ files:
588
590
  - lib/rubocop/cop/style/eval_with_location.rb
589
591
  - lib/rubocop/cop/style/even_odd.rb
590
592
  - lib/rubocop/cop/style/expand_path_arguments.rb
593
+ - lib/rubocop/cop/style/exponential_notation.rb
591
594
  - lib/rubocop/cop/style/float_division.rb
592
595
  - lib/rubocop/cop/style/for.rb
593
596
  - lib/rubocop/cop/style/format_string.rb
@@ -736,7 +739,6 @@ files:
736
739
  - lib/rubocop/formatter/clang_style_formatter.rb
737
740
  - lib/rubocop/formatter/colorizable.rb
738
741
  - lib/rubocop/formatter/disabled_config_formatter.rb
739
- - lib/rubocop/formatter/disabled_lines_formatter.rb
740
742
  - lib/rubocop/formatter/emacs_style_formatter.rb
741
743
  - lib/rubocop/formatter/file_list_formatter.rb
742
744
  - lib/rubocop/formatter/formatter_set.rb
@@ -793,7 +795,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
793
795
  requirements:
794
796
  - - ">="
795
797
  - !ruby/object:Gem::Version
796
- version: 2.3.0
798
+ version: 2.4.0
797
799
  required_rubygems_version: !ruby/object:Gem::Requirement
798
800
  requirements:
799
801
  - - ">="
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Formatter
5
- # A basic formatter that displays the lines disabled
6
- # inline comments.
7
- class DisabledLinesFormatter < BaseFormatter
8
- include PathUtil
9
- include Colorizable
10
-
11
- attr_reader :cop_disabled_line_ranges
12
-
13
- def started(_target_files)
14
- @cop_disabled_line_ranges = {}
15
- end
16
-
17
- def file_started(file, options)
18
- return unless options[:cop_disabled_line_ranges]
19
-
20
- @cop_disabled_line_ranges[file] =
21
- options[:cop_disabled_line_ranges]
22
- end
23
-
24
- def finished(_inspected_files)
25
- cops_disabled_in_comments_summary
26
- end
27
-
28
- private
29
-
30
- def cops_disabled_in_comments_summary
31
- summary = "\nCops disabled line ranges:\n\n"
32
-
33
- @cop_disabled_line_ranges.each do |file, disabled_cops|
34
- disabled_cops.each do |cop, line_ranges|
35
- line_ranges.each do |line_range|
36
- file = cyan(smart_path(file))
37
- summary += "#{file}:#{line_range}: #{cop}\n"
38
- end
39
- end
40
- end
41
-
42
- output.puts summary
43
- end
44
-
45
- def smart_path(path)
46
- # Ideally, we calculate this relative to the project root.
47
- base_dir = Dir.pwd
48
-
49
- if path.start_with? base_dir
50
- relative_path(path, base_dir)
51
- else
52
- path
53
- end
54
- end
55
- end
56
- end
57
- end