rubocop 0.69.0 → 0.70.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +17 -1
- data/lib/rubocop.rb +1 -0
- data/lib/rubocop/ast/builder.rb +37 -37
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +10 -0
- data/lib/rubocop/cached_data.rb +2 -2
- data/lib/rubocop/config.rb +9 -1
- data/lib/rubocop/config_loader.rb +2 -2
- data/lib/rubocop/config_loader_resolver.rb +3 -2
- data/lib/rubocop/cop/generator.rb +7 -1
- data/lib/rubocop/cop/layout/align_hash.rb +74 -31
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +6 -6
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +75 -4
- data/lib/rubocop/cop/layout/indentation_width.rb +1 -7
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +5 -5
- data/lib/rubocop/cop/lint/handle_exceptions.rb +47 -8
- data/lib/rubocop/cop/lint/number_conversion.rb +7 -0
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +3 -0
- data/lib/rubocop/cop/mixin/configurable_naming.rb +1 -1
- data/lib/rubocop/cop/mixin/configurable_numbering.rb +2 -2
- data/lib/rubocop/cop/mixin/ignored_method_patterns.rb +19 -0
- data/lib/rubocop/cop/rails/refute_methods.rb +13 -13
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +17 -3
- data/lib/rubocop/cop/variable_force/scope.rb +3 -3
- data/lib/rubocop/formatter/formatter_set.rb +13 -13
- data/lib/rubocop/formatter/html_formatter.rb +4 -4
- data/lib/rubocop/formatter/json_formatter.rb +16 -16
- data/lib/rubocop/formatter/simple_text_formatter.rb +4 -4
- data/lib/rubocop/options.rb +89 -83
- data/lib/rubocop/version.rb +1 -1
- 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:
|
11
|
+
defs: 0..0,
|
12
12
|
module: 0..0,
|
13
|
-
class:
|
13
|
+
class: 0..1,
|
14
14
|
sclass: 0..0,
|
15
|
-
block:
|
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'
|
13
|
-
'simple'
|
14
|
-
'clang'
|
15
|
-
'fuubar'
|
16
|
-
'emacs'
|
17
|
-
'json'
|
18
|
-
'html'
|
19
|
-
'files'
|
20
|
-
'offenses'
|
21
|
-
'disabled'
|
22
|
-
'worst'
|
23
|
-
'tap'
|
24
|
-
'quiet'
|
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:
|
75
|
+
refactor: Color.new(0xED, 0x9C, 0x28, 1.0),
|
76
76
|
convention: Color.new(0xED, 0x9C, 0x28, 1.0),
|
77
|
-
warning:
|
78
|
-
error:
|
79
|
-
fatal:
|
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:
|
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:
|
41
|
-
ruby_version:
|
40
|
+
ruby_engine: RUBY_ENGINE,
|
41
|
+
ruby_version: RUBY_VERSION,
|
42
42
|
ruby_patchlevel: RUBY_PATCHLEVEL.to_s,
|
43
|
-
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:
|
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:
|
57
|
-
message:
|
58
|
-
cop_name:
|
56
|
+
severity: offense.severity.name,
|
57
|
+
message: offense.message,
|
58
|
+
cop_name: offense.cop_name,
|
59
59
|
corrected: offense.corrected?,
|
60
|
-
location:
|
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:
|
67
|
+
start_line: offense.line,
|
68
68
|
start_column: offense.real_column,
|
69
|
-
last_line:
|
70
|
-
last_column:
|
71
|
-
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:
|
75
|
-
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:
|
16
|
+
refactor: :yellow,
|
17
17
|
convention: :yellow,
|
18
|
-
warning:
|
19
|
-
error:
|
20
|
-
fatal:
|
18
|
+
warning: :magenta,
|
19
|
+
error: :red,
|
20
|
+
fatal: :red
|
21
21
|
}.freeze
|
22
22
|
|
23
23
|
def started(_target_files)
|
data/lib/rubocop/options.rb
CHANGED
@@ -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:
|
359
|
-
only_guide_cops:
|
360
|
-
|
361
|
-
except:
|
362
|
-
require:
|
363
|
-
config:
|
364
|
-
auto_gen_config:
|
365
|
-
|
366
|
-
no_offense_counts:
|
367
|
-
|
368
|
-
no_auto_gen_timestamp:
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
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:
|
414
|
-
|
415
|
-
|
416
|
-
fail_fast:
|
417
|
-
|
418
|
-
|
419
|
-
cache:
|
420
|
-
|
421
|
-
|
422
|
-
debug:
|
423
|
-
display_cop_names:
|
424
|
-
|
425
|
-
display_style_guide:
|
426
|
-
extra_details:
|
427
|
-
rails:
|
428
|
-
lint:
|
429
|
-
safe:
|
430
|
-
list_target_files:
|
431
|
-
auto_correct:
|
432
|
-
safe_auto_correct:
|
433
|
-
fix_layout:
|
434
|
-
color:
|
435
|
-
version:
|
436
|
-
verbose_version:
|
437
|
-
parallel:
|
438
|
-
|
439
|
-
stdin:
|
440
|
-
|
441
|
-
init:
|
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
|
data/lib/rubocop/version.rb
CHANGED
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.
|
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
|
+
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
|