rubocop 0.74.0 → 0.75.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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/config/default.yml +28 -4
  4. data/lib/rubocop.rb +6 -1
  5. data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +1 -12
  6. data/lib/rubocop/comment_config.rb +3 -2
  7. data/lib/rubocop/config.rb +4 -0
  8. data/lib/rubocop/config_loader.rb +20 -2
  9. data/lib/rubocop/config_loader_resolver.rb +2 -2
  10. data/lib/rubocop/config_obsoletion.rb +12 -0
  11. data/lib/rubocop/cop/autocorrect_logic.rb +2 -2
  12. data/lib/rubocop/cop/cop.rb +4 -3
  13. data/lib/rubocop/cop/correctors/alignment_corrector.rb +43 -17
  14. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +2 -2
  15. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
  16. data/lib/rubocop/cop/generator.rb +3 -3
  17. data/lib/rubocop/cop/generator/configuration_injector.rb +9 -4
  18. data/lib/rubocop/cop/generator/require_file_injector.rb +1 -1
  19. data/lib/rubocop/cop/layout/block_alignment.rb +2 -2
  20. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +1 -1
  21. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +22 -7
  22. data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +2 -2
  23. data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +2 -2
  24. data/lib/rubocop/cop/layout/extra_spacing.rb +0 -6
  25. data/lib/rubocop/cop/layout/indent_assignment.rb +10 -1
  26. data/lib/rubocop/cop/layout/indent_heredoc.rb +1 -1
  27. data/lib/rubocop/cop/layout/multiline_block_layout.rb +24 -2
  28. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +5 -1
  29. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +1 -1
  30. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +7 -0
  31. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +2 -0
  32. data/lib/rubocop/cop/lint/assignment_in_condition.rb +17 -4
  33. data/lib/rubocop/cop/lint/debugger.rb +1 -1
  34. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +10 -36
  35. data/lib/rubocop/cop/lint/number_conversion.rb +1 -1
  36. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +91 -0
  37. data/lib/rubocop/cop/lint/unneeded_cop_disable_directive.rb +1 -1
  38. data/lib/rubocop/cop/lint/unused_block_argument.rb +22 -6
  39. data/lib/rubocop/cop/lint/unused_method_argument.rb +23 -5
  40. data/lib/rubocop/cop/lint/void.rb +3 -22
  41. data/lib/rubocop/cop/message_annotator.rb +16 -7
  42. data/lib/rubocop/cop/migration/department_name.rb +44 -0
  43. data/lib/rubocop/cop/mixin/alignment.rb +1 -1
  44. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
  45. data/lib/rubocop/cop/mixin/safe_mode.rb +2 -0
  46. data/lib/rubocop/cop/naming/method_name.rb +12 -1
  47. data/lib/rubocop/cop/naming/variable_name.rb +1 -0
  48. data/lib/rubocop/cop/offense.rb +18 -7
  49. data/lib/rubocop/cop/registry.rb +22 -1
  50. data/lib/rubocop/cop/style/access_modifier_declarations.rb +1 -0
  51. data/lib/rubocop/cop/style/block_delimiters.rb +2 -1
  52. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +29 -10
  53. data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
  54. data/lib/rubocop/cop/style/commented_keyword.rb +8 -2
  55. data/lib/rubocop/cop/style/conditional_assignment.rb +4 -4
  56. data/lib/rubocop/cop/style/documentation_method.rb +44 -0
  57. data/lib/rubocop/cop/style/double_cop_disable_directive.rb +8 -2
  58. data/lib/rubocop/cop/style/expand_path_arguments.rb +1 -1
  59. data/lib/rubocop/cop/style/format_string_token.rb +18 -69
  60. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +18 -33
  61. data/lib/rubocop/cop/style/if_unless_modifier.rb +51 -15
  62. data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
  63. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +25 -25
  64. data/lib/rubocop/cop/style/mixin_usage.rb +11 -1
  65. data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
  66. data/lib/rubocop/cop/style/nested_modifier.rb +18 -2
  67. data/lib/rubocop/cop/style/or_assignment.rb +6 -1
  68. data/lib/rubocop/cop/style/parentheses_around_condition.rb +14 -0
  69. data/lib/rubocop/cop/style/redundant_parentheses.rb +13 -4
  70. data/lib/rubocop/cop/style/redundant_return.rb +12 -0
  71. data/lib/rubocop/cop/style/redundant_self.rb +18 -1
  72. data/lib/rubocop/cop/style/rescue_modifier.rb +24 -0
  73. data/lib/rubocop/cop/style/safe_navigation.rb +17 -0
  74. data/lib/rubocop/cop/style/semicolon.rb +11 -0
  75. data/lib/rubocop/cop/style/single_line_methods.rb +8 -1
  76. data/lib/rubocop/cop/style/ternary_parentheses.rb +19 -0
  77. data/lib/rubocop/cop/utils/format_string.rb +128 -0
  78. data/lib/rubocop/cop/variable_force/variable.rb +15 -2
  79. data/lib/rubocop/core_ext/string.rb +0 -24
  80. data/lib/rubocop/formatter/clang_style_formatter.rb +8 -3
  81. data/lib/rubocop/formatter/emacs_style_formatter.rb +22 -9
  82. data/lib/rubocop/formatter/file_list_formatter.rb +1 -1
  83. data/lib/rubocop/formatter/formatter_set.rb +16 -15
  84. data/lib/rubocop/formatter/pacman_formatter.rb +80 -0
  85. data/lib/rubocop/formatter/simple_text_formatter.rb +16 -4
  86. data/lib/rubocop/formatter/tap_formatter.rb +17 -4
  87. data/lib/rubocop/magic_comment.rb +4 -0
  88. data/lib/rubocop/options.rb +5 -16
  89. data/lib/rubocop/runner.rb +14 -8
  90. data/lib/rubocop/version.rb +1 -1
  91. metadata +6 -3
  92. data/lib/rubocop/cop/mixin/ignored_method_patterns.rb +0 -19
