rubocop 0.59.2 → 0.60.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +3 -2
  3. data/config/default.yml +2960 -552
  4. data/lib/rubocop.rb +1 -0
  5. data/lib/rubocop/ast/builder.rb +29 -29
  6. data/lib/rubocop/ast/node.rb +29 -25
  7. data/lib/rubocop/ast/node/args_node.rb +1 -1
  8. data/lib/rubocop/ast/node/mixin/binary_operator_node.rb +1 -1
  9. data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +26 -0
  10. data/lib/rubocop/ast/node/mixin/method_identifier_predicates.rb +5 -1
  11. data/lib/rubocop/ast/node/pair_node.rb +8 -1
  12. data/lib/rubocop/ast/node/str_node.rb +1 -1
  13. data/lib/rubocop/cached_data.rb +2 -2
  14. data/lib/rubocop/config.rb +1 -1
  15. data/lib/rubocop/config_loader.rb +8 -0
  16. data/lib/rubocop/cop/autocorrect_logic.rb +7 -1
  17. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -1
  18. data/lib/rubocop/cop/correctors/alignment_corrector.rb +2 -1
  19. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +1 -1
  20. data/lib/rubocop/cop/generator.rb +10 -3
  21. data/lib/rubocop/cop/generator/require_file_injector.rb +1 -1
  22. data/lib/rubocop/cop/internal_affairs/node_destructuring.rb +1 -1
  23. data/lib/rubocop/cop/layout/align_hash.rb +9 -1
  24. data/lib/rubocop/cop/layout/block_end_newline.rb +2 -4
  25. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +7 -7
  26. data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
  27. data/lib/rubocop/cop/layout/dot_position.rb +2 -2
  28. data/lib/rubocop/cop/layout/else_alignment.rb +1 -1
  29. data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +1 -2
  30. data/lib/rubocop/cop/layout/empty_lines.rb +1 -1
  31. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +25 -25
  32. data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +1 -1
  33. data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +1 -1
  34. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +1 -1
  35. data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +1 -1
  36. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +1 -1
  37. data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +1 -1
  38. data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +1 -1
  39. data/lib/rubocop/cop/layout/end_alignment.rb +1 -1
  40. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +1 -1
  41. data/lib/rubocop/cop/layout/indent_hash.rb +1 -1
  42. data/lib/rubocop/cop/layout/indent_heredoc.rb +2 -2
  43. data/lib/rubocop/cop/layout/indentation_consistency.rb +1 -1
  44. data/lib/rubocop/cop/layout/indentation_width.rb +1 -1
  45. data/lib/rubocop/cop/layout/initial_indentation.rb +1 -1
  46. data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +1 -1
  47. data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +1 -1
  48. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +84 -43
  49. data/lib/rubocop/cop/layout/space_after_method_name.rb +1 -1
  50. data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -1
  51. data/lib/rubocop/cop/layout/space_around_operators.rb +3 -2
  52. data/lib/rubocop/cop/layout/space_inside_array_percent_literal.rb +1 -1
  53. data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +2 -2
  54. data/lib/rubocop/cop/lint/ambiguous_operator.rb +5 -5
  55. data/lib/rubocop/cop/lint/assignment_in_condition.rb +10 -20
  56. data/lib/rubocop/cop/lint/ensure_return.rb +3 -0
  57. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +3 -3
  58. data/lib/rubocop/cop/lint/literal_as_condition.rb +1 -1
  59. data/lib/rubocop/cop/lint/percent_string_array.rb +2 -2
  60. data/lib/rubocop/cop/lint/percent_symbol_array.rb +10 -7
  61. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +3 -4
  62. data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -2
  63. data/lib/rubocop/cop/lint/syntax.rb +3 -2
  64. data/lib/rubocop/cop/lint/uri_escape_unescape.rb +3 -3
  65. data/lib/rubocop/cop/lint/useless_setter_call.rb +4 -7
  66. data/lib/rubocop/cop/metrics/abc_size.rb +1 -17
  67. data/lib/rubocop/cop/metrics/line_length.rb +14 -10
  68. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +45 -0
  69. data/lib/rubocop/cop/mixin/check_assignment.rb +12 -6
  70. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +1 -1
  71. data/lib/rubocop/cop/mixin/configurable_formatting.rb +0 -2
  72. data/lib/rubocop/cop/mixin/configurable_max.rb +4 -2
  73. data/lib/rubocop/cop/mixin/configurable_naming.rb +1 -1
  74. data/lib/rubocop/cop/mixin/configurable_numbering.rb +2 -2
  75. data/lib/rubocop/cop/mixin/hash_alignment.rb +32 -5
  76. data/lib/rubocop/cop/mixin/heredoc.rb +1 -1
  77. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +3 -4
  78. data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +1 -1
  79. data/lib/rubocop/cop/mixin/statement_modifier.rb +4 -0
  80. data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
  81. data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +1 -1
  82. data/lib/rubocop/cop/naming/constant_name.rb +1 -1
  83. data/lib/rubocop/cop/naming/file_name.rb +1 -1
  84. data/lib/rubocop/cop/naming/method_name.rb +2 -0
  85. data/lib/rubocop/cop/naming/variable_number.rb +1 -1
  86. data/lib/rubocop/cop/offense.rb +1 -1
  87. data/lib/rubocop/cop/performance/regexp_match.rb +1 -1
  88. data/lib/rubocop/cop/performance/sample.rb +3 -2
  89. data/lib/rubocop/cop/performance/start_with.rb +1 -1
  90. data/lib/rubocop/cop/performance/string_replacement.rb +1 -1
  91. data/lib/rubocop/cop/rails/date.rb +8 -8
  92. data/lib/rubocop/cop/rails/dynamic_find_by.rb +1 -1
  93. data/lib/rubocop/cop/rails/exit.rb +8 -9
  94. data/lib/rubocop/cop/rails/output_safety.rb +3 -3
  95. data/lib/rubocop/cop/rails/read_write_attribute.rb +5 -4
  96. data/lib/rubocop/cop/rails/refute_methods.rb +13 -13
  97. data/lib/rubocop/cop/rails/reversible_migration.rb +2 -1
  98. data/lib/rubocop/cop/rails/skips_model_validations.rb +17 -0
  99. data/lib/rubocop/cop/registry.rb +11 -2
  100. data/lib/rubocop/cop/style/and_or.rb +3 -3
  101. data/lib/rubocop/cop/style/collection_methods.rb +26 -0
  102. data/lib/rubocop/cop/style/empty_literal.rb +1 -1
  103. data/lib/rubocop/cop/style/encoding.rb +1 -1
  104. data/lib/rubocop/cop/style/even_odd.rb +2 -2
  105. data/lib/rubocop/cop/style/for.rb +3 -3
  106. data/lib/rubocop/cop/style/global_vars.rb +1 -1
  107. data/lib/rubocop/cop/style/identical_conditional_branches.rb +1 -1
  108. data/lib/rubocop/cop/style/if_unless_modifier.rb +1 -13
  109. data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
  110. data/lib/rubocop/cop/style/inverse_methods.rb +1 -1
  111. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +4 -7
  112. data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
  113. data/lib/rubocop/cop/style/module_function.rb +1 -1
  114. data/lib/rubocop/cop/style/multiline_if_then.rb +1 -1
  115. data/lib/rubocop/cop/style/mutable_constant.rb +15 -1
  116. data/lib/rubocop/cop/style/nested_modifier.rb +1 -1
  117. data/lib/rubocop/cop/style/not.rb +2 -1
  118. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +6 -6
  119. data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
  120. data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
  121. data/lib/rubocop/cop/style/one_line_conditional.rb +2 -2
  122. data/lib/rubocop/cop/style/parentheses_around_condition.rb +1 -1
  123. data/lib/rubocop/cop/style/proc.rb +1 -1
  124. data/lib/rubocop/cop/style/redundant_freeze.rb +10 -0
  125. data/lib/rubocop/cop/style/redundant_parentheses.rb +6 -2
  126. data/lib/rubocop/cop/style/redundant_self.rb +1 -1
  127. data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
  128. data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
  129. data/lib/rubocop/cop/style/ternary_parentheses.rb +4 -3
  130. data/lib/rubocop/cop/style/unneeded_condition.rb +2 -2
  131. data/lib/rubocop/cop/style/unneeded_percent_q.rb +2 -2
  132. data/lib/rubocop/cop/style/unpack_first.rb +1 -1
  133. data/lib/rubocop/cop/team.rb +3 -2
  134. data/lib/rubocop/cop/util.rb +2 -22
  135. data/lib/rubocop/cop/variable_force/scope.rb +3 -3
  136. data/lib/rubocop/cop/variable_force/variable.rb +3 -4
  137. data/lib/rubocop/cop/variable_force/variable_table.rb +2 -2
  138. data/lib/rubocop/formatter/base_formatter.rb +3 -3
  139. data/lib/rubocop/formatter/disabled_config_formatter.rb +16 -1
  140. data/lib/rubocop/formatter/formatter_set.rb +14 -14
  141. data/lib/rubocop/formatter/html_formatter.rb +4 -4
  142. data/lib/rubocop/formatter/json_formatter.rb +13 -13
  143. data/lib/rubocop/formatter/simple_text_formatter.rb +4 -4
  144. data/lib/rubocop/magic_comment.rb +4 -4
  145. data/lib/rubocop/node_pattern.rb +17 -17
  146. data/lib/rubocop/options.rb +93 -82
  147. data/lib/rubocop/result_cache.rb +9 -1
  148. data/lib/rubocop/rspec/expect_offense.rb +2 -2
  149. data/lib/rubocop/rspec/shared_contexts.rb +11 -11
  150. data/lib/rubocop/rspec/shared_examples.rb +4 -4
  151. data/lib/rubocop/string_interpreter.rb +1 -1
  152. data/lib/rubocop/version.rb +1 -1
  153. metadata +6 -13
  154. data/config/disabled.yml +0 -161
  155. data/config/enabled.yml +0 -2092
