rubocop 0.69.0 → 0.70.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +17 -1
  4. data/lib/rubocop.rb +1 -0
  5. data/lib/rubocop/ast/builder.rb +37 -37
  6. data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +10 -0
  7. data/lib/rubocop/cached_data.rb +2 -2
  8. data/lib/rubocop/config.rb +9 -1
  9. data/lib/rubocop/config_loader.rb +2 -2
  10. data/lib/rubocop/config_loader_resolver.rb +3 -2
  11. data/lib/rubocop/cop/generator.rb +7 -1
  12. data/lib/rubocop/cop/layout/align_hash.rb +74 -31
  13. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +6 -6
  14. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +75 -4
  15. data/lib/rubocop/cop/layout/indentation_width.rb +1 -7
  16. data/lib/rubocop/cop/lint/ambiguous_operator.rb +5 -5
  17. data/lib/rubocop/cop/lint/handle_exceptions.rb +47 -8
  18. data/lib/rubocop/cop/lint/number_conversion.rb +7 -0
  19. data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +3 -0
  20. data/lib/rubocop/cop/mixin/configurable_naming.rb +1 -1
  21. data/lib/rubocop/cop/mixin/configurable_numbering.rb +2 -2
  22. data/lib/rubocop/cop/mixin/ignored_method_patterns.rb +19 -0
  23. data/lib/rubocop/cop/rails/refute_methods.rb +13 -13
  24. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +17 -3
  25. data/lib/rubocop/cop/variable_force/scope.rb +3 -3
  26. data/lib/rubocop/formatter/formatter_set.rb +13 -13
  27. data/lib/rubocop/formatter/html_formatter.rb +4 -4
  28. data/lib/rubocop/formatter/json_formatter.rb +16 -16
  29. data/lib/rubocop/formatter/simple_text_formatter.rb +4 -4
  30. data/lib/rubocop/options.rb +89 -83
  31. data/lib/rubocop/version.rb +1 -1
  32. metadata +4 -24
@@ -8,11 +8,11 @@ module RuboCop
8
8
  # A scope instance holds a scope node and variable entries.
9
9
  class Scope
10
10
  OUTER_SCOPE_CHILD_INDICES = {
11
- defs: 0..0,
11
+ defs: 0..0,
12
12
  module: 0..0,
13
- class: 0..1,
13
+ class: 0..1,
14
14
  sclass: 0..0,
15
- block: 0..0
15
+ block: 0..0
16
16
  }.freeze
17
17
 
18
18
  attr_reader :node, :variables, :naked_top_level
@@ -9,19 +9,19 @@ module RuboCop
9
9
  # which invoke same method of each formatters.
10
10
  class FormatterSet < Array
11
11
  BUILTIN_FORMATTERS_FOR_KEYS = {
12
- 'progress' => ProgressFormatter,
13
- 'simple' => SimpleTextFormatter,
14
- 'clang' => ClangStyleFormatter,
15
- 'fuubar' => FuubarStyleFormatter,
16
- 'emacs' => EmacsStyleFormatter,
17
- 'json' => JSONFormatter,
18
- 'html' => HTMLFormatter,
19
- 'files' => FileListFormatter,
20
- 'offenses' => OffenseCountFormatter,
21
- 'disabled' => DisabledLinesFormatter,
22
- 'worst' => WorstOffendersFormatter,
23
- 'tap' => TapFormatter,
24
- 'quiet' => QuietFormatter,
12
+ 'progress' => ProgressFormatter,
13
+ 'simple' => SimpleTextFormatter,
14
+ 'clang' => ClangStyleFormatter,
15
+ 'fuubar' => FuubarStyleFormatter,
16
+ 'emacs' => EmacsStyleFormatter,
17
+ 'json' => JSONFormatter,
18
+ 'html' => HTMLFormatter,
19
+ 'files' => FileListFormatter,
20
+ 'offenses' => OffenseCountFormatter,
21
+ 'disabled' => DisabledLinesFormatter,
22
+ 'worst' => WorstOffendersFormatter,
23
+ 'tap' => TapFormatter,
24
+ 'quiet' => QuietFormatter,
25
25
  'autogenconf' => AutoGenConfigFormatter
26
26
  }.freeze
27
27
 
@@ -72,11 +72,11 @@ module RuboCop
72
72
  include TextUtil
73
73
 
74
74
  SEVERITY_COLORS = {
75
- refactor: Color.new(0xED, 0x9C, 0x28, 1.0),
75
+ refactor: Color.new(0xED, 0x9C, 0x28, 1.0),
76
76
  convention: Color.new(0xED, 0x9C, 0x28, 1.0),
77
- warning: Color.new(0x96, 0x28, 0xEF, 1.0),
78
- error: Color.new(0xD2, 0x32, 0x2D, 1.0),
79
- fatal: Color.new(0xD2, 0x32, 0x2D, 1.0)
77
+ warning: Color.new(0x96, 0x28, 0xEF, 1.0),
78
+ error: Color.new(0xD2, 0x32, 0x2D, 1.0),
79
+ fatal: Color.new(0xD2, 0x32, 0x2D, 1.0)
80
80
  }.freeze