@@ -42,9 +42,13 @@ module RuboCop
42
42
  output.puts yellow("== #{smart_path(file)} ==")
43
43
 
44
44
  offenses.each do |o|
45
- output.printf("%s:%3d:%3d: %s\n",
46
- colored_severity_code(o),
47
- o.line, o.real_column, message(o))
45
+ output.printf(
46
+ "%<severity>s:%3<line>d:%3<column>d: %<message>s\n",
47
+ severity: colored_severity_code(o),
48
+ line: o.line,
49
+ column: o.real_column,
50
+ message: message(o)
51
+ )
48
52
  end
49
53
  end
50
54
 
@@ -75,7 +79,15 @@ module RuboCop
75
79
  end
76
80
 
77
81
  def message(offense)
78
- message = offense.corrected? ? green('[Corrected] ') : ''
82
+ message =
83
+ if offense.corrected_with_todo?
84
+ green('[Todo] ')
85
+ elsif offense.corrected?
86
+ green('[Corrected] ')
87
+ else
88
+ ''
89
+ end
90
+
79
91
  "#{message}#{annotate_message(offense.message)}"
80
92
  end
81
93
 
@@ -42,9 +42,14 @@ module RuboCop
42
42
  end
43
43
 
44
44
  def report_offense(file, offense)
45
- output.printf("# %s:%d:%d: %s: %s\n",
46
- cyan(smart_path(file)), offense.line, offense.real_column,
47
- colored_severity_code(offense), message(offense))
45
+ output.printf(
46
+ "# %<path>s:%<line>d:%<column>d: %<severity>s: %<message>s\n",
47
+ path: cyan(smart_path(file)),
48
+ line: offense.line,
49
+ column: offense.real_column,
50
+ severity: colored_severity_code(offense),
51
+ message: message(offense)
52
+ )
48
53
 
49
54
  # rubocop:disable Lint/HandleExceptions
50
55
  begin
@@ -63,7 +68,15 @@ module RuboCop
63
68
  end
64
69
 
65
70
  def message(offense)