@@ -96,27 +96,27 @@ module RuboCop
96
96
  # @private
97
97
  # Builds Ruby code which implements a pattern
98
98
  class Compiler
99
- SYMBOL = %r{:(?:[\w+@*/?!<>=~|%^-]+|\[\]=?)}
100
- IDENTIFIER = /[a-zA-Z_-]/
101
- META = /\(|\)|\{|\}|\[|\]|\$\.\.\.|\$|!|\^|\.\.\./
102
- NUMBER = /-?\d+(?:\.\d+)?/
103
- STRING = /".+?"/
104
- METHOD_NAME = /\#?#{IDENTIFIER}+[\!\?]?\(?/
105
- PARAM_NUMBER = /%\d*/
106
-
107
- SEPARATORS = /[\s]+/
99
+ SYMBOL = %r{:(?:[\w+@*/?!<>=~|%^-]+|\[\]=?)}.freeze
100
+ IDENTIFIER = /[a-zA-Z_-]/.freeze
101
+ META = /\(|\)|\{|\}|\[|\]|\$\.\.\.|\$|!|\^|\.\.\./.freeze
102
+ NUMBER = /-?\d+(?:\.\d+)?/.freeze
103
+ STRING = /".+?"/.freeze
104
+ METHOD_NAME = /\#?#{IDENTIFIER}+[\!\?]?\(?/.freeze
105
+ PARAM_NUMBER = /%\d*/.freeze
106
+
107
+ SEPARATORS = /[\s]+/.freeze
108
108
  TOKENS = Regexp.union(META, PARAM_NUMBER, NUMBER,
109
109
  METHOD_NAME, SYMBOL, STRING)