81
81
 
82
82
  LOGO_IMAGE_PATH =
@@ -15,8 +15,8 @@ module RuboCop
15
15
  super
16
16
  @output_hash = {
17
17
  metadata: metadata_hash,
18
- files: [],
19
- summary: { offense_count: 0 }
18
+ files: [],
19
+ summary: { offense_count: 0 }
20
20
  }
21
21
  end
22
22
 
@@ -37,42 +37,42 @@ module RuboCop
37
37
  def metadata_hash
38
38
  {
39
39
  rubocop_version: RuboCop::Version::STRING,
40
- ruby_engine: RUBY_ENGINE,
41
- ruby_version: RUBY_VERSION,
40
+ ruby_engine: RUBY_ENGINE,
41
+ ruby_version: RUBY_VERSION,
42
42
  ruby_patchlevel: RUBY_PATCHLEVEL.to_s,
43
- ruby_platform: RUBY_PLATFORM
43
+ ruby_platform: RUBY_PLATFORM
44
44
  }
45
45
  end
46
46
 
47
47
  def hash_for_file(file, offenses)
48
48
  {
49
- path: smart_path(file),
49
+ path: smart_path(file),
50
50
  offenses: offenses.map { |o| hash_for_offense(o) }
51
51
  }
52
52
  end
53
53
 
54
54
  def hash_for_offense(offense)
55
55
  {
56
- severity: offense.severity.name,
57
- message: offense.message,
58
- cop_name: offense.cop_name,
56
+ severity: offense.severity.name,
57
+ message: offense.message,
58
+ cop_name: offense.cop_name,
59
59
  corrected: offense.corrected?,
60
- location: hash_for_location(offense)
60
+ location: hash_for_location(offense)
61
61
  }
62
62
  end
63
63
 
64
64
  # TODO: Consider better solution for Offense#real_column.
65
65
  def hash_for_location(offense)
66
66
  {
67
- start_line: offense.line,
67
+ start_line: offense.line,
68
68
  start_column: offense.real_column,
69
- last_line: offense.last_line,
70
- last_column: offense.last_column,
71
- length: offense.location.length,
69
+ last_line: offense.last_line,
70
+ last_column: offense.last_column,
71
+ length: offense.location.length,
72
72
  # `line` and `column` exist for compatibility.
73
73
  # Use `start_line` and `start_column` instead.
74
- line: offense.line,
75
- column: offense.real_column
74
+ line: offense.line,
75
+ column: offense.real_column
76
76
  }
77
77
  end
78
78
  end
@@ -13,11 +13,11 @@ module RuboCop
13
13
  include PathUtil
14
14
 
15
15
  COLOR_FOR_SEVERITY = {
16
- refactor: :yellow,
16
+ refactor: :yellow,
17
17
  convention: :yellow,
18
- warning: :magenta,
19
- error: :red,
20
- fatal: :red
18
+ warning: :magenta,
19
+ error: :red,
20
+ fatal: :red
21
21
  }.freeze
22
22
 
23
23
  def started(_target_files)
@@ -354,91 +354,97 @@ module RuboCop
354
354
  # This module contains help texts for command line options.
355
355
  module OptionsHelp
356
356
  MAX_EXCL = RuboCop::Options::DEFAULT_MAXIMUM_EXCLUSION_ITEMS.to_s