66
- message = offense.corrected? ? '[Corrected] ' : ''
71
+ message =
72
+ if offense.corrected_with_todo?
73
+ '[Todo] '
74
+ elsif offense.corrected?
75
+ '[Corrected] '
76
+ else
77
+ ''
78
+ end
79
+
67
80
  "#{message}#{annotate_message(offense.message)}"
68
81
  end
69
82
  end
@@ -42,6 +42,10 @@ module RuboCop
42
42
  frozen_string_literal == true
43
43
  end
44
44
 
45
+ def valid_literal_value?
46
+ [true, false].include?(frozen_string_literal)
47
+ end
48
+
45
49
  # Was a magic comment for the frozen string literal found?
46
50
  #
47
51
  # @return [Boolean]
@@ -367,8 +367,9 @@ module RuboCop
367
367
  # This module contains help texts for command line options.
368
368
  module OptionsHelp
369
369
  MAX_EXCL = RuboCop::Options::DEFAULT_MAXIMUM_EXCLUSION_ITEMS.to_s
370
-
371
370
  # rubocop:disable Metrics/LineLength
371
+ FORMATTER_OPTION_LIST = RuboCop::Formatter::FormatterSet::BUILTIN_FORMATTERS_FOR_KEYS.keys
372
+
372
373
  TEXT = {
373
374
  only: 'Run only the given cop(s).',
374
375
  only_guide_cops: ['Run only cops for rules that link to a',
@@ -394,7 +395,7 @@ module RuboCop
394
395
  "properties to generate. Default is #{MAX_EXCL}."],
395
396
  disable_uncorrectable: ['Used with --auto-correct to annotate any',
396
397
  'offenses that do not support autocorrect',
397
- 'with `rubocop:disable` comments.'],
398
+ 'with `rubocop:todo` comments.'],
398
399
  force_exclusion: ['Force excluding files specified in the',
399
400
  'configuration `Exclude` even if they are',
400
401
  'explicitly passed as arguments.'],
@@ -407,20 +408,8 @@ module RuboCop
407
408
  format: ['Choose an output formatter. This option',
408
409
  'can be specified multiple times to enable',
409
410
  'multiple formatters at the same time.',
410
- ' [p]rogress (default)',
411
- ' [s]imple',
412
- ' [c]lang',
413
- ' [d]isabled cops via inline comments',
414
- ' [fu]ubar',
415
- ' [e]macs',
416
- ' [j]son',
417
- ' [h]tml',
418
- ' [fi]les',
419
- ' [o]ffenses',
420
- ' [w]orst',
421
- ' [t]ap',
422
- ' [q]uiet',
423
- ' [a]utogenconf',
411
+ '[p]rogress is used by default',
412
+ *FORMATTER_OPTION_LIST.map { |item| " #{item}" },
424
413
  ' custom formatter class name'],