110
110
 
111
- TOKEN = /\G(?:#{SEPARATORS}|#{TOKENS}|.)/
111
+ TOKEN = /\G(?:#{SEPARATORS}|#{TOKENS}|.)/.freeze
112
112
 
113
- NODE = /\A#{IDENTIFIER}+\Z/
114
- PREDICATE = /\A#{IDENTIFIER}+\?\(?\Z/
115
- WILDCARD = /\A_#{IDENTIFIER}*\Z/
116
- FUNCALL = /\A\##{METHOD_NAME}/
117
- LITERAL = /\A(?:#{SYMBOL}|#{NUMBER}|#{STRING})\Z/
118
- PARAM = /\A#{PARAM_NUMBER}\Z/
119
- CLOSING = /\A(?:\)|\}|\])\Z/
113
+ NODE = /\A#{IDENTIFIER}+\Z/.freeze
114
+ PREDICATE = /\A#{IDENTIFIER}+\?\(?\Z/.freeze
115
+ WILDCARD = /\A_#{IDENTIFIER}*\Z/.freeze
116
+ FUNCALL = /\A\##{METHOD_NAME}/.freeze
117
+ LITERAL = /\A(?:#{SYMBOL}|#{NUMBER}|#{STRING})\Z/.freeze
118
+ PARAM = /\A#{PARAM_NUMBER}\Z/.freeze
119
+ CLOSING = /\A(?:\)|\}|\])\Z/.freeze
120
120
 
