rubocop 1.4.2 → 1.6.1
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 +52 -9
- data/config/obsoletion.yml +196 -0
- data/lib/rubocop.rb +14 -0
- data/lib/rubocop/cli.rb +5 -1
- data/lib/rubocop/cli/command/suggest_extensions.rb +80 -0
- data/lib/rubocop/config_loader.rb +1 -1
- data/lib/rubocop/config_loader_resolver.rb +5 -1
- data/lib/rubocop/config_obsoletion.rb +65 -247
- data/lib/rubocop/config_obsoletion/changed_enforced_styles.rb +33 -0
- data/lib/rubocop/config_obsoletion/changed_parameter.rb +21 -0
- data/lib/rubocop/config_obsoletion/cop_rule.rb +34 -0
- data/lib/rubocop/config_obsoletion/extracted_cop.rb +44 -0
- data/lib/rubocop/config_obsoletion/parameter_rule.rb +44 -0
- data/lib/rubocop/config_obsoletion/removed_cop.rb +41 -0
- data/lib/rubocop/config_obsoletion/renamed_cop.rb +34 -0
- data/lib/rubocop/config_obsoletion/rule.rb +41 -0
- data/lib/rubocop/config_obsoletion/split_cop.rb +27 -0
- data/lib/rubocop/config_validator.rb +18 -4
- data/lib/rubocop/cop/base.rb +17 -15
- data/lib/rubocop/cop/cop.rb +2 -2
- data/lib/rubocop/cop/correctors/string_literal_corrector.rb +6 -8
- data/lib/rubocop/cop/generator.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +6 -1
- data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +1 -1
- data/lib/rubocop/cop/layout/end_of_line.rb +5 -5
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +7 -2
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +12 -0
- data/lib/rubocop/cop/layout/line_length.rb +6 -16
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +7 -3
- data/lib/rubocop/cop/lint/interpolation_check.rb +7 -2
- data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +1 -1
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +13 -0
- data/lib/rubocop/cop/lint/unexpected_block_arity.rb +85 -0
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +8 -5
- data/lib/rubocop/cop/metrics/abc_size.rb +25 -1
- data/lib/rubocop/cop/metrics/block_length.rb +13 -7
- data/lib/rubocop/cop/metrics/method_length.rb +7 -2
- data/lib/rubocop/cop/metrics/parameter_lists.rb +64 -1
- data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +20 -10
- data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +146 -0
- data/lib/rubocop/cop/metrics/utils/repeated_csend_discount.rb +6 -1
- data/lib/rubocop/cop/migration/department_name.rb +1 -1
- data/lib/rubocop/cop/mixin/ignored_methods.rb +36 -3
- data/lib/rubocop/cop/mixin/method_complexity.rb +6 -0
- data/lib/rubocop/cop/mixin/string_help.rb +4 -1
- data/lib/rubocop/cop/naming/accessor_method_name.rb +15 -1
- data/lib/rubocop/cop/naming/variable_number.rb +3 -1
- data/lib/rubocop/cop/style/and_or.rb +10 -0
- data/lib/rubocop/cop/style/character_literal.rb +10 -11
- data/lib/rubocop/cop/style/class_and_module_children.rb +8 -3
- data/lib/rubocop/cop/style/float_division.rb +44 -1
- data/lib/rubocop/cop/style/if_unless_modifier.rb +4 -0
- data/lib/rubocop/cop/style/if_with_semicolon.rb +39 -4
- data/lib/rubocop/cop/style/ip_addresses.rb +1 -1
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +11 -2
- data/lib/rubocop/cop/style/numeric_literals.rb +14 -11
- data/lib/rubocop/cop/style/perl_backrefs.rb +86 -9
- data/lib/rubocop/cop/style/redundant_argument.rb +15 -2
- data/lib/rubocop/cop/style/redundant_condition.rb +2 -1
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +24 -8
- data/lib/rubocop/cop/style/single_line_block_params.rb +30 -7
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +65 -3
- data/lib/rubocop/cop/style/special_global_vars.rb +1 -13
- data/lib/rubocop/cop/style/string_concatenation.rb +26 -1
- data/lib/rubocop/cop/style/string_literals.rb +14 -8
- data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +4 -3
- data/lib/rubocop/cop/style/symbol_proc.rb +5 -3
- data/lib/rubocop/core_ext/hash.rb +20 -0
- data/lib/rubocop/ext/regexp_node.rb +29 -12
- data/lib/rubocop/ext/regexp_parser.rb +20 -9
- data/lib/rubocop/formatter/emacs_style_formatter.rb +2 -0
- data/lib/rubocop/formatter/simple_text_formatter.rb +2 -0
- data/lib/rubocop/formatter/tap_formatter.rb +2 -0
- data/lib/rubocop/lockfile.rb +40 -0
- data/lib/rubocop/version.rb +1 -1
- metadata +32 -5
@@ -15,20 +15,37 @@ module RuboCop
|
|
15
15
|
# see `ext/regexp_parser`.
|
16
16
|
attr_reader :parsed_tree
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
if Gem::Version.new(Regexp::Parser::VERSION) >= Gem::Version.new('2.0')
|
19
|
+
def assign_properties(*)
|
20
|
+
super
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
str = with_interpolations_blanked
|
23
|
+
@parsed_tree = begin
|
24
|
+
Regexp::Parser.parse(str, options: options)
|
25
|
+
rescue StandardError
|
26
|
+
nil
|
27
|
+
end
|
27
28
|
origin = loc.begin.end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
@parsed_tree&.each_expression(true) { |e| e.origin = origin }
|
30
|
+
end
|
31
|
+
# Please remove this `else` branch when support for regexp_parser 1.8 will be dropped.
|
32
|
+
# It's for compatibility with regexp_arser 1.8 and will never be maintained.
|
33
|
+
else
|
34
|
+
def assign_properties(*)
|
35
|
+
super
|
36
|
+
|
37
|
+
str = with_interpolations_blanked
|
38
|
+
begin
|
39
|
+
@parsed_tree = Regexp::Parser.parse(str, options: options)
|
40
|
+
rescue StandardError
|
41
|
+
@parsed_tree = nil
|
42
|
+
else
|
43
|
+
origin = loc.begin.end
|
44
|
+
source = @parsed_tree.to_s
|
45
|
+
@parsed_tree.each_expression(true) do |e|
|
46
|
+
e.origin = origin
|
47
|
+
e.source = source
|
48
|
+
end
|
32
49
|
end
|
33
50
|
end
|
34
51
|
end
|
@@ -20,17 +20,28 @@ module RuboCop
|
|
20
20
|
module Expression
|
21
21
|
# Add `expression` and `loc` to all `regexp_parser` nodes
|
22
22
|
module Base
|
23
|
-
attr_accessor :origin
|
23
|
+
attr_accessor :origin
|
24
24
|
|
25
|
-
|
26
|
-
#
|
27
|
-
|
28
|
-
|
25
|
+
if Gem::Version.new(Regexp::Parser::VERSION) >= Gem::Version.new('2.0')
|
26
|
+
# Shortcut to `loc.expression`
|
27
|
+
def expression
|
28
|
+
@expression ||= origin.adjust(begin_pos: ts, end_pos: ts + full_length)
|
29
|
+
end
|
30
|
+
# Please remove this `else` branch when support for regexp_parser 1.8 will be dropped.
|
31
|
+
# It's for compatibility with regexp_arser 1.8 and will never be maintained.
|
32
|
+
else
|
33
|
+
attr_accessor :source
|
34
|
+
|
35
|
+
def start_index
|
36
|
+
# ts is a byte index; convert it to a character index
|
37
|
+
@start_index ||= source.byteslice(0, ts).length
|
38
|
+
end
|
29
39
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
40
|
+
# Shortcut to `loc.expression`
|
41
|
+
def expression
|
42
|
+
@expression ||= begin
|
43
|
+
origin.adjust(begin_pos: start_index, end_pos: start_index + full_length)
|
44
|
+
end
|
34
45
|
end
|
35
46
|
end
|
36
47
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
# Encapsulation of a lockfile for use when checking for gems.
|
5
|
+
# Does not actually resolve gems, just parses the lockfile.
|
6
|
+
# @api private
|
7
|
+
class Lockfile
|
8
|
+
# Gems that the bundle depends on
|
9
|
+
def dependencies
|
10
|
+
return [] unless parser
|
11
|
+
|
12
|
+
parser.dependencies.values
|
13
|
+
end
|
14
|
+
|
15
|
+
# All activated gems, including transitive dependencies
|
16
|
+
def gems
|
17
|
+
return [] unless parser
|
18
|
+
|
19
|
+
# `Bundler::LockfileParser` returns `Bundler::LazySpecification` objects
|
20
|
+
# which are not resolved, so extract the dependencies from them
|
21
|
+
parser.dependencies.values.concat(parser.specs.flat_map(&:dependencies))
|
22
|
+
end
|
23
|
+
|
24
|
+
def includes_gem?(name)
|
25
|
+
gems.any? { |gem| gem.name == name }
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def parser
|
31
|
+
return unless defined?(Bundler) && Bundler.default_lockfile
|
32
|
+
return @parser if defined?(@parser)
|
33
|
+
|
34
|
+
lockfile = Bundler.read_file(Bundler.default_lockfile)
|
35
|
+
@parser = lockfile ? Bundler::LockfileParser.new(lockfile) : nil
|
36
|
+
rescue Bundler::BundlerError
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
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: 1.
|
4
|
+
version: 1.6.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: 2020-
|
13
|
+
date: 2020-12-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parallel
|
@@ -67,6 +67,9 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '1.8'
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '3.0'
|
70
73
|
type: :runtime
|
71
74
|
prerelease: false
|
72
75
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,6 +77,9 @@ dependencies:
|
|
74
77
|
- - ">="
|
75
78
|
- !ruby/object:Gem::Version
|
76
79
|
version: '1.8'
|
80
|
+
- - "<"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
77
83
|
- !ruby/object:Gem::Dependency
|
78
84
|
name: rexml
|
79
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,14 +100,20 @@ dependencies:
|
|
94
100
|
requirements:
|
95
101
|
- - ">="
|
96
102
|
- !ruby/object:Gem::Version
|
97
|
-
version: 1.
|
103
|
+
version: 1.2.0
|
104
|
+
- - "<"
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '2.0'
|
98
107
|
type: :runtime
|
99
108
|
prerelease: false
|
100
109
|
version_requirements: !ruby/object:Gem::Requirement
|
101
110
|
requirements:
|
102
111
|
- - ">="
|
103
112
|
- !ruby/object:Gem::Version
|
104
|
-
version: 1.
|
113
|
+
version: 1.2.0
|
114
|
+
- - "<"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '2.0'
|
105
117
|
- !ruby/object:Gem::Dependency
|
106
118
|
name: ruby-progressbar
|
107
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,6 +184,7 @@ files:
|
|
172
184
|
- assets/logo.png
|
173
185
|
- assets/output.html.erb
|
174
186
|
- config/default.yml
|
187
|
+
- config/obsoletion.yml
|
175
188
|
- exe/rubocop
|
176
189
|
- lib/rubocop.rb
|
177
190
|
- lib/rubocop/ast_aliases.rb
|
@@ -183,6 +196,7 @@ files:
|
|
183
196
|
- lib/rubocop/cli/command/execute_runner.rb
|
184
197
|
- lib/rubocop/cli/command/init_dotfile.rb
|
185
198
|
- lib/rubocop/cli/command/show_cops.rb
|
199
|
+
- lib/rubocop/cli/command/suggest_extensions.rb
|
186
200
|
- lib/rubocop/cli/command/version.rb
|
187
201
|
- lib/rubocop/cli/environment.rb
|
188
202
|
- lib/rubocop/comment_config.rb
|
@@ -190,6 +204,15 @@ files:
|
|
190
204
|
- lib/rubocop/config_loader.rb
|
191
205
|
- lib/rubocop/config_loader_resolver.rb
|
192
206
|
- lib/rubocop/config_obsoletion.rb
|
207
|
+
- lib/rubocop/config_obsoletion/changed_enforced_styles.rb
|
208
|
+
- lib/rubocop/config_obsoletion/changed_parameter.rb
|
209
|
+
- lib/rubocop/config_obsoletion/cop_rule.rb
|
210
|
+
- lib/rubocop/config_obsoletion/extracted_cop.rb
|
211
|
+
- lib/rubocop/config_obsoletion/parameter_rule.rb
|
212
|
+
- lib/rubocop/config_obsoletion/removed_cop.rb
|
213
|
+
- lib/rubocop/config_obsoletion/renamed_cop.rb
|
214
|
+
- lib/rubocop/config_obsoletion/rule.rb
|
215
|
+
- lib/rubocop/config_obsoletion/split_cop.rb
|
193
216
|
- lib/rubocop/config_regeneration.rb
|
194
217
|
- lib/rubocop/config_store.rb
|
195
218
|
- lib/rubocop/config_validator.rb
|
@@ -426,6 +449,7 @@ files:
|
|
426
449
|
- lib/rubocop/cop/lint/top_level_return_with_argument.rb
|
427
450
|
- lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb
|
428
451
|
- lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb
|
452
|
+
- lib/rubocop/cop/lint/unexpected_block_arity.rb
|
429
453
|
- lib/rubocop/cop/lint/unified_integer.rb
|
430
454
|
- lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb
|
431
455
|
- lib/rubocop/cop/lint/unreachable_code.rb
|
@@ -454,6 +478,7 @@ files:
|
|
454
478
|
- lib/rubocop/cop/metrics/utils/abc_size_calculator.rb
|
455
479
|
- lib/rubocop/cop/metrics/utils/code_length_calculator.rb
|
456
480
|
- lib/rubocop/cop/metrics/utils/iterating_block.rb
|
481
|
+
- lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb
|
457
482
|
- lib/rubocop/cop/metrics/utils/repeated_csend_discount.rb
|
458
483
|
- lib/rubocop/cop/migration/department_name.rb
|
459
484
|
- lib/rubocop/cop/mixin/alignment.rb
|
@@ -764,6 +789,7 @@ files:
|
|
764
789
|
- lib/rubocop/cop/variable_force/variable.rb
|
765
790
|
- lib/rubocop/cop/variable_force/variable_table.rb
|
766
791
|
- lib/rubocop/cops_documentation_generator.rb
|
792
|
+
- lib/rubocop/core_ext/hash.rb
|
767
793
|
- lib/rubocop/core_ext/string.rb
|
768
794
|
- lib/rubocop/directive_comment.rb
|
769
795
|
- lib/rubocop/error.rb
|
@@ -792,6 +818,7 @@ files:
|
|
792
818
|
- lib/rubocop/formatter/tap_formatter.rb
|
793
819
|
- lib/rubocop/formatter/text_util.rb
|
794
820
|
- lib/rubocop/formatter/worst_offenders_formatter.rb
|
821
|
+
- lib/rubocop/lockfile.rb
|
795
822
|
- lib/rubocop/magic_comment.rb
|
796
823
|
- lib/rubocop/name_similarity.rb
|
797
824
|
- lib/rubocop/options.rb
|
@@ -819,7 +846,7 @@ metadata:
|
|
819
846
|
homepage_uri: https://rubocop.org/
|
820
847
|
changelog_uri: https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md
|
821
848
|
source_code_uri: https://github.com/rubocop-hq/rubocop/
|
822
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
849
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.6/
|
823
850
|
bug_tracker_uri: https://github.com/rubocop-hq/rubocop/issues
|
824
851
|
post_install_message:
|
825
852
|
rdoc_options: []
|