rubocop 0.92.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +21 -7
- data/config/default.yml +169 -59
- data/exe/rubocop +1 -1
- data/lib/rubocop.rb +15 -3
- data/lib/rubocop/cached_data.rb +2 -1
- data/lib/rubocop/cli/command/auto_genenerate_config.rb +1 -1
- data/lib/rubocop/cli/command/version.rb +1 -1
- data/lib/rubocop/comment_config.rb +1 -1
- data/lib/rubocop/config.rb +4 -0
- data/lib/rubocop/config_loader.rb +19 -2
- data/lib/rubocop/config_loader_resolver.rb +7 -5
- data/lib/rubocop/config_validator.rb +7 -6
- data/lib/rubocop/cop/badge.rb +9 -24
- data/lib/rubocop/cop/base.rb +16 -1
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +23 -3
- data/lib/rubocop/cop/commissioner.rb +36 -22
- data/lib/rubocop/cop/corrector.rb +3 -1
- data/lib/rubocop/cop/correctors/line_break_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
- data/lib/rubocop/cop/force.rb +1 -1
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +10 -10
- data/lib/rubocop/cop/layout/class_structure.rb +7 -0
- data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/dot_position.rb +6 -9
- data/lib/rubocop/cop/layout/else_alignment.rb +15 -2
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +7 -7
- data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +1 -1
- data/lib/rubocop/cop/layout/end_alignment.rb +3 -3
- data/lib/rubocop/cop/layout/extra_spacing.rb +1 -2
- data/lib/rubocop/cop/layout/hash_alignment.rb +4 -4
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +24 -18
- data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +2 -11
- data/lib/rubocop/cop/layout/space_around_operators.rb +4 -1
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +0 -4
- data/lib/rubocop/cop/layout/space_inside_parens.rb +35 -13
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +37 -13
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +2 -0
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +18 -1
- data/lib/rubocop/cop/lint/boolean_symbol.rb +3 -0
- data/lib/rubocop/cop/lint/debugger.rb +2 -3
- data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +77 -0
- data/lib/rubocop/cop/lint/else_layout.rb +29 -3
- data/lib/rubocop/cop/lint/empty_block.rb +59 -0
- data/lib/rubocop/cop/lint/flip_flop.rb +8 -2
- data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +37 -0
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +17 -3
- data/lib/rubocop/cop/lint/loop.rb +0 -4
- data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -0
- data/lib/rubocop/cop/lint/nested_percent_literal.rb +14 -0
- data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +58 -0
- data/lib/rubocop/cop/lint/number_conversion.rb +46 -13
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +27 -8
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +78 -0
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +95 -0
- data/lib/rubocop/cop/lint/to_json.rb +1 -1
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +185 -0
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +2 -2
- data/lib/rubocop/cop/lint/useless_setter_call.rb +6 -1
- data/lib/rubocop/cop/metrics/block_length.rb +3 -1
- data/lib/rubocop/cop/metrics/class_length.rb +14 -6
- data/lib/rubocop/cop/metrics/parameter_lists.rb +4 -1
- data/lib/rubocop/cop/mixin/configurable_numbering.rb +3 -3
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -1
- data/lib/rubocop/cop/mixin/line_length_help.rb +1 -1
- data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +12 -2
- data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +11 -5
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +67 -18
- data/lib/rubocop/cop/naming/predicate_name.rb +2 -1
- data/lib/rubocop/cop/naming/variable_number.rb +82 -8
- data/lib/rubocop/cop/offense.rb +18 -5
- data/lib/rubocop/cop/security/open.rb +12 -10
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +6 -2
- data/lib/rubocop/cop/style/accessor_grouping.rb +3 -0
- data/lib/rubocop/cop/style/arguments_forwarding.rb +142 -0
- data/lib/rubocop/cop/style/bisected_attr_accessor.rb +0 -4
- data/lib/rubocop/cop/style/case_like_if.rb +18 -6
- data/lib/rubocop/cop/style/class_equality_comparison.rb +64 -0
- data/lib/rubocop/cop/style/collection_compact.rb +85 -0
- data/lib/rubocop/cop/style/combinable_loops.rb +8 -1
- data/lib/rubocop/cop/style/comment_annotation.rb +6 -0
- data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +67 -0
- data/lib/rubocop/cop/style/double_negation.rb +6 -1
- data/lib/rubocop/cop/style/explicit_block_argument.rb +6 -2
- data/lib/rubocop/cop/style/for.rb +0 -4
- data/lib/rubocop/cop/style/format_string_token.rb +48 -3
- data/lib/rubocop/cop/style/hash_syntax.rb +3 -3
- data/lib/rubocop/cop/style/keyword_parameters_order.rb +12 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +10 -13
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +6 -11
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +7 -11
- data/lib/rubocop/cop/style/method_def_parentheses.rb +0 -4
- data/lib/rubocop/cop/style/mixin_grouping.rb +0 -4
- data/lib/rubocop/cop/style/multiple_comparison.rb +54 -7
- data/lib/rubocop/cop/style/negated_if_else_condition.rb +99 -0
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +2 -0
- data/lib/rubocop/cop/style/raise_args.rb +21 -9
- data/lib/rubocop/cop/style/redundant_begin.rb +36 -8
- data/lib/rubocop/cop/style/redundant_condition.rb +5 -1
- data/lib/rubocop/cop/style/redundant_interpolation.rb +6 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +4 -0
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +45 -24
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +8 -15
- data/lib/rubocop/cop/style/redundant_self.rb +3 -0
- data/lib/rubocop/cop/style/safe_navigation.rb +16 -4
- data/lib/rubocop/cop/style/semicolon.rb +3 -0
- data/lib/rubocop/cop/style/string_concatenation.rb +14 -2
- data/lib/rubocop/cop/style/swap_values.rb +108 -0
- data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +3 -1
- data/lib/rubocop/cop/team.rb +6 -1
- data/lib/rubocop/cop/util.rb +5 -1
- data/lib/rubocop/cop/variable_force/branch.rb +0 -4
- data/lib/rubocop/ext/regexp_node.rb +35 -11
- data/lib/rubocop/ext/regexp_parser.rb +84 -0
- data/lib/rubocop/formatter/formatter_set.rb +2 -1
- data/lib/rubocop/formatter/git_hub_actions_formatter.rb +47 -0
- data/lib/rubocop/formatter/offense_count_formatter.rb +1 -1
- data/lib/rubocop/formatter/worst_offenders_formatter.rb +1 -1
- data/lib/rubocop/magic_comment.rb +2 -2
- data/lib/rubocop/options.rb +6 -1
- data/lib/rubocop/result_cache.rb +8 -2
- data/lib/rubocop/rspec/cop_helper.rb +1 -1
- data/lib/rubocop/rspec/shared_contexts.rb +4 -0
- data/lib/rubocop/runner.rb +4 -4
- data/lib/rubocop/target_finder.rb +23 -25
- data/lib/rubocop/version.rb +56 -6
- metadata +22 -8
- data/lib/rubocop/cop/mixin/regexp_literal_help.rb +0 -43
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:
|
4
|
+
version: 1.2.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: 2020-
|
13
|
+
date: 2020-11-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parallel
|
@@ -66,14 +66,14 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '1.
|
69
|
+
version: '1.8'
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '1.
|
76
|
+
version: '1.8'
|
77
77
|
- !ruby/object:Gem::Dependency
|
78
78
|
name: rexml
|
79
79
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,14 +94,14 @@ dependencies:
|
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.
|
97
|
+
version: 1.0.1
|
98
98
|
type: :runtime
|
99
99
|
prerelease: false
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0.
|
104
|
+
version: 1.0.1
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: ruby-progressbar
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
@@ -351,10 +351,12 @@ files:
|
|
351
351
|
- lib/rubocop/cop/lint/duplicate_elsif_condition.rb
|
352
352
|
- lib/rubocop/cop/lint/duplicate_hash_key.rb
|
353
353
|
- lib/rubocop/cop/lint/duplicate_methods.rb
|
354
|
+
- lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb
|
354
355
|
- lib/rubocop/cop/lint/duplicate_require.rb
|
355
356
|
- lib/rubocop/cop/lint/duplicate_rescue_exception.rb
|
356
357
|
- lib/rubocop/cop/lint/each_with_object_argument.rb
|
357
358
|
- lib/rubocop/cop/lint/else_layout.rb
|
359
|
+
- lib/rubocop/cop/lint/empty_block.rb
|
358
360
|
- lib/rubocop/cop/lint/empty_conditional_body.rb
|
359
361
|
- lib/rubocop/cop/lint/empty_ensure.rb
|
360
362
|
- lib/rubocop/cop/lint/empty_expression.rb
|
@@ -367,6 +369,7 @@ files:
|
|
367
369
|
- lib/rubocop/cop/lint/float_comparison.rb
|
368
370
|
- lib/rubocop/cop/lint/float_out_of_range.rb
|
369
371
|
- lib/rubocop/cop/lint/format_parameter_mismatch.rb
|
372
|
+
- lib/rubocop/cop/lint/hash_compare_by_identity.rb
|
370
373
|
- lib/rubocop/cop/lint/heredoc_method_call_position.rb
|
371
374
|
- lib/rubocop/cop/lint/identity_comparison.rb
|
372
375
|
- lib/rubocop/cop/lint/implicit_string_concatenation.rb
|
@@ -383,6 +386,7 @@ files:
|
|
383
386
|
- lib/rubocop/cop/lint/nested_method_definition.rb
|
384
387
|
- lib/rubocop/cop/lint/nested_percent_literal.rb
|
385
388
|
- lib/rubocop/cop/lint/next_without_accumulator.rb
|
389
|
+
- lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb
|
386
390
|
- lib/rubocop/cop/lint/non_deterministic_require_order.rb
|
387
391
|
- lib/rubocop/cop/lint/non_local_exit_from_iterator.rb
|
388
392
|
- lib/rubocop/cop/lint/number_conversion.rb
|
@@ -396,6 +400,7 @@ files:
|
|
396
400
|
- lib/rubocop/cop/lint/redundant_cop_disable_directive.rb
|
397
401
|
- lib/rubocop/cop/lint/redundant_cop_enable_directive.rb
|
398
402
|
- lib/rubocop/cop/lint/redundant_require_statement.rb
|
403
|
+
- lib/rubocop/cop/lint/redundant_safe_navigation.rb
|
399
404
|
- lib/rubocop/cop/lint/redundant_splat_expansion.rb
|
400
405
|
- lib/rubocop/cop/lint/redundant_string_coercion.rb
|
401
406
|
- lib/rubocop/cop/lint/redundant_with_index.rb
|
@@ -417,11 +422,13 @@ files:
|
|
417
422
|
- lib/rubocop/cop/lint/struct_new_override.rb
|
418
423
|
- lib/rubocop/cop/lint/suppressed_exception.rb
|
419
424
|
- lib/rubocop/cop/lint/syntax.rb
|
425
|
+
- lib/rubocop/cop/lint/to_enum_arguments.rb
|
420
426
|
- lib/rubocop/cop/lint/to_json.rb
|
421
427
|
- lib/rubocop/cop/lint/top_level_return_with_argument.rb
|
422
428
|
- lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb
|
423
429
|
- lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb
|
424
430
|
- lib/rubocop/cop/lint/unified_integer.rb
|
431
|
+
- lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb
|
425
432
|
- lib/rubocop/cop/lint/unreachable_code.rb
|
426
433
|
- lib/rubocop/cop/lint/unreachable_loop.rb
|
427
434
|
- lib/rubocop/cop/lint/unused_block_argument.rb
|
@@ -501,7 +508,6 @@ files:
|
|
501
508
|
- lib/rubocop/cop/mixin/preferred_delimiters.rb
|
502
509
|
- lib/rubocop/cop/mixin/range_help.rb
|
503
510
|
- lib/rubocop/cop/mixin/rational_literal.rb
|
504
|
-
- lib/rubocop/cop/mixin/regexp_literal_help.rb
|
505
511
|
- lib/rubocop/cop/mixin/rescue_node.rb
|
506
512
|
- lib/rubocop/cop/mixin/safe_assignment.rb
|
507
513
|
- lib/rubocop/cop/mixin/space_after_punctuation.rb
|
@@ -544,6 +550,7 @@ files:
|
|
544
550
|
- lib/rubocop/cop/style/accessor_grouping.rb
|
545
551
|
- lib/rubocop/cop/style/alias.rb
|
546
552
|
- lib/rubocop/cop/style/and_or.rb
|
553
|
+
- lib/rubocop/cop/style/arguments_forwarding.rb
|
547
554
|
- lib/rubocop/cop/style/array_coercion.rb
|
548
555
|
- lib/rubocop/cop/style/array_join.rb
|
549
556
|
- lib/rubocop/cop/style/ascii_comments.rb
|
@@ -559,9 +566,11 @@ files:
|
|
559
566
|
- lib/rubocop/cop/style/character_literal.rb
|
560
567
|
- lib/rubocop/cop/style/class_and_module_children.rb
|
561
568
|
- lib/rubocop/cop/style/class_check.rb
|
569
|
+
- lib/rubocop/cop/style/class_equality_comparison.rb
|
562
570
|
- lib/rubocop/cop/style/class_methods.rb
|
563
571
|
- lib/rubocop/cop/style/class_methods_definitions.rb
|
564
572
|
- lib/rubocop/cop/style/class_vars.rb
|
573
|
+
- lib/rubocop/cop/style/collection_compact.rb
|
565
574
|
- lib/rubocop/cop/style/collection_methods.rb
|
566
575
|
- lib/rubocop/cop/style/colon_method_call.rb
|
567
576
|
- lib/rubocop/cop/style/colon_method_definition.rb
|
@@ -576,6 +585,7 @@ files:
|
|
576
585
|
- lib/rubocop/cop/style/def_with_parentheses.rb
|
577
586
|
- lib/rubocop/cop/style/dir.rb
|
578
587
|
- lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb
|
588
|
+
- lib/rubocop/cop/style/document_dynamic_eval_definition.rb
|
579
589
|
- lib/rubocop/cop/style/documentation.rb
|
580
590
|
- lib/rubocop/cop/style/documentation_method.rb
|
581
591
|
- lib/rubocop/cop/style/double_cop_disable_directive.rb
|
@@ -645,6 +655,7 @@ files:
|
|
645
655
|
- lib/rubocop/cop/style/multiple_comparison.rb
|
646
656
|
- lib/rubocop/cop/style/mutable_constant.rb
|
647
657
|
- lib/rubocop/cop/style/negated_if.rb
|
658
|
+
- lib/rubocop/cop/style/negated_if_else_condition.rb
|
648
659
|
- lib/rubocop/cop/style/negated_unless.rb
|
649
660
|
- lib/rubocop/cop/style/negated_while.rb
|
650
661
|
- lib/rubocop/cop/style/nested_modifier.rb
|
@@ -715,6 +726,7 @@ files:
|
|
715
726
|
- lib/rubocop/cop/style/string_methods.rb
|
716
727
|
- lib/rubocop/cop/style/strip.rb
|
717
728
|
- lib/rubocop/cop/style/struct_inheritance.rb
|
729
|
+
- lib/rubocop/cop/style/swap_values.rb
|
718
730
|
- lib/rubocop/cop/style/symbol_array.rb
|
719
731
|
- lib/rubocop/cop/style/symbol_literal.rb
|
720
732
|
- lib/rubocop/cop/style/symbol_proc.rb
|
@@ -755,6 +767,7 @@ files:
|
|
755
767
|
- lib/rubocop/error.rb
|
756
768
|
- lib/rubocop/ext/processed_source.rb
|
757
769
|
- lib/rubocop/ext/regexp_node.rb
|
770
|
+
- lib/rubocop/ext/regexp_parser.rb
|
758
771
|
- lib/rubocop/file_finder.rb
|
759
772
|
- lib/rubocop/formatter/auto_gen_config_formatter.rb
|
760
773
|
- lib/rubocop/formatter/base_formatter.rb
|
@@ -765,6 +778,7 @@ files:
|
|
765
778
|
- lib/rubocop/formatter/file_list_formatter.rb
|
766
779
|
- lib/rubocop/formatter/formatter_set.rb
|
767
780
|
- lib/rubocop/formatter/fuubar_style_formatter.rb
|
781
|
+
- lib/rubocop/formatter/git_hub_actions_formatter.rb
|
768
782
|
- lib/rubocop/formatter/html_formatter.rb
|
769
783
|
- lib/rubocop/formatter/json_formatter.rb
|
770
784
|
- lib/rubocop/formatter/junit_formatter.rb
|
@@ -803,7 +817,7 @@ metadata:
|
|
803
817
|
homepage_uri: https://rubocop.org/
|
804
818
|
changelog_uri: https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md
|
805
819
|
source_code_uri: https://github.com/rubocop-hq/rubocop/
|
806
|
-
documentation_uri: https://docs.rubocop.org/rubocop/
|
820
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.2/
|
807
821
|
bug_tracker_uri: https://github.com/rubocop-hq/rubocop/issues
|
808
822
|
post_install_message:
|
809
823
|
rdoc_options: []
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
# Common functionality for handling Regexp literals.
|
6
|
-
module RegexpLiteralHelp
|
7
|
-
private
|
8
|
-
|
9
|
-
def freespace_mode_regexp?(node)
|
10
|
-
regopt = node.children.find(&:regopt_type?)
|
11
|
-
|
12
|
-
regopt.children.include?(:x)
|
13
|
-
end
|
14
|
-
|
15
|
-
def pattern_source(node)
|
16
|
-
freespace_mode = freespace_mode_regexp?(node)
|
17
|
-
|
18
|
-
node.children.reject(&:regopt_type?).map do |child|
|
19
|
-
source_with_comments_and_interpolations_blanked(child, freespace_mode)
|
20
|
-
end.join
|
21
|
-
end
|
22
|
-
|
23
|
-
def source_with_comments_and_interpolations_blanked(child, freespace_mode)
|
24
|
-
source = child.source
|
25
|
-
|
26
|
-
# We don't want to consider the contents of interpolations or free-space mode comments as
|
27
|
-
# part of the pattern source, but need to preserve their width, to allow offsets to
|
28
|
-
# correctly line up with the original source: spaces have no effect, and preserve width.
|
29
|
-
if child.begin_type?
|
30
|
-
replace_match_with_spaces(source, /.*/m) # replace all content
|
31
|
-
elsif freespace_mode
|
32
|
-
replace_match_with_spaces(source, /(?<!\\)#.*/) # replace any comments
|
33
|
-
else
|
34
|
-
source
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def replace_match_with_spaces(source, pattern)
|
39
|
-
source.sub(pattern) { ' ' * Regexp.last_match[0].length }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|