121
121
  attr_reader :match_code
122
122
 
@@ -94,22 +94,24 @@ module RuboCop
94
94
 
95
95
  def add_configuration_options(opts)
96
96
  option(opts, '-c', '--config FILE')
97
+ option(opts, '--force-exclusion')
98
+ option(opts, '--ignore-parent-exclusion')
99
+ option(opts, '--force-default-config')
100
+ add_auto_gen_options(opts)
101
+ end
97
102
 
103
+ def add_auto_gen_options(opts)
98
104
  option(opts, '--auto-gen-config')
99
105
 
100
106
  option(opts, '--exclude-limit COUNT') do
101
107
  @validator.validate_exclude_limit_option
102
108
  end
103
109
 
104
- option(opts, '--force-exclusion')
105
- option(opts, '--ignore-parent-exclusion')
106
-
107
- option(opts, '--force-default-config')
108
-
109
110
  option(opts, '--no-offense-counts') do
110
111
  @options[:no_offense_counts] = true
111
112
  end
112
113
 
114
+ option(opts, '--auto-gen-only-exclude')
113
115
  option(opts, '--no-auto-gen-timestamp') do
114
116
  @options[:no_auto_gen_timestamp] = true
115
117
  end
@@ -156,6 +158,8 @@ module RuboCop
156
158
  option(opts, '-R', '--rails')
157
159
  option(opts, '-a', '--auto-correct')
158
160
 
161
+ option(opts, '--safe')
162
+
159
163
  option(opts, '--[no-]color')
160
164
 
161
165
  option(opts, '-v', '--version')
@@ -173,6 +177,9 @@ module RuboCop
173
177
  @options[:only] << 'Layout'
174
178
  @options[:auto_correct] = true
175
179
  end
180
+ option(opts, '--safe-auto-correct') do
181
+ @options[:auto_correct] = true
182
+ end
176
183
  end
177
184
 
178
185
  def add_list_options(opts)
@@ -272,7 +279,8 @@ module RuboCop
272
279
 
273
280
  message = '--%<flag>s can only be used together with --auto-gen-config.'
274
281
 
275
- %i[exclude_limit no_offense_counts no_auto_gen_timestamp].each do |option|
282
+ %i[exclude_limit no_offense_counts no_auto_gen_timestamp
283
+ auto_gen_only_exclude].each do |option|
276
284
  if @options.key?(option)
277
285
  raise OptionArgumentError,
278
286
  format(message, flag: option.to_s.tr('_', '-'))
@@ -342,84 +350,87 @@ module RuboCop
342
350
  module OptionsHelp
343
351
  MAX_EXCL = RuboCop::Options::DEFAULT_MAXIMUM_EXCLUSION_ITEMS.to_s