425
414
  out: ['Write output to a file instead of STDOUT.',
426
415
  'This option applies to the previously',
@@ -155,10 +155,10 @@ module RuboCop
155
155
  if cop.relevant_file?(file)
156
156
  cop.check(offenses, source.disabled_line_ranges, source.comments)
157
157
  offenses += cop.offenses
158
- autocorrect_unneeded_disables(source, cop)
158
+ offenses += autocorrect_unneeded_disables(file, source, cop,
159
+ offenses)
159
160
  end
160
161
  end
161
- offenses
162
162
  end
163
163
 
164
164
  offenses.sort.reject(&:disabled?).freeze
@@ -172,14 +172,20 @@ module RuboCop
172
172
  @options[:except] || @options[:only]
173
173
  end
174
174
 
175
- def autocorrect_unneeded_disables(source, cop)
175
+ def autocorrect_unneeded_disables(file, source, cop, offenses)
176
176
  cop.processed_source = source
177
177
 
178
- Cop::Team.new(
179
- RuboCop::Cop::Registry.new,
180
- nil,
181
- @options
182
- ).autocorrect(source.buffer, [cop])
178
+ team = Cop::Team.new(RuboCop::Cop::Registry.new, nil, @options)
179
+ team.autocorrect(source.buffer, [cop])
180
+
181
+ return [] unless team.updated_source_file?
182
+
183
+ # Do one extra inspection loop if any unneeded disables were
184
+ # removed. This is done in order to find rubocop:enable directives that
185
+ # have now become useless.
186
+ _source, new_offenses = do_inspection_loop(file,
187
+ get_processed_source(file))
188
+ new_offenses - offenses
183
189
  end
184
190
 
185
191
  def file_started(file)
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.74.0'
6
+ STRING = '0.75.1'
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.74.0
4
+ version: 0.75.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: 2019-07-31 00:00:00.000000000 Z
13
+ date: 2019-10-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jaro_winkler
@@ -389,6 +389,7 @@ files:
389
389
  - lib/rubocop/cop/lint/safe_navigation_consistency.rb
390
390
  - lib/rubocop/cop/lint/safe_navigation_with_empty.rb
391
391
  - lib/rubocop/cop/lint/script_permission.rb
392
+ - lib/rubocop/cop/lint/send_with_mixin_argument.rb
392
393
  - lib/rubocop/cop/lint/shadowed_argument.rb
393
394
  - lib/rubocop/cop/lint/shadowed_exception.rb
394
395
  - lib/rubocop/cop/lint/shadowing_outer_local_variable.rb
@@ -424,6 +425,7 @@ files:
424
425
  - lib/rubocop/cop/metrics/parameter_lists.rb
425
426
  - lib/rubocop/cop/metrics/perceived_complexity.rb
426
427
  - lib/rubocop/cop/metrics/utils/abc_size_calculator.rb
428
+ - lib/rubocop/cop/migration/department_name.rb
427
429
  - lib/rubocop/cop/mixin/alignment.rb
428
430
  - lib/rubocop/cop/mixin/annotation_comment.rb
429
431
  - lib/rubocop/cop/mixin/array_min_size.rb
@@ -448,7 +450,6 @@ files:
448
450
  - lib/rubocop/cop/mixin/frozen_string_literal.rb
449
451
  - lib/rubocop/cop/mixin/hash_alignment.rb
450
452
  - lib/rubocop/cop/mixin/heredoc.rb
451
- - lib/rubocop/cop/mixin/ignored_method_patterns.rb
452
453
  - lib/rubocop/cop/mixin/ignored_methods.rb
453
454
  - lib/rubocop/cop/mixin/ignored_pattern.rb
454
455
  - lib/rubocop/cop/mixin/integer_node.rb
@@ -683,6 +684,7 @@ files:
683
684
  - lib/rubocop/cop/style/zero_length_predicate.rb
684
685
  - lib/rubocop/cop/team.rb
685
686
  - lib/rubocop/cop/util.rb
687
+ - lib/rubocop/cop/utils/format_string.rb
686
688
  - lib/rubocop/cop/variable_force.rb
687
689
  - lib/rubocop/cop/variable_force/assignment.rb
688
690
  - lib/rubocop/cop/variable_force/branch.rb
@@ -707,6 +709,7 @@ files:
707
709
  - lib/rubocop/formatter/html_formatter.rb
708
710
  - lib/rubocop/formatter/json_formatter.rb
709
711
  - lib/rubocop/formatter/offense_count_formatter.rb
712
+ - lib/rubocop/formatter/pacman_formatter.rb
710
713
  - lib/rubocop/formatter/progress_formatter.rb
711
714
  - lib/rubocop/formatter/quiet_formatter.rb
712
715
  - lib/rubocop/formatter/simple_text_formatter.rb
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- # This module encapsulates the ability to ignore certain methods when
6
- # parsing using regex patterns.
7
- module IgnoredMethodPatterns
8
- private
9
-
10
- def ignored_method_pattern?(name)
11
- ignored_method_patterns.any? { |pattern| Regexp.new(pattern) =~ name }
12
- end
13
-
14
- def ignored_method_patterns
15
- cop_config.fetch('IgnoredMethodPatterns', [])
16
- end
17
- end
18
- end
19
- end