rubocop 1.21.0 → 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +43 -6
  4. data/lib/rubocop/config.rb +5 -0
  5. data/lib/rubocop/config_loader.rb +2 -0
  6. data/lib/rubocop/config_validator.rb +9 -1
  7. data/lib/rubocop/cop/base.rb +1 -1
  8. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +34 -11
  9. data/lib/rubocop/cop/bundler/ordered_gems.rb +3 -12
  10. data/lib/rubocop/cop/correctors/ordered_gem_corrector.rb +11 -10
  11. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +3 -12
  12. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +1 -1
  13. data/lib/rubocop/cop/generator.rb +14 -8
  14. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -1
  15. data/lib/rubocop/cop/layout/dot_position.rb +25 -2
  16. data/lib/rubocop/cop/layout/line_length.rb +7 -5
  17. data/lib/rubocop/cop/layout/redundant_line_break.rb +1 -0
  18. data/lib/rubocop/cop/layout/space_inside_parens.rb +74 -24
  19. data/lib/rubocop/cop/lint/ambiguous_operator_precedence.rb +5 -1
  20. data/lib/rubocop/cop/lint/ambiguous_range.rb +7 -7
  21. data/lib/rubocop/cop/lint/assignment_in_condition.rb +7 -5
  22. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +18 -5
  23. data/lib/rubocop/cop/lint/boolean_symbol.rb +5 -0
  24. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +4 -4
  25. data/lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb +24 -1
  26. data/lib/rubocop/cop/lint/else_layout.rb +9 -5
  27. data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +12 -3
  28. data/lib/rubocop/cop/lint/interpolation_check.rb +5 -0
  29. data/lib/rubocop/cop/lint/loop.rb +4 -3
  30. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +5 -1
  31. data/lib/rubocop/cop/lint/number_conversion.rb +5 -0
  32. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +1 -1
  33. data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +4 -2
  34. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +17 -0
  35. data/lib/rubocop/cop/lint/percent_string_array.rb +10 -0
  36. data/lib/rubocop/cop/lint/raise_exception.rb +4 -0
  37. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +5 -4
  38. data/lib/rubocop/cop/lint/require_relative_self_path.rb +49 -0
  39. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +1 -1
  40. data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
  41. data/lib/rubocop/cop/lint/triple_quotes.rb +1 -1
  42. data/lib/rubocop/cop/lint/unexpected_block_arity.rb +8 -3
  43. data/lib/rubocop/cop/lint/useless_method_definition.rb +3 -2
  44. data/lib/rubocop/cop/lint/useless_setter_call.rb +7 -4
  45. data/lib/rubocop/cop/lint/useless_times.rb +3 -2
  46. data/lib/rubocop/cop/metrics/abc_size.rb +6 -0
  47. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +5 -1
  48. data/lib/rubocop/cop/mixin/heredoc.rb +1 -3
  49. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +9 -1
  50. data/lib/rubocop/cop/mixin/percent_array.rb +6 -1
  51. data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
  52. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +5 -4
  53. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +7 -0
  54. data/lib/rubocop/cop/security/io_methods.rb +49 -0
  55. data/lib/rubocop/cop/security/json_load.rb +8 -7
  56. data/lib/rubocop/cop/security/open.rb +4 -0
  57. data/lib/rubocop/cop/security/yaml_load.rb +4 -0
  58. data/lib/rubocop/cop/style/and_or.rb +4 -3
  59. data/lib/rubocop/cop/style/arguments_forwarding.rb +13 -2
  60. data/lib/rubocop/cop/style/array_coercion.rb +21 -3
  61. data/lib/rubocop/cop/style/case_like_if.rb +5 -0
  62. data/lib/rubocop/cop/style/class_and_module_children.rb +9 -0
  63. data/lib/rubocop/cop/style/collection_compact.rb +7 -5
  64. data/lib/rubocop/cop/style/collection_methods.rb +6 -5
  65. data/lib/rubocop/cop/style/combinable_loops.rb +3 -2
  66. data/lib/rubocop/cop/style/commented_keyword.rb +4 -1
  67. data/lib/rubocop/cop/style/date_time.rb +5 -0
  68. data/lib/rubocop/cop/style/double_negation.rb +15 -5
  69. data/lib/rubocop/cop/style/float_division.rb +10 -2
  70. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +6 -1
  71. data/lib/rubocop/cop/style/global_std_stream.rb +4 -0
  72. data/lib/rubocop/cop/style/hash_each_methods.rb +5 -0
  73. data/lib/rubocop/cop/style/hash_transform_keys.rb +4 -6
  74. data/lib/rubocop/cop/style/hash_transform_values.rb +4 -6
  75. data/lib/rubocop/cop/style/identical_conditional_branches.rb +18 -16
  76. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +15 -2
  77. data/lib/rubocop/cop/style/infinite_loop.rb +4 -3
  78. data/lib/rubocop/cop/style/inverse_methods.rb +9 -2
  79. data/lib/rubocop/cop/style/line_end_concatenation.rb +13 -0
  80. data/lib/rubocop/cop/style/module_function.rb +8 -9
  81. data/lib/rubocop/cop/style/mutable_constant.rb +12 -7
  82. data/lib/rubocop/cop/style/numbered_parameters.rb +46 -0
  83. data/lib/rubocop/cop/style/numbered_parameters_limit.rb +50 -0
  84. data/lib/rubocop/cop/style/numeric_literals.rb +7 -8
  85. data/lib/rubocop/cop/style/numeric_predicate.rb +5 -0
  86. data/lib/rubocop/cop/style/optional_arguments.rb +4 -0
  87. data/lib/rubocop/cop/style/optional_boolean_parameter.rb +14 -4
  88. data/lib/rubocop/cop/style/preferred_hash_methods.rb +9 -4
  89. data/lib/rubocop/cop/style/redundant_argument.rb +14 -7
  90. data/lib/rubocop/cop/style/redundant_fetch_block.rb +4 -0
  91. data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +12 -3
  92. data/lib/rubocop/cop/style/redundant_freeze.rb +0 -1
  93. data/lib/rubocop/cop/style/redundant_self.rb +10 -0
  94. data/lib/rubocop/cop/style/redundant_self_assignment.rb +4 -3
  95. data/lib/rubocop/cop/style/redundant_sort.rb +47 -29
  96. data/lib/rubocop/cop/style/safe_navigation.rb +13 -2
  97. data/lib/rubocop/cop/style/select_by_regexp.rb +106 -0
  98. data/lib/rubocop/cop/style/single_argument_dig.rb +5 -0
  99. data/lib/rubocop/cop/style/slicing_with_range.rb +13 -0
  100. data/lib/rubocop/cop/style/special_global_vars.rb +4 -0
  101. data/lib/rubocop/cop/style/static_class.rb +4 -3
  102. data/lib/rubocop/cop/style/string_chars.rb +4 -2
  103. data/lib/rubocop/cop/style/string_concatenation.rb +4 -0
  104. data/lib/rubocop/cop/style/string_hash_keys.rb +4 -0
  105. data/lib/rubocop/cop/style/struct_inheritance.rb +3 -2
  106. data/lib/rubocop/cop/style/swap_values.rb +4 -2
  107. data/lib/rubocop/cop/style/symbol_proc.rb +26 -0
  108. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +19 -0
  109. data/lib/rubocop/cop/style/yoda_condition.rb +20 -0
  110. data/lib/rubocop/cop/style/zero_length_predicate.rb +6 -0
  111. data/lib/rubocop/cop/util.rb +2 -2
  112. data/lib/rubocop/cops_documentation_generator.rb +17 -5
  113. data/lib/rubocop/options.rb +126 -112
  114. data/lib/rubocop/rspec/cop_helper.rb +1 -1
  115. data/lib/rubocop/rspec/expect_offense.rb +6 -2
  116. data/lib/rubocop/version.rb +1 -1
  117. data/lib/rubocop.rb +5 -0
  118. metadata +10 -5