344
352
  TEXT = {
345
- only: 'Run only the given cop(s).',
346
- only_guide_cops: ['Run only cops for rules that link to a',
347
- 'style guide.'],
348
- except: 'Disable the given cop(s).',
349
- require: 'Require Ruby file.',
350
- config: 'Specify configuration file.',
351
- auto_gen_config: ['Generate a configuration file acting as a',
352
- 'TODO list.'],
353
- no_offense_counts: ['Do not include offense counts in configuration',
354
- 'file generated by --auto-gen-config.'],
355
- no_auto_gen_timestamp:
356
- ['Do not include the date and time when',
357
- 'the --auto-gen-config was run in the file it',
358
- 'generates.'],
359
- exclude_limit: ['Used together with --auto-gen-config to',
360
- 'set the limit for how many Exclude',
361
- "properties to generate. Default is #{MAX_EXCL}."],
362
- force_exclusion: ['Force excluding files specified in the',
363
- 'configuration `Exclude` even if they are',
364
- 'explicitly passed as arguments.'],
365
- ignore_parent_exclusion:
366
- ['Prevent from inheriting AllCops/Exclude from',
367
- 'parent folders.'],
353
+ only: 'Run only the given cop(s).',
354
+ only_guide_cops: ['Run only cops for rules that link to a',
355
+ 'style guide.'],
356
+ except: 'Disable the given cop(s).',
357
+ require: 'Require Ruby file.',
358
+ config: 'Specify configuration file.',
359
+ auto_gen_config: ['Generate a configuration file acting as a',
360
+ 'TODO list.'],
361
+ no_offense_counts: ['Do not include offense counts in configuration',
362
+ 'file generated by --auto-gen-config.'],
363
+ no_auto_gen_timestamp: ['Do not include the date and time when',
364
+ 'the --auto-gen-config was run in the file it',
365
+ 'generates.'],
366
+ auto_gen_only_exclude: ['Generate only Exclude parameters and not Max',
367
+ 'when running --auto-gen-config, except if the',
368
+ 'number of files with offenses is bigger than',
369
+ 'exclude-limit.'],
370
+ exclude_limit: ['Used together with --auto-gen-config to',
371
+ 'set the limit for how many Exclude',
372
+ "properties to generate. Default is #{MAX_EXCL}."],
373
+ force_exclusion: ['Force excluding files specified in the',
374
+ 'configuration `Exclude` even if they are',
375
+ 'explicitly passed as arguments.'],
376
+ ignore_parent_exclusion: ['Prevent from inheriting AllCops/Exclude from',
377
+ 'parent folders.'],
368
378
  force_default_config: ['Use default configuration even if configuration',
369
379
  'files are present in the directory tree.'],
370
- format: ['Choose an output formatter. This option',
371
- 'can be specified multiple times to enable',
372
- 'multiple formatters at the same time.',
373
- ' [p]rogress (default)',
374
- ' [s]imple',
375
- ' [c]lang',
376
- ' [d]isabled cops via inline comments',
377
- ' [fu]ubar',
378
- ' [e]macs',
379
- ' [j]son',
380
- ' [h]tml',
381
- ' [fi]les',
382
- ' [o]ffenses',
383
- ' [w]orst',
384
- ' [t]ap',
385
- ' [q]uiet',
386
- ' [a]utogenconf',
387
- ' custom formatter class name'],
388
- out: ['Write output to a file instead of STDOUT.',
389
- 'This option applies to the previously',
390
- 'specified --format, or the default format',
391
- 'if no format is specified.'],
392
- fail_level: ['Minimum severity (A/R/C/W/E/F) for exit',
393
- 'with error code.'],
394
- display_only_fail_level_offenses:
395
- ['Only output offense messages at',
396
- 'the specified --fail-level or above'],
397
- show_cops: ['Shows the given cops, or all cops by',
398
- 'default, and their configurations for the',
399
- 'current directory.'],
400
- fail_fast: ['Inspect files in order of modification',
401
- 'time and stop after the first file',
402
- 'containing offenses.'],
403
- cache: ["Use result caching (FLAG=true) or don't",
404
- '(FLAG=false), default determined by',
405
- 'configuration parameter AllCops: UseCache.'],
406
- debug: 'Display debug info.',
407
- display_cop_names: ['Display cop names in offense messages.',
408
- 'Default is true.'],
409
- display_style_guide: 'Display style guide URLs in offense messages.',
410
- extra_details: 'Display extra details in offense messages.',
411
- rails: 'Run extra Rails cops.',
412
- lint: 'Run only lint cops.',
413
- list_target_files: 'List all files RuboCop will inspect.',
414
- auto_correct: 'Auto-correct offenses.',
415
- fix_layout: 'Run only layout cops, with auto-correct on.',
416
- color: 'Force color output on or off.',
417
- version: 'Display version.',
418
- verbose_version: 'Display verbose version.',
419
- parallel: ['Use available CPUs to execute inspection in',
420
- 'parallel.'],
421
- stdin: ['Pipe source from STDIN, using FILE in offense',
422
- 'reports. This is useful for editor integration.']
380
+ format: ['Choose an output formatter. This option',
381
+ 'can be specified multiple times to enable',
382
+ 'multiple formatters at the same time.',
383
+ ' [p]rogress (default)',
384
+ ' [s]imple',
385
+ ' [c]lang',
386
+ ' [d]isabled cops via inline comments',
387
+ ' [fu]ubar',
388
+ ' [e]macs',
389
+ ' [j]son',
390
+ ' [h]tml',
391
+ ' [fi]les',
392
+ ' [o]ffenses',
393
+ ' [w]orst',
394
+ ' [t]ap',
395
+ ' [q]uiet',
396
+ ' [a]utogenconf',
397
+ ' custom formatter class name'],
398
+ out: ['Write output to a file instead of STDOUT.',
399
+ 'This option applies to the previously',
400
+ 'specified --format, or the default format',
401
+ 'if no format is specified.'],
402
+ fail_level: ['Minimum severity (A/R/C/W/E/F) for exit',
403
+ 'with error code.'],
404
+ display_only_fail_level_offenses: ['Only output offense messages at',
405
+ 'the specified --fail-level or above'],
406
+ show_cops: ['Shows the given cops, or all cops by',
407
+ 'default, and their configurations for the',
408
+ 'current directory.'],
409
+ fail_fast: ['Inspect files in order of modification',
410
+ 'time and stop after the first file',
411
+ 'containing offenses.'],
412
+ cache: ["Use result caching (FLAG=true) or don't",
413
+ '(FLAG=false), default determined by',
414
+ 'configuration parameter AllCops: UseCache.'],
415
+ debug: 'Display debug info.',
416
+ display_cop_names: ['Display cop names in offense messages.',
417
+ 'Default is true.'],
418
+ display_style_guide: 'Display style guide URLs in offense messages.',
419
+ extra_details: 'Display extra details in offense messages.',
420
+ rails: 'Run extra Rails cops.',
421
+ lint: 'Run only lint cops.',
422
+ safe: 'Run only safe cops.',
423
+ list_target_files: 'List all files RuboCop will inspect.',
424
+ auto_correct: 'Auto-correct offenses.',
425
+ safe_auto_correct: 'Run auto-correct only when it\'s safe.',
426
+ fix_layout: 'Run only layout cops, with auto-correct on.',
427
+ color: 'Force color output on or off.',
428
+ version: 'Display version.',
429
+ verbose_version: 'Display verbose version.',
430
+ parallel: ['Use available CPUs to execute inspection in',
431
+ 'parallel.'],
432
+ stdin: ['Pipe source from STDIN, using FILE in offense',
433
+ 'reports. This is useful for editor integration.']
423
434
  }.freeze