357
+
358
+ # rubocop:disable Metrics/LineLength
357
359
  TEXT = {
358
- only: 'Run only the given cop(s).',
359
- only_guide_cops: ['Run only cops for rules that link to a',
360
- 'style guide.'],
361
- except: 'Disable the given cop(s).',
362
- require: 'Require Ruby file.',
363
- config: 'Specify configuration file.',
364
- auto_gen_config: ['Generate a configuration file acting as a',
365
- 'TODO list.'],
366
- no_offense_counts: ['Do not include offense counts in configuration',
367
- 'file generated by --auto-gen-config.'],
368
- no_auto_gen_timestamp: ['Do not include the date and time when',
369
- 'the --auto-gen-config was run in the file it',
370
- 'generates.'],
371
- auto_gen_only_exclude: ['Generate only Exclude parameters and not Max',
372
- 'when running --auto-gen-config, except if the',
373
- 'number of files with offenses is bigger than',
374
- 'exclude-limit.'],
375
- exclude_limit: ['Used together with --auto-gen-config to',
376
- 'set the limit for how many Exclude',
377
- "properties to generate. Default is #{MAX_EXCL}."],
378
- force_exclusion: ['Force excluding files specified in the',
379
- 'configuration `Exclude` even if they are',
380
- 'explicitly passed as arguments.'],
381
- ignore_disable_comments: ['Run cops even when they are disabled locally',
382
- 'with a comment.'],
383
- ignore_parent_exclusion: ['Prevent from inheriting AllCops/Exclude from',
384
- 'parent folders.'],
385
- force_default_config: ['Use default configuration even if configuration',
386
- 'files are present in the directory tree.'],
387
- format: ['Choose an output formatter. This option',
388
- 'can be specified multiple times to enable',
389
- 'multiple formatters at the same time.',
390
- ' [p]rogress (default)',
391
- ' [s]imple',
392
- ' [c]lang',
393
- ' [d]isabled cops via inline comments',
394
- ' [fu]ubar',
395
- ' [e]macs',
396
- ' [j]son',
397
- ' [h]tml',
398
- ' [fi]les',
399
- ' [o]ffenses',
400
- ' [w]orst',
401
- ' [t]ap',
402
- ' [q]uiet',
403
- ' [a]utogenconf',
404
- ' custom formatter class name'],
405
- out: ['Write output to a file instead of STDOUT.',
406
- 'This option applies to the previously',
407
- 'specified --format, or the default format',
408
- 'if no format is specified.'],
409
- fail_level: ['Minimum severity (A/R/C/W/E/F) for exit',
410
- 'with error code.'],
411
- display_only_fail_level_offenses: ['Only output offense messages at',
360
+ only: 'Run only the given cop(s).',
361
+ only_guide_cops: ['Run only cops for rules that link to a',
362
+ 'style guide.'],
363
+ except: 'Disable the given cop(s).',
364
+ require: 'Require Ruby file.',
365
+ config: 'Specify configuration file.',
366
+ auto_gen_config: ['Generate a configuration file acting as a',
367
+ 'TODO list.'],
368
+ no_offense_counts: ['Do not include offense counts in configuration',
369
+ 'file generated by --auto-gen-config.'],
370
+ no_auto_gen_timestamp:
371
+ ['Do not include the date and time when',
372
+ 'the --auto-gen-config was run in the file it',
373
+ 'generates.'],
374
+ auto_gen_only_exclude:
375
+ ['Generate only Exclude parameters and not Max',
376
+ 'when running --auto-gen-config, except if the',
377
+ 'number of files with offenses is bigger than',
378
+ 'exclude-limit.'],
379
+ exclude_limit: ['Used together with --auto-gen-config to',
380
+ 'set the limit for how many Exclude',
381
+ "properties to generate. Default is #{MAX_EXCL}."],
382
+ force_exclusion: ['Force excluding files specified in the',
383
+ 'configuration `Exclude` even if they are',
384
+ 'explicitly passed as arguments.'],
385
+ ignore_disable_comments: ['Run cops even when they are disabled locally',
386
+ 'with a comment.'],
387
+ ignore_parent_exclusion: ['Prevent from inheriting AllCops/Exclude from',
388
+ 'parent folders.'],
389
+ force_default_config: ['Use default configuration even if configuration',
390
+ 'files are present in the directory tree.'],
391
+ format: ['Choose an output formatter. This option',
392
+ 'can be specified multiple times to enable',
393
+ 'multiple formatters at the same time.',
394
+ ' [p]rogress (default)',
395
+ ' [s]imple',
396
+ ' [c]lang',
397
+ ' [d]isabled cops via inline comments',
398
+ ' [fu]ubar',
399
+ ' [e]macs',
400
+ ' [j]son',
401
+ ' [h]tml',
402
+ ' [fi]les',
403
+ ' [o]ffenses',
404
+ ' [w]orst',
405
+ ' [t]ap',
406
+ ' [q]uiet',
407
+ ' [a]utogenconf',
408
+ ' custom formatter class name'],
409
+ out: ['Write output to a file instead of STDOUT.',
410
+ 'This option applies to the previously',
411
+ 'specified --format, or the default format',
412
+ 'if no format is specified.'],
413
+ fail_level: ['Minimum severity (A/R/C/W/E/F) for exit',
414
+ 'with error code.'],
415
+ display_only_fail_level_offenses:
416
+ ['Only output offense messages at',
412
417
  'the specified --fail-level or above'],
413
- show_cops: ['Shows the given cops, or all cops by',
414
- 'default, and their configurations for the',
415
- 'current directory.'],
416
- fail_fast: ['Inspect files in order of modification',
417
- 'time and stop after the first file',
418
- 'containing offenses.'],
419
- cache: ["Use result caching (FLAG=true) or don't",
420
- '(FLAG=false), default determined by',
421
- 'configuration parameter AllCops: UseCache.'],
422
- debug: 'Display debug info.',
423
- display_cop_names: ['Display cop names in offense messages.',
424
- 'Default is true.'],
425
- display_style_guide: 'Display style guide URLs in offense messages.',
426
- extra_details: 'Display extra details in offense messages.',
427
- rails: 'Run extra Rails cops.',
428
- lint: 'Run only lint cops.',
429
- safe: 'Run only safe cops.',
430
- list_target_files: 'List all files RuboCop will inspect.',
431
- auto_correct: 'Auto-correct offenses.',
432
- safe_auto_correct: 'Run auto-correct only when it\'s safe.',
433
- fix_layout: 'Run only layout cops, with auto-correct on.',
434
- color: 'Force color output on or off.',
435
- version: 'Display version.',
436
- verbose_version: 'Display verbose version.',
437
- parallel: ['Use available CPUs to execute inspection in',
438
- 'parallel.'],
439
- stdin: ['Pipe source from STDIN, using FILE in offense',
440
- 'reports. This is useful for editor integration.'],
441
- init: 'Generate a .rubocop.yml file in the current directory.'
418
+ show_cops: ['Shows the given cops, or all cops by',
419
+ 'default, and their configurations for the',
420
+ 'current directory.'],
421
+ fail_fast: ['Inspect files in order of modification',
422
+ 'time and stop after the first file',
423
+ 'containing offenses.'],
424
+ cache: ["Use result caching (FLAG=true) or don't",
425
+ '(FLAG=false), default determined by',
426
+ 'configuration parameter AllCops: UseCache.'],
427
+ debug: 'Display debug info.',
428
+ display_cop_names: ['Display cop names in offense messages.',
429
+ 'Default is true.'],
430
+ display_style_guide: 'Display style guide URLs in offense messages.',
431
+ extra_details: 'Display extra details in offense messages.',
432
+ rails: 'Run extra Rails cops.',
433
+ lint: 'Run only lint cops.',
434
+ safe: 'Run only safe cops.',
435
+ list_target_files: 'List all files RuboCop will inspect.',
436
+ auto_correct: 'Auto-correct offenses.',
437
+ safe_auto_correct: 'Run auto-correct only when it\'s safe.',
438
+ fix_layout: 'Run only layout cops, with auto-correct on.',
439
+ color: 'Force color output on or off.',
440
+ version: 'Display version.',
441
+ verbose_version: 'Display verbose version.',
442
+ parallel: ['Use available CPUs to execute inspection in',
443
+ 'parallel.'],
444
+ stdin: ['Pipe source from STDIN, using FILE in offense',
445
+ 'reports. This is useful for editor integration.'],
446
+ init: 'Generate a .rubocop.yml file in the current directory.'
442
447
  }.freeze
448
+ # rubocop:enable Metrics/LineLength
443
449
  end
444
450
  end
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.69.0'
6
+ STRING = '0.70.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.69.0
4
+ version: 0.70.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: 2019-05-13 00:00:00.000000000 Z
13
+ date: 2019-05-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jaro_winkler
@@ -456,6 +456,7 @@ files:
456
456
  - lib/rubocop/cop/mixin/frozen_string_literal.rb
457
457
  - lib/rubocop/cop/mixin/hash_alignment.rb
458
458
  - lib/rubocop/cop/mixin/heredoc.rb
459
+ - lib/rubocop/cop/mixin/ignored_method_patterns.rb
459
460
  - lib/rubocop/cop/mixin/ignored_methods.rb
460
461
  - lib/rubocop/cop/mixin/ignored_pattern.rb
461
462
  - lib/rubocop/cop/mixin/integer_node.rb
@@ -801,28 +802,7 @@ metadata:
801
802
  source_code_uri: https://github.com/rubocop-hq/rubocop/
802
803
  documentation_uri: https://docs.rubocop.org/
803
804
  bug_tracker_uri: https://github.com/rubocop-hq/rubocop/issues
804
- post_install_message: |
805
- Performance cops have been removed from RuboCop 0.68. Use the `rubocop-performance` gem instead.
806
-
807
- Put this in your `Gemfile`.
808
-
809
- ```rb
810
- gem 'rubocop-performance'
811
- ```
812
-
813
- And then execute:
814
-
815
- ```sh
816
- $ bundle install
817
- ```
818
-
819
- Put this into your `.rubocop.yml`.
820
-
821
- ```yaml
822
- require: rubocop-performance
823
- ```
824
-
825
- More information: https://github.com/rubocop-hq/rubocop-performance
805
+ post_install_message:
826
806
  rdoc_options: []
827
807
  require_paths:
828
808
  - lib