@@ -59,86 +59,111 @@ module RuboCop
59
59
 
60
60
  def define_options
61
61
  OptionParser.new do |opts|
62
- opts.banner = 'Usage: rubocop [options] [file1, file2, ...]'
62
+ opts.banner = rainbow.wrap('Usage: rubocop [options] [file1, file2, ...]').bright
63
63
 
64
- add_list_options(opts)
65
- add_only_options(opts)
66
- add_configuration_options(opts)
67
- add_formatting_options(opts)
68
-
69
- option(opts, '-r', '--require FILE') { |f| require_feature(f) }
70
-
71
- add_severity_option(opts)
72
- add_flags_with_optional_args(opts)
64
+ add_check_options(opts)
73
65
  add_cache_options(opts)
74
- add_boolean_flags(opts)
75
- add_aliases(opts)
66
+ add_output_options(opts)
67
+ add_autocorrection_options(opts)
68
+ add_config_generation_options(opts)
69
+ add_additional_modes(opts)
70
+ add_general_options(opts)
71
+ end
72
+ end
76
73
 
74
+ def add_check_options(opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
75
+ section(opts, 'Basic Options') do
76
+ option(opts, '-l', '--lint') do
77
+ @options[:only] ||= []
78
+ @options[:only] << 'Lint'
79
+ end
80
+ option(opts, '-x', '--fix-layout') do
81
+ @options[:only] ||= []
82
+ @options[:only] << 'Layout'
83
+ @options[:auto_correct] = true
84
+ end
85
+ option(opts, '--safe')
86
+ add_cop_selection_csv_option('except', opts)
87
+ add_cop_selection_csv_option('only', opts)
88
+ option(opts, '--only-guide-cops')
89
+ option(opts, '-F', '--fail-fast')
90
+ option(opts, '--disable-pending-cops')
91
+ option(opts, '--enable-pending-cops')
92
+ option(opts, '--ignore-disable-comments')
93
+ option(opts, '--force-exclusion')
94
+ option(opts, '--only-recognized-file-types')
95
+ option(opts, '--ignore-parent-exclusion')
96
+ option(opts, '--force-default-config')
77
97
  option(opts, '-s', '--stdin FILE')
98
+ option(opts, '-P', '--[no-]parallel')
99
+ add_severity_option(opts)
78
100
  end
79
101
  end
80
102
 
81
- def add_only_options(opts)
82
- add_cop_selection_csv_option('except', opts)
83
- add_cop_selection_csv_option('only', opts)
84
- option(opts, '--only-guide-cops')
85
- end
103
+ def add_output_options(opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
104
+ section(opts, 'Output Options') do
105
+ option(opts, '-f', '--format FORMATTER') do |key|
106
+ @options[:formatters] ||= []
107
+ @options[:formatters] << [key]
108
+ end
86
109
 
87
- def add_cop_selection_csv_option(option, opts)
88
- option(opts, "--#{option} [COP1,COP2,...]") do |list|
89
- unless list
90
- message = "--#{option} argument should be [COP1,COP2,...]."
110
+ option(opts, '-D', '--[no-]display-cop-names')
111
+ option(opts, '-E', '--extra-details')
112
+ option(opts, '-S', '--display-style-guide')
91
113
 
92
- raise OptionArgumentError, message
114
+ option(opts, '-o', '--out FILE') do |path|
115
+ if @options[:formatters]
116
+ @options[:formatters].last << path
117
+ else
118
+ @options[:output_path] = path
119
+ end
93
120
  end
94
121
 
95
- @options[:"#{option}"] = list.empty? ? [''] : list.split(',')
122
+ option(opts, '--stderr')
123
+ option(opts, '--display-time')
124
+ option(opts, '--display-only-failed')
125
+ option(opts, '--display-only-fail-level-offenses')
96
126
  end
97
127
  end
98
128
 
99
- def add_configuration_options(opts)
100
- option(opts, '-c', '--config FILE')
101
- option(opts, '--force-exclusion')
102
- option(opts, '--only-recognized-file-types')
103
- option(opts, '--ignore-parent-exclusion')
104
- option(opts, '--force-default-config')
105
- add_auto_gen_options(opts)
106
- end
107
-
108
- def add_auto_gen_options(opts)
109
- option(opts, '--auto-gen-config')
110
-
111
- option(opts, '--regenerate-todo') do
112
- @options.replace(ConfigRegeneration.new.options.merge(@options))
129
+ def add_autocorrection_options(opts)
130
+ section(opts, 'Auto-correction') do
131
+ option(opts, '-a', '--auto-correct') { @options[:safe_auto_correct] = true }
132
+ option(opts, '--safe-auto-correct') do
133
+ warn '--safe-auto-correct is deprecated; use --auto-correct'
134
+ @options[:safe_auto_correct] = @options[:auto_correct] = true
135
+ end
136
+ option(opts, '-A', '--auto-correct-all') { @options[:auto_correct] = true }
137
+ option(opts, '--disable-uncorrectable')
113
138
  end
139
+ end
114
140
 
115
- option(opts, '--exclude-limit COUNT') { @validator.validate_exclude_limit_option }
141
+ def add_config_generation_options(opts)
142
+ section(opts, 'Config Generation') do
143
+ option(opts, '--auto-gen-config')
116
144
 
117
- option(opts, '--disable-uncorrectable')
145
+ option(opts, '--regenerate-todo') do
146
+ @options.replace(ConfigRegeneration.new.options.merge(@options))
147
+ end
118
148
 
119
- option(opts, '--[no-]offense-counts')
120
- option(opts, '--[no-]auto-gen-only-exclude')
121
- option(opts, '--[no-]auto-gen-timestamp')
149
+ option(opts, '--exclude-limit COUNT') { @validator.validate_exclude_limit_option }
122
150
 
123
- option(opts, '--init')
151
+ option(opts, '--[no-]offense-counts')
152
+ option(opts, '--[no-]auto-gen-only-exclude')
153
+ option(opts, '--[no-]auto-gen-timestamp')
154
+ end
124
155
  end
125
156
 
126
- def add_formatting_options(opts)
127
- option(opts, '-f', '--format FORMATTER') do |key|
128
- @options[:formatters] ||= []
129
- @options[:formatters] << [key]
130
- end
157
+ def add_cop_selection_csv_option(option, opts)
158
+ option(opts, "--#{option} [COP1,COP2,...]") do |list|
159
+ unless list
160
+ message = "--#{option} argument should be [COP1,COP2,...]."
131
161
 
132
- option(opts, '-o', '--out FILE') do |path|
133
- if @options[:formatters]
134
- @options[:formatters].last << path
135
- else
136
- @options[:output_path] = path
162
+ raise OptionArgumentError, message
137
163
  end
138
- end
139
164
 
140
- option(opts, '--display-time')
141
- option(opts, '--display-only-failed')
165
+ @options[:"#{option}"] = list.empty? ? [''] : list.split(',')
166
+ end
142
167
  end
143
168
 
144
169
  def add_severity_option(opts)
@@ -148,62 +173,50 @@ module RuboCop
148
173
  table) do |severity|
149
174
  @options[:fail_level] = severity
150
175
  end
151
- option(opts, '--display-only-fail-level-offenses')
152
176
  end
153
177
 
154
- def add_flags_with_optional_args(opts)
155
- option(opts, '--show-cops [COP1,COP2,...]') do |list|
156
- @options[:show_cops] = list.nil? ? [] : list.split(',')
178
+ def add_cache_options(opts)
179
+ section(opts, 'Caching') do
180
+ option(opts, '-C', '--cache FLAG')
181
+ option(opts, '--cache-root DIR') { @validator.validate_cache_enabled_for_cache_root }
157
182
  end
158
183
  end
159
184
 
160
- def add_cache_options(opts)
161
- option(opts, '-C', '--cache FLAG')
162
- option(opts, '--cache-root DIR') { @validator.validate_cache_enabled_for_cache_root }
163
- end
164
-
165
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
166
- def add_boolean_flags(opts)
167
- option(opts, '-F', '--fail-fast')
168
- option(opts, '-d', '--debug')
169
- option(opts, '-D', '--[no-]display-cop-names')
170
- option(opts, '-E', '--extra-details')
171
- option(opts, '-S', '--display-style-guide')
172
- option(opts, '-a', '--auto-correct') { @options[:safe_auto_correct] = true }
173
- option(opts, '--safe-auto-correct') do
174
- warn '--safe-auto-correct is deprecated; use --auto-correct'
175
- @options[:safe_auto_correct] = @options[:auto_correct] = true
185
+ def add_additional_modes(opts)
186
+ section(opts, 'Additional Modes') do
187
+ option(opts, '-L', '--list-target-files')
188
+ option(opts, '--show-cops [COP1,COP2,...]') do |list|
189
+ @options[:show_cops] = list.nil? ? [] : list.split(',')
190
+ end
176
191
  end
177
- option(opts, '-A', '--auto-correct-all') { @options[:auto_correct] = true }
178
- option(opts, '--disable-pending-cops')
179
- option(opts, '--enable-pending-cops')
180
- option(opts, '--ignore-disable-comments')
181
-
182
- option(opts, '--safe')
183
-
184
- option(opts, '--stderr')
185
- option(opts, '--[no-]color')
186
-
187
- option(opts, '-v', '--version')
188
- option(opts, '-V', '--verbose-version')
189
- option(opts, '-P', '--[no-]parallel')
190
192
  end
191
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
192
193
 
193
- def add_aliases(opts)
194
- option(opts, '-l', '--lint') do
195
- @options[:only] ||= []
196
- @options[:only] << 'Lint'
194
+ def add_general_options(opts)
195
+ section(opts, 'General Options') do
196
+ option(opts, '--init')
197
+ option(opts, '-c', '--config FILE')
198
+ option(opts, '-d', '--debug')
199
+ option(opts, '-r', '--require FILE') { |f| require_feature(f) }
200
+ option(opts, '--[no-]color')
201
+ option(opts, '-v', '--version')
202
+ option(opts, '-V', '--verbose-version')
197
203
  end
198
- option(opts, '-x', '--fix-layout') do
199
- @options[:only] ||= []
200
- @options[:only] << 'Layout'
201
- @options[:auto_correct] = true
204
+ end
205
+
206
+ def rainbow
207
+ @rainbow ||= begin
208
+ rainbow = Rainbow.new
209
+ rainbow.enabled = false if ARGV.include?('--no-color')
210
+ rainbow
202
211
  end
203
212
  end
204
213
 
205
- def add_list_options(opts)
206
- option(opts, '-L', '--list-target-files')
214
+ # Creates a section of options in order to separate them visually when
215
+ # using `--help`.
216
+ def section(opts, heading, &_block)
217
+ heading = rainbow.wrap(heading).bright
218
+ opts.separator("\n#{heading}:\n")
219
+ yield
207
220
  end
208
221
 
209
222
  # Sets a value in the @options hash, based on the given long option and its
@@ -403,7 +416,7 @@ module RuboCop
403
416
  only: 'Run only the given cop(s).',
404
417
  only_guide_cops: ['Run only cops for rules that link to a',
405
418
  'style guide.'],
406
- except: 'Disable the given cop(s).',
419
+ except: 'Exclude the given cop(s).',
407
420
  require: 'Require Ruby file.',
408
421
  config: 'Specify configuration file.',
409
422
  auto_gen_config: ['Generate a configuration file acting as a',
@@ -422,29 +435,30 @@ module RuboCop
422
435
  'when running --auto-gen-config, except if the',
423
436
  'number of files with offenses is bigger than',
424
437
  'exclude-limit. Default is false.'],
425
- exclude_limit: ['Used together with --auto-gen-config to',
426
- 'set the limit for how many Exclude',
427
- "properties to generate. Default is #{MAX_EXCL}."],
438
+ exclude_limit: ['Set the limit for how many files to explicitly exclude.',
439
+ 'If there are more files than the limit, the cop will',
440
+ "be disabled instead. Default is #{MAX_EXCL}."],
428
441
  disable_uncorrectable: ['Used with --auto-correct to annotate any',
429
442
  'offenses that do not support autocorrect',
430
443
  'with `rubocop:todo` comments.'],
431
- force_exclusion: ['Force excluding files specified in the',
432
- 'configuration `Exclude` even if they are',
433
- 'explicitly passed as arguments.'],
444
+ force_exclusion: ['Any files excluded by `Exclude` in configuration',
445
+ 'files will be excluded, even if given explicitly',
446
+ 'as arguments.'],
434
447
  only_recognized_file_types: ['Inspect files given on the command line only if',
435
- 'they are listed in AllCops/Include parameters',
448
+ 'they are listed in `AllCops/Include` parameters',
436
449
  'of user configuration or default configuration.'],
437
450
  ignore_disable_comments: ['Run cops even when they are disabled locally',
438
- 'with a comment.'],
439
- ignore_parent_exclusion: ['Prevent from inheriting AllCops/Exclude from',
451
+ 'by a `rubocop:disable` directive.'],
452
+ ignore_parent_exclusion: ['Prevent from inheriting `AllCops/Exclude` from',
440
453
  'parent folders.'],
441
454
  force_default_config: ['Use default configuration even if configuration',
442
455
  'files are present in the directory tree.'],
443
456
  format: ['Choose an output formatter. This option',
444
457
  'can be specified multiple times to enable',
445
458
  'multiple formatters at the same time.',
446
- '[p]rogress is used by default',
447
- *FORMATTER_OPTION_LIST.map { |item| " #{item}" },
459
+ *FORMATTER_OPTION_LIST.map do |item|
460
+ " #{item}#{' (default)' if item == '[p]rogress'}"
461
+ end,
448
462
  ' custom formatter class name'],
449
463
  out: ['Write output to a file instead of STDOUT.',
450
464
  'This option applies to the previously',
@@ -49,7 +49,7 @@ module CopHelper
49
49
  team = RuboCop::Cop::Team.new([cop], nil, raise_error: true)
50
50
  report = team.investigate(processed_source)
51
51
  @last_corrector = report.correctors.first || RuboCop::Cop::Corrector.new(processed_source)
52
- report.offenses
52
+ report.offenses.reject(&:disabled?)
53
53
  end
54
54
  end
55
55
 
@@ -126,7 +126,7 @@ module RuboCop
126
126
  @offenses
127
127
  end
128
128
 
129
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
129
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
130
130
  def expect_correction(correction, loop: true, source: nil)
131
131
  if source
132
132
  expected_annotations = parse_annotations(source, raise_error: false)
@@ -136,6 +136,8 @@ module RuboCop
136
136
 
137
137
  raise '`expect_correction` must follow `expect_offense`' unless @processed_source
138
138
 
139
+ source = @processed_source.raw_source
140
+
139
141
  iteration = 0
140
142
  new_source = loop do
141
143
  iteration += 1
@@ -155,9 +157,11 @@ module RuboCop
155
157
  _investigate(cop, @processed_source)
156
158
  end
157
159
 
160
+ raise 'Use `expect_no_corrections` if the code will not change' if new_source == source
161
+
158
162
  expect(new_source).to eq(correction)
159
163
  end
160
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
164
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
161
165
 
162
166
  def expect_no_corrections
163
167
  raise '`expect_no_corrections` must follow `expect_offense`' unless @processed_source
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.21.0'
6
+ STRING = '1.22.0'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, '\
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
data/lib/rubocop.rb CHANGED
@@ -346,6 +346,7 @@ require_relative 'rubocop/cop/lint/redundant_with_index'
346
346
  require_relative 'rubocop/cop/lint/redundant_with_object'
347
347
  require_relative 'rubocop/cop/lint/regexp_as_condition'
348
348
  require_relative 'rubocop/cop/lint/require_parentheses'
349
+ require_relative 'rubocop/cop/lint/require_relative_self_path'
349
350
  require_relative 'rubocop/cop/lint/rescue_exception'
350
351
  require_relative 'rubocop/cop/lint/rescue_type'
351
352
  require_relative 'rubocop/cop/lint/return_in_void_context'
@@ -512,6 +513,7 @@ require_relative 'rubocop/cop/style/line_end_concatenation'
512
513
  require_relative 'rubocop/cop/style/method_call_without_args_parentheses'
513
514
  require_relative 'rubocop/cop/style/method_call_with_args_parentheses'
514
515
  require_relative 'rubocop/cop/style/multiline_in_pattern_then'
516
+ require_relative 'rubocop/cop/style/numbered_parameters'
515
517
  require_relative 'rubocop/cop/style/redundant_assignment'
516
518
  require_relative 'rubocop/cop/style/redundant_fetch_block'
517
519
  require_relative 'rubocop/cop/style/redundant_file_extension_in_require'
@@ -548,6 +550,7 @@ require_relative 'rubocop/cop/style/nil_comparison'
548
550
  require_relative 'rubocop/cop/style/nil_lambda'
549
551
  require_relative 'rubocop/cop/style/non_nil_check'
550
552
  require_relative 'rubocop/cop/style/not'
553
+ require_relative 'rubocop/cop/style/numbered_parameters_limit'
551
554
  require_relative 'rubocop/cop/style/numeric_literals'
552
555
  require_relative 'rubocop/cop/style/numeric_literal_prefix'
553
556
  require_relative 'rubocop/cop/style/numeric_predicate'
@@ -588,6 +591,7 @@ require_relative 'rubocop/cop/style/rescue_standard_error'
588
591
  require_relative 'rubocop/cop/style/return_nil'
589
592
  require_relative 'rubocop/cop/style/safe_navigation'
590
593
  require_relative 'rubocop/cop/style/sample'
594
+ require_relative 'rubocop/cop/style/select_by_regexp'
591
595
  require_relative 'rubocop/cop/style/self_assignment'
592
596
  require_relative 'rubocop/cop/style/semicolon'
593
597
  require_relative 'rubocop/cop/style/send'
@@ -635,6 +639,7 @@ require_relative 'rubocop/cop/style/yoda_condition'
635
639
  require_relative 'rubocop/cop/style/zero_length_predicate'
636
640
 
637
641
  require_relative 'rubocop/cop/security/eval'
642
+ require_relative 'rubocop/cop/security/io_methods'
638
643
  require_relative 'rubocop/cop/security/json_load'
639
644
  require_relative 'rubocop/cop/security/marshal_load'
640
645
  require_relative 'rubocop/cop/security/open'
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: 1.21.0
4
+ version: 1.22.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: 2021-09-13 00:00:00.000000000 Z
13
+ date: 2021-09-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parallel
@@ -100,7 +100,7 @@ dependencies:
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 1.9.1
103
+ version: 1.12.0
104
104
  - - "<"
105
105
  - !ruby/object:Gem::Version
106
106
  version: '2.0'
@@ -110,7 +110,7 @@ dependencies:
110
110
  requirements:
111
111
  - - ">="
112
112
  - !ruby/object:Gem::Version
113
- version: 1.9.1
113
+ version: 1.12.0
114
114
  - - "<"
115
115
  - !ruby/object:Gem::Version
116
116
  version: '2.0'
@@ -456,6 +456,7 @@ files:
456
456
  - lib/rubocop/cop/lint/redundant_with_object.rb
457
457
  - lib/rubocop/cop/lint/regexp_as_condition.rb
458
458
  - lib/rubocop/cop/lint/require_parentheses.rb
459
+ - lib/rubocop/cop/lint/require_relative_self_path.rb
459
460
  - lib/rubocop/cop/lint/rescue_exception.rb
460
461
  - lib/rubocop/cop/lint/rescue_type.rb
461
462
  - lib/rubocop/cop/lint/return_in_void_context.rb
@@ -599,6 +600,7 @@ files:
599
600
  - lib/rubocop/cop/offense.rb
600
601
  - lib/rubocop/cop/registry.rb
601
602
  - lib/rubocop/cop/security/eval.rb
603
+ - lib/rubocop/cop/security/io_methods.rb
602
604
  - lib/rubocop/cop/security/json_load.rb
603
605
  - lib/rubocop/cop/security/marshal_load.rb
604
606
  - lib/rubocop/cop/security/open.rb
@@ -731,6 +733,8 @@ files:
731
733
  - lib/rubocop/cop/style/nil_lambda.rb
732
734
  - lib/rubocop/cop/style/non_nil_check.rb
733
735
  - lib/rubocop/cop/style/not.rb
736
+ - lib/rubocop/cop/style/numbered_parameters.rb
737
+ - lib/rubocop/cop/style/numbered_parameters_limit.rb
734
738
  - lib/rubocop/cop/style/numeric_literal_prefix.rb
735
739
  - lib/rubocop/cop/style/numeric_literals.rb
736
740
  - lib/rubocop/cop/style/numeric_predicate.rb
@@ -776,6 +780,7 @@ files:
776
780
  - lib/rubocop/cop/style/return_nil.rb
777
781
  - lib/rubocop/cop/style/safe_navigation.rb
778
782
  - lib/rubocop/cop/style/sample.rb
783
+ - lib/rubocop/cop/style/select_by_regexp.rb
779
784
  - lib/rubocop/cop/style/self_assignment.rb
780
785
  - lib/rubocop/cop/style/semicolon.rb
781
786
  - lib/rubocop/cop/style/send.rb
@@ -892,7 +897,7 @@ metadata:
892
897
  homepage_uri: https://rubocop.org/
893
898
  changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
894
899
  source_code_uri: https://github.com/rubocop/rubocop/
895
- documentation_uri: https://docs.rubocop.org/rubocop/1.21/
900
+ documentation_uri: https://docs.rubocop.org/rubocop/1.22/
896
901
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
897
902
  post_install_message:
898
903
  rdoc_options: []