424
435
  end
425
436
  end
@@ -97,7 +97,15 @@ module RuboCop
97
97
 
98
98
  def save(offenses)
99
99
  dir = File.dirname(@path)
100
- FileUtils.mkdir_p(dir)
100
+
101
+ begin
102
+ FileUtils.mkdir_p(dir)
103
+ rescue Errno::EACCES => e
104
+ warn "Couldn't create cache directory. Continuing without cache."\
105
+ "\n #{e.message}"
106
+ return
107
+ end
108
+
101
109
  preliminary_path = "#{@path}_#{rand(1_000_000_000)}"
102
110
  # RuboCop must be in control of where its cached data is stored. A
103
111
  # symbolic link anywhere in the cache directory tree can be an
@@ -5,7 +5,7 @@ module RuboCop
5
5
  # Mixin for `expect_offense` and `expect_no_offenses`
6
6
  #
7
7
  # This mixin makes it easier to specify strict offense expectations
8
- # and a declarative and visual fashion. Just type out the code that
8
+ # in a declarative and visual fashion. Just type out the code that
9
9
  # should generate a offense, annotate code by writing '^'s
10
10
  # underneath each character that should be highlighted, and follow
11
11
  # the carets with a string (separated by a space) that is the
@@ -65,7 +65,7 @@ module RuboCop
65
65
 
66
66
  # Parsed representation of code annotated with the `^^^ Message` style
67
67
  class AnnotatedSource
68
- ANNOTATION_PATTERN = /\A\s*\^+ /
68
+ ANNOTATION_PATTERN = /\A\s*\^+ /.freeze
69
69
 
70
70
  # @param annotated_source [String] string passed to the matchers
71
71
  #
@@ -3,7 +3,7 @@
3
3
  require 'tmpdir'
4
4
  require 'fileutils'
5
5
 
6
- shared_context 'isolated environment', :isolated_environment do
6
+ RSpec.shared_context 'isolated environment', :isolated_environment do
7
7
  around do |example|
8
8
  Dir.mktmpdir do |tmpdir|
9
9
  original_home = ENV['HOME']
@@ -36,7 +36,7 @@ shared_context 'isolated environment', :isolated_environment do
36
36
  end
37
37
 
38
38
  # `cop_config` must be declared with #let.
39
- shared_context 'config', :config do
39
+ RSpec.shared_context 'config', :config do
40
40
  let(:config) do
41
41
  # Module#<
42
42
  unless described_class < RuboCop::Cop::Cop
@@ -59,38 +59,38 @@ shared_context 'config', :config do
59
59
  end
60
60
  end
61
61
 
62
- shared_context 'ruby 2.2', :ruby22 do
62
+ RSpec.shared_context 'ruby 2.2', :ruby22 do
63
63
  let(:ruby_version) { 2.2 }
64
64
  end
65
65
 
66
- shared_context 'ruby 2.3', :ruby23 do
66
+ RSpec.shared_context 'ruby 2.3', :ruby23 do
67
67
  let(:ruby_version) { 2.3 }
68
68
  end
69
69
 
70
- shared_context 'ruby 2.4', :ruby24 do
70
+ RSpec.shared_context 'ruby 2.4', :ruby24 do
71
71
  let(:ruby_version) { 2.4 }
72
72
  end
73
73
 
74
- shared_context 'ruby 2.5', :ruby25 do
74
+ RSpec.shared_context 'ruby 2.5', :ruby25 do
75
75
  let(:ruby_version) { 2.5 }
76
76
  end
77
77
 
78
- shared_context 'ruby 2.6', :ruby26 do
78
+ RSpec.shared_context 'ruby 2.6', :ruby26 do
79
79
  let(:ruby_version) { 2.6 }
80
80
  end
81
81
 
82
- shared_context 'with Rails', :enabled_rails do
82
+ RSpec.shared_context 'with Rails', :enabled_rails do
83
83
  let(:enabled_rails) { true }
84
84
  end
85
85
 
86
- shared_context 'with Rails 3', :rails3 do
86
+ RSpec.shared_context 'with Rails 3', :rails3 do
87
87
  let(:rails_version) { 3.0 }
88
88
  end
89
89
 
90
- shared_context 'with Rails 4', :rails4 do
90
+ RSpec.shared_context 'with Rails 4', :rails4 do
91
91
  let(:rails_version) { 4.0 }
92
92
  end
93
93
 
94
- shared_context 'with Rails 5', :rails5 do
94
+ RSpec.shared_context 'with Rails 5', :rails5 do
95
95
  let(:rails_version) { 5.0 }
96
96
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # `cop` and `source` must be declared with #let.
4
4
 
5
- shared_examples_for 'misaligned' do |annotated_source, used_style|
5
+ RSpec.shared_examples_for 'misaligned' do |annotated_source, used_style|
6
6
  config_to_allow_offenses = if used_style
7
7
  { 'EnforcedStyleAlignWith' => used_style.to_s }
8
8
  else
@@ -31,7 +31,7 @@ shared_examples_for 'misaligned' do |annotated_source, used_style|
31
31
  end
32
32
  end
33
33
 
34
- shared_examples_for 'aligned' do |alignment_base, arg, end_kw, name|
34
+ RSpec.shared_examples_for 'aligned' do |alignment_base, arg, end_kw, name|
35
35
  name ||= alignment_base
36
36
  name = name.gsub(/\n/, ' <newline>')
37
37
  it "accepts matching #{name} ... end" do
@@ -40,7 +40,7 @@ shared_examples_for 'aligned' do |alignment_base, arg, end_kw, name|
40
40
  end
41
41
  end
42
42
 
43
- shared_examples_for 'debugger' do |name, src|
43
+ RSpec.shared_examples_for 'debugger' do |name, src|
44
44
  it "reports an offense for a #{name} call" do
45
45
  inspect_source(src)
46
46
  src = [src] if src.is_a? String
@@ -51,7 +51,7 @@ shared_examples_for 'debugger' do |name, src|
51
51
  end
52
52
  end
53
53
 
54
- shared_examples_for 'non-debugger' do |name, src|
54
+ RSpec.shared_examples_for 'non-debugger' do |name, src|
55
55
  it "does not report an offense for #{name}" do
56
56
  inspect_source(src)
57
57
  expect(cop.offenses).to be_empty
@@ -16,7 +16,7 @@ module RuboCop
16
16
  u[0-9a-fA-F]{4} | # unicode char escape
17
17
  u\{[^}]*\} | # extended unicode escape
18
18
  . # any other escaped char
19
- )/x
19
+ )/x.freeze
20
20
  class << self
21
21
  def interpret(string)
22
22
  # We currently don't handle \cx, \C-x, and \M-x
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.59.2'.freeze
6
+ STRING = '0.60.0'.freeze
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)'.freeze
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.59.2
4
+ version: 0.60.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: 2018-09-24 00:00:00.000000000 Z
13
+ date: 2018-10-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jaro_winkler
@@ -114,20 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1.0'
118
- - - ">="
119
- - !ruby/object:Gem::Version
120
- version: 1.0.1
117
+ version: 1.4.0
121
118
  type: :runtime
122
119
  prerelease: false
123
120
  version_requirements: !ruby/object:Gem::Requirement
124
121
  requirements:
125
122
  - - "~>"
126
123
  - !ruby/object:Gem::Version
127
- version: '1.0'
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: 1.0.1
124
+ version: 1.4.0
131
125
  - !ruby/object:Gem::Dependency
132
126
  name: bundler
133
127
  requirement: !ruby/object:Gem::Requirement
@@ -174,8 +168,6 @@ files:
174
168
  - bin/console
175
169
  - bin/setup
176
170
  - config/default.yml
177
- - config/disabled.yml
178
- - config/enabled.yml
179
171
  - exe/rubocop
180
172
  - lib/rubocop.rb
181
173
  - lib/rubocop/ast/builder.rb
@@ -425,6 +417,7 @@ files:
425
417
  - lib/rubocop/cop/metrics/module_length.rb
426
418
  - lib/rubocop/cop/metrics/parameter_lists.rb
427
419
  - lib/rubocop/cop/metrics/perceived_complexity.rb
420
+ - lib/rubocop/cop/metrics/utils/abc_size_calculator.rb
428
421
  - lib/rubocop/cop/mixin/alignment.rb
429
422
  - lib/rubocop/cop/mixin/annotation_comment.rb
430
423
  - lib/rubocop/cop/mixin/array_hash_indentation.rb
@@ -822,7 +815,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
822
815
  version: '0'
823
816
  requirements: []
824
817
  rubyforge_project:
825
- rubygems_version: 2.6.11
818
+ rubygems_version: 2.7.6
826
819
  signing_key:
827
820
  specification_version: 4
828
821
  summary: Automatic Ruby code style checking tool.