rubocop 0.89.1 → 0.90.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 +79 -11
- data/lib/rubocop.rb +13 -0
- data/lib/rubocop/cached_data.rb +1 -0
- data/lib/rubocop/cli/command.rb +1 -0
- data/lib/rubocop/cli/command/auto_genenerate_config.rb +1 -0
- data/lib/rubocop/cli/command/base.rb +1 -0
- data/lib/rubocop/cli/command/execute_runner.rb +1 -0
- data/lib/rubocop/cli/command/init_dotfile.rb +1 -0
- data/lib/rubocop/cli/command/show_cops.rb +1 -0
- data/lib/rubocop/cli/command/version.rb +1 -0
- data/lib/rubocop/cli/environment.rb +1 -0
- data/lib/rubocop/comment_config.rb +5 -0
- data/lib/rubocop/config_loader.rb +17 -6
- data/lib/rubocop/config_loader_resolver.rb +1 -0
- data/lib/rubocop/config_obsoletion.rb +1 -0
- data/lib/rubocop/config_validator.rb +3 -0
- data/lib/rubocop/cop/base.rb +23 -0
- data/lib/rubocop/cop/bundler/gem_comment.rb +7 -3
- data/lib/rubocop/cop/commissioner.rb +47 -7
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +4 -4
- data/lib/rubocop/cop/correctors/condition_corrector.rb +3 -5
- data/lib/rubocop/cop/correctors/empty_line_corrector.rb +9 -10
- data/lib/rubocop/cop/correctors/line_break_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +8 -3
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +5 -8
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +4 -9
- data/lib/rubocop/cop/correctors/punctuation_corrector.rb +8 -10
- data/lib/rubocop/cop/documentation.rb +22 -0
- data/lib/rubocop/cop/generator.rb +1 -0
- data/lib/rubocop/cop/layout/block_alignment.rb +23 -19
- data/lib/rubocop/cop/layout/class_structure.rb +10 -9
- data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +4 -6
- data/lib/rubocop/cop/layout/condition_position.rb +13 -15
- data/lib/rubocop/cop/layout/def_end_alignment.rb +7 -4
- data/lib/rubocop/cop/layout/dot_position.rb +21 -17
- data/lib/rubocop/cop/layout/empty_comment.rb +30 -23
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +19 -16
- data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +13 -13
- data/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb +144 -0
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +21 -23
- data/lib/rubocop/cop/layout/empty_lines.rb +6 -7
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +4 -6
- data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +7 -8
- data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +3 -6
- data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +2 -5
- data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +2 -5
- data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +2 -5
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +2 -5
- data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +2 -5
- data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +2 -5
- data/lib/rubocop/cop/layout/end_alignment.rb +6 -7
- data/lib/rubocop/cop/layout/first_array_element_line_break.rb +2 -5
- data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +2 -5
- data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +4 -8
- data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +2 -5
- data/lib/rubocop/cop/layout/hash_alignment.rb +17 -20
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +15 -14
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +14 -11
- data/lib/rubocop/cop/layout/initial_indentation.rb +6 -7
- data/lib/rubocop/cop/layout/leading_comment_space.rb +11 -9
- data/lib/rubocop/cop/layout/leading_empty_lines.rb +6 -11
- data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +2 -5
- data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +2 -5
- data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +10 -14
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +21 -19
- data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +2 -5
- data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +2 -5
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +5 -9
- data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +2 -5
- data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +2 -5
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +18 -21
- data/lib/rubocop/cop/layout/space_after_colon.rb +11 -7
- data/lib/rubocop/cop/layout/space_after_comma.rb +2 -5
- data/lib/rubocop/cop/layout/space_after_method_name.rb +5 -6
- data/lib/rubocop/cop/layout/space_after_not.rb +9 -11
- data/lib/rubocop/cop/layout/space_after_semicolon.rb +2 -5
- data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +20 -15
- data/lib/rubocop/cop/layout/space_around_keyword.rb +17 -18
- data/lib/rubocop/cop/layout/space_around_operators.rb +17 -16
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +23 -22
- data/lib/rubocop/cop/layout/space_before_comma.rb +3 -5
- data/lib/rubocop/cop/layout/space_before_comment.rb +10 -7
- data/lib/rubocop/cop/layout/space_before_first_arg.rb +7 -7
- data/lib/rubocop/cop/layout/space_before_semicolon.rb +2 -5
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +9 -17
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +13 -16
- data/lib/rubocop/cop/layout/space_inside_array_percent_literal.rb +3 -8
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +17 -16
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +16 -19
- data/lib/rubocop/cop/layout/space_inside_parens.rb +9 -14
- data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +5 -10
- data/lib/rubocop/cop/layout/space_inside_range_literal.rb +8 -17
- data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +13 -16
- data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +10 -11
- data/lib/rubocop/cop/layout/trailing_empty_lines.rb +10 -15
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +11 -11
- data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +1 -1
- data/lib/rubocop/cop/lint/constant_resolution.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_require.rb +41 -0
- data/lib/rubocop/cop/lint/duplicate_rescue_exception.rb +0 -11
- data/lib/rubocop/cop/lint/empty_file.rb +53 -0
- data/lib/rubocop/cop/lint/missing_super.rb +2 -2
- data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +2 -35
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +9 -19
- data/lib/rubocop/cop/lint/percent_string_array.rb +8 -12
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +4 -4
- data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
- data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +57 -0
- data/lib/rubocop/cop/lint/useless_method_definition.rb +77 -0
- data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +2 -0
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -0
- data/lib/rubocop/cop/mixin/alignment.rb +3 -0
- data/lib/rubocop/cop/mixin/allowed_methods.rb +2 -0
- data/lib/rubocop/cop/mixin/annotation_comment.rb +5 -0
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +16 -7
- data/lib/rubocop/cop/mixin/comments_help.rb +54 -0
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +8 -7
- data/lib/rubocop/cop/mixin/empty_parameter.rb +3 -1
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +3 -1
- data/lib/rubocop/cop/mixin/first_element_line_break.rb +3 -1
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +17 -0
- data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +3 -1
- data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +12 -10
- data/lib/rubocop/cop/mixin/negative_conditional.rb +2 -2
- data/lib/rubocop/cop/mixin/percent_array.rb +14 -3
- data/lib/rubocop/cop/mixin/regexp_literal_help.rb +1 -1
- data/lib/rubocop/cop/mixin/rescue_node.rb +10 -1
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +4 -3
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +4 -3
- data/lib/rubocop/cop/mixin/surrounding_space.rb +8 -4
- data/lib/rubocop/cop/mixin/trailing_comma.rb +7 -7
- data/lib/rubocop/cop/offense.rb +1 -0
- data/lib/rubocop/cop/severity.rb +0 -8
- data/lib/rubocop/cop/style/case_equality.rb +8 -3
- data/lib/rubocop/cop/style/case_like_if.rb +20 -4
- data/lib/rubocop/cop/style/class_methods_definitions.rb +131 -0
- data/lib/rubocop/cop/style/combinable_loops.rb +89 -0
- data/lib/rubocop/cop/style/empty_block_parameter.rb +9 -10
- data/lib/rubocop/cop/style/empty_lambda_parameter.rb +9 -10
- data/lib/rubocop/cop/style/guard_clause.rb +1 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +6 -5
- data/lib/rubocop/cop/style/hash_transform_keys.rb +14 -1
- data/lib/rubocop/cop/style/hash_transform_values.rb +14 -1
- data/lib/rubocop/cop/style/if_unless_modifier.rb +2 -2
- data/lib/rubocop/cop/style/keyword_parameters_order.rb +58 -0
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +10 -1
- data/lib/rubocop/cop/style/multiline_when_then.rb +2 -2
- data/lib/rubocop/cop/style/negated_if.rb +6 -6
- data/lib/rubocop/cop/style/negated_unless.rb +6 -6
- data/lib/rubocop/cop/style/negated_while.rb +7 -15
- data/lib/rubocop/cop/style/nested_modifier.rb +10 -13
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +11 -11
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +14 -16
- data/lib/rubocop/cop/style/next.rb +10 -14
- data/lib/rubocop/cop/style/nil_comparison.rb +11 -11
- data/lib/rubocop/cop/style/non_nil_check.rb +32 -26
- data/lib/rubocop/cop/style/not.rb +19 -26
- data/lib/rubocop/cop/style/numeric_literal_prefix.rb +4 -9
- data/lib/rubocop/cop/style/numeric_predicate.rb +4 -11
- data/lib/rubocop/cop/style/one_line_conditional.rb +71 -23
- data/lib/rubocop/cop/style/option_hash.rb +1 -1
- data/lib/rubocop/cop/style/optional_arguments.rb +1 -1
- data/lib/rubocop/cop/style/or_assignment.rb +13 -10
- data/lib/rubocop/cop/style/parallel_assignment.rb +14 -14
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +6 -6
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +13 -19
- data/lib/rubocop/cop/style/percent_q_literals.rb +8 -10
- data/lib/rubocop/cop/style/perl_backrefs.rb +8 -10
- data/lib/rubocop/cop/style/preferred_hash_methods.rb +9 -14
- data/lib/rubocop/cop/style/proc.rb +6 -6
- data/lib/rubocop/cop/style/raise_args.rb +13 -24
- data/lib/rubocop/cop/style/random_with_offset.rb +15 -16
- data/lib/rubocop/cop/style/redundant_assignment.rb +8 -10
- data/lib/rubocop/cop/style/redundant_begin.rb +7 -9
- data/lib/rubocop/cop/style/redundant_capital_w.rb +6 -9
- data/lib/rubocop/cop/style/redundant_condition.rb +5 -6
- data/lib/rubocop/cop/style/redundant_fetch_block.rb +3 -12
- data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +8 -8
- data/lib/rubocop/cop/style/redundant_freeze.rb +3 -6
- data/lib/rubocop/cop/style/redundant_interpolation.rb +25 -24
- data/lib/rubocop/cop/style/redundant_parentheses.rb +7 -9
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +6 -13
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +5 -14
- data/lib/rubocop/cop/style/redundant_self.rb +2 -2
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +116 -0
- data/lib/rubocop/cop/style/regexp_literal.rb +10 -21
- data/lib/rubocop/cop/style/rescue_modifier.rb +29 -9
- data/lib/rubocop/cop/style/return_nil.rb +5 -5
- data/lib/rubocop/cop/style/safe_navigation.rb +13 -12
- data/lib/rubocop/cop/style/sample.rb +10 -13
- data/lib/rubocop/cop/style/self_assignment.rb +26 -22
- data/lib/rubocop/cop/style/semicolon.rb +6 -9
- data/lib/rubocop/cop/style/send.rb +2 -2
- data/lib/rubocop/cop/style/signal_exception.rb +21 -19
- data/lib/rubocop/cop/style/single_line_block_params.rb +4 -2
- data/lib/rubocop/cop/style/single_line_methods.rb +17 -16
- data/lib/rubocop/cop/style/slicing_with_range.rb +4 -7
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +66 -0
- data/lib/rubocop/cop/style/special_global_vars.rb +10 -15
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +17 -21
- data/lib/rubocop/cop/style/stderr_puts.rb +4 -6
- data/lib/rubocop/cop/style/string_hash_keys.rb +6 -7
- data/lib/rubocop/cop/style/string_methods.rb +7 -17
- data/lib/rubocop/cop/style/strip.rb +8 -14
- data/lib/rubocop/cop/style/struct_inheritance.rb +3 -6
- data/lib/rubocop/cop/style/symbol_array.rb +5 -16
- data/lib/rubocop/cop/style/symbol_literal.rb +4 -6
- data/lib/rubocop/cop/style/symbol_proc.rb +14 -18
- data/lib/rubocop/cop/style/ternary_parentheses.rb +21 -20
- data/lib/rubocop/cop/style/trailing_body_on_class.rb +3 -6
- data/lib/rubocop/cop/style/trailing_body_on_method_definition.rb +4 -7
- data/lib/rubocop/cop/style/trailing_body_on_module.rb +3 -6
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +2 -5
- data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +2 -5
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +7 -6
- data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +2 -5
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +8 -17
- data/lib/rubocop/cop/style/trivial_accessors.rb +26 -30
- data/lib/rubocop/cop/style/unless_else.rb +5 -8
- data/lib/rubocop/cop/style/unpack_first.rb +4 -8
- data/lib/rubocop/cop/style/variable_interpolation.rb +7 -10
- data/lib/rubocop/cop/style/when_then.rb +4 -6
- data/lib/rubocop/cop/style/while_until_do.rb +6 -16
- data/lib/rubocop/cop/style/while_until_modifier.rb +6 -20
- data/lib/rubocop/cop/style/word_array.rb +5 -23
- data/lib/rubocop/cop/style/yoda_condition.rb +4 -15
- data/lib/rubocop/cop/style/zero_length_predicate.rb +11 -13
- data/lib/rubocop/cop/team.rb +1 -0
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cop/utils/format_string.rb +3 -5
- data/lib/rubocop/cop/variable_force.rb +2 -0
- data/lib/rubocop/cops_documentation_generator.rb +4 -2
- data/lib/rubocop/core_ext/string.rb +1 -1
- data/lib/rubocop/ext/regexp_node.rb +46 -0
- data/lib/rubocop/file_finder.rb +1 -0
- data/lib/rubocop/formatter/auto_gen_config_formatter.rb +2 -1
- data/lib/rubocop/formatter/html_formatter.rb +2 -0
- data/lib/rubocop/formatter/progress_formatter.rb +2 -1
- data/lib/rubocop/formatter/quiet_formatter.rb +1 -1
- data/lib/rubocop/formatter/simple_text_formatter.rb +36 -6
- data/lib/rubocop/name_similarity.rb +1 -0
- data/lib/rubocop/options.rb +3 -0
- data/lib/rubocop/remote_config.rb +1 -0
- data/lib/rubocop/result_cache.rb +1 -0
- data/lib/rubocop/rspec/cop_helper.rb +4 -1
- data/lib/rubocop/rspec/expect_offense.rb +10 -5
- data/lib/rubocop/rspec/shared_contexts.rb +12 -0
- data/lib/rubocop/runner.rb +1 -0
- data/lib/rubocop/string_interpreter.rb +3 -0
- data/lib/rubocop/target_finder.rb +1 -0
- data/lib/rubocop/target_ruby.rb +6 -0
- data/lib/rubocop/version.rb +2 -1
- data/lib/rubocop/yaml_duplication_checker.rb +1 -0
- metadata +15 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39db2826fa916853dc6641e30da24937e009a06b843daf1a7cdb2eca458dfaad
|
4
|
+
data.tar.gz: 9a4ffd95ff0401aeee427555d1baf51517e06580becfa9243dac9c75305998aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e502aeecd9ceaeec36624190f4e9b72d075eed552f2e6204e2e842db1a77758f5fd11336f01f400af45bb36b27f13885a27847b17b84595aeef90df6b0db63b
|
7
|
+
data.tar.gz: e7ecf12bfc331ef99870f03e034a5154765ceb93c159fdde0fdf8802609c81fa3459250eb3bf6aa7ee140d5c80958783614f5da81585ba75ad9e252afdb8fc50
|
data/README.md
CHANGED
@@ -49,7 +49,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
|
|
49
49
|
might want to use a conservative version lock in your `Gemfile`:
|
50
50
|
|
51
51
|
```rb
|
52
|
-
gem 'rubocop', '~> 0.
|
52
|
+
gem 'rubocop', '~> 0.90.0', require: false
|
53
53
|
```
|
54
54
|
|
55
55
|
## Quickstart
|
data/config/default.yml
CHANGED
@@ -399,7 +399,6 @@ Layout/DefEndAlignment:
|
|
399
399
|
SupportedStylesAlignWith:
|
400
400
|
- start_of_line
|
401
401
|
- def
|
402
|
-
AutoCorrect: false
|
403
402
|
Severity: warning
|
404
403
|
|
405
404
|
Layout/DotPosition:
|
@@ -436,6 +435,14 @@ Layout/EmptyLineAfterMagicComment:
|
|
436
435
|
Enabled: true
|
437
436
|
VersionAdded: '0.49'
|
438
437
|
|
438
|
+
Layout/EmptyLineAfterMultilineCondition:
|
439
|
+
Description: 'Enforces empty line after multiline condition.'
|
440
|
+
# This is disabled, because this style is not very common in practice.
|
441
|
+
Enabled: false
|
442
|
+
VersionAdded: '0.90'
|
443
|
+
Reference:
|
444
|
+
- https://github.com/airbnb/ruby#multiline-if-newline
|
445
|
+
|
439
446
|
Layout/EmptyLineBetweenDefs:
|
440
447
|
Description: 'Use empty lines between defs.'
|
441
448
|
StyleGuide: '#empty-lines-between-methods'
|
@@ -555,7 +562,6 @@ Layout/EndAlignment:
|
|
555
562
|
- keyword
|
556
563
|
- variable
|
557
564
|
- start_of_line
|
558
|
-
AutoCorrect: false
|
559
565
|
Severity: warning
|
560
566
|
|
561
567
|
Layout/EndOfLine:
|
@@ -1427,6 +1433,11 @@ Lint/DuplicateMethods:
|
|
1427
1433
|
Enabled: true
|
1428
1434
|
VersionAdded: '0.29'
|
1429
1435
|
|
1436
|
+
Lint/DuplicateRequire:
|
1437
|
+
Description: 'Check for duplicate `require`s and `require_relative`s.'
|
1438
|
+
Enabled: pending
|
1439
|
+
VersionAdded: '0.90'
|
1440
|
+
|
1430
1441
|
Lint/DuplicateRescueException:
|
1431
1442
|
Description: 'Checks that there are no repeated exceptions used in `rescue` expressions.'
|
1432
1443
|
Enabled: pending
|
@@ -1453,13 +1464,18 @@ Lint/EmptyEnsure:
|
|
1453
1464
|
Enabled: true
|
1454
1465
|
VersionAdded: '0.10'
|
1455
1466
|
VersionChanged: '0.48'
|
1456
|
-
AutoCorrect: false
|
1457
1467
|
|
1458
1468
|
Lint/EmptyExpression:
|
1459
1469
|
Description: 'Checks for empty expressions.'
|
1460
1470
|
Enabled: true
|
1461
1471
|
VersionAdded: '0.45'
|
1462
1472
|
|
1473
|
+
Lint/EmptyFile:
|
1474
|
+
Description: 'Enforces that Ruby source files are not empty.'
|
1475
|
+
Enabled: pending
|
1476
|
+
AllowComments: true
|
1477
|
+
VersionAdded: '0.90'
|
1478
|
+
|
1463
1479
|
Lint/EmptyInterpolation:
|
1464
1480
|
Description: 'Checks for empty string interpolation.'
|
1465
1481
|
Enabled: true
|
@@ -1856,6 +1872,11 @@ Lint/TopLevelReturnWithArgument:
|
|
1856
1872
|
Enabled: 'pending'
|
1857
1873
|
VersionAdded: '0.89'
|
1858
1874
|
|
1875
|
+
Lint/TrailingCommaInAttributeDeclaration:
|
1876
|
+
Description: 'This cop checks for trailing commas in attribute declarations.'
|
1877
|
+
Enabled: pending
|
1878
|
+
VersionAdded: '0.90'
|
1879
|
+
|
1859
1880
|
Lint/UnderscorePrefixedVariableName:
|
1860
1881
|
Description: 'Do not use prefix `_` for a variable that is used.'
|
1861
1882
|
Enabled: true
|
@@ -1931,6 +1952,13 @@ Lint/UselessElseWithoutRescue:
|
|
1931
1952
|
Enabled: true
|
1932
1953
|
VersionAdded: '0.17'
|
1933
1954
|
|
1955
|
+
Lint/UselessMethodDefinition:
|
1956
|
+
Description: 'Checks for useless method definitions.'
|
1957
|
+
Enabled: pending
|
1958
|
+
VersionAdded: '0.90'
|
1959
|
+
Safe: false
|
1960
|
+
AllowComments: true
|
1961
|
+
|
1934
1962
|
Lint/UselessSetterCall:
|
1935
1963
|
Description: 'Checks for useless setter call to a local variable.'
|
1936
1964
|
Enabled: true
|
@@ -2591,6 +2619,7 @@ Style/CaseLikeIf:
|
|
2591
2619
|
Description: 'This cop identifies places where `if-elsif` constructions can be replaced with `case-when`.'
|
2592
2620
|
StyleGuide: '#case-vs-if-else'
|
2593
2621
|
Enabled: 'pending'
|
2622
|
+
Safe: false
|
2594
2623
|
VersionAdded: '0.88'
|
2595
2624
|
|
2596
2625
|
Style/CharacterLiteral:
|
@@ -2608,7 +2637,6 @@ Style/ClassAndModuleChildren:
|
|
2608
2637
|
# have the knowledge to perform either operation safely and thus requires
|
2609
2638
|
# manual oversight.
|
2610
2639
|
SafeAutoCorrect: false
|
2611
|
-
AutoCorrect: false
|
2612
2640
|
Enabled: true
|
2613
2641
|
VersionAdded: '0.19'
|
2614
2642
|
#
|
@@ -2647,6 +2675,16 @@ Style/ClassMethods:
|
|
2647
2675
|
VersionAdded: '0.9'
|
2648
2676
|
VersionChanged: '0.20'
|
2649
2677
|
|
2678
|
+
Style/ClassMethodsDefinitions:
|
2679
|
+
Description: 'Enforces using `def self.method_name` or `class << self` to define class methods.'
|
2680
|
+
StyleGuide: '#def-self-class-methods'
|
2681
|
+
Enabled: false
|
2682
|
+
VersionAdded: '0.89'
|
2683
|
+
EnforcedStyle: def_self
|
2684
|
+
SupportedStyles:
|
2685
|
+
- def_self
|
2686
|
+
- self_class
|
2687
|
+
|
2650
2688
|
Style/ClassVars:
|
2651
2689
|
Description: 'Avoid the use of class variables.'
|
2652
2690
|
StyleGuide: '#no-class-vars'
|
@@ -2687,6 +2725,14 @@ Style/ColonMethodDefinition:
|
|
2687
2725
|
Enabled: true
|
2688
2726
|
VersionAdded: '0.52'
|
2689
2727
|
|
2728
|
+
Style/CombinableLoops:
|
2729
|
+
Description: >-
|
2730
|
+
Checks for places where multiple consecutive loops over the same data
|
2731
|
+
can be combined into a single loop.
|
2732
|
+
Enabled: pending
|
2733
|
+
Safe: false
|
2734
|
+
VersionAdded: '0.90'
|
2735
|
+
|
2690
2736
|
Style/CommandLiteral:
|
2691
2737
|
Description: 'Use `` or %x around command literals.'
|
2692
2738
|
StyleGuide: '#percent-x'
|
@@ -3021,7 +3067,7 @@ Style/FrozenStringLiteralComment:
|
|
3021
3067
|
# `never` will enforce that the frozen string literal comment does not
|
3022
3068
|
# exist in a file.
|
3023
3069
|
- never
|
3024
|
-
|
3070
|
+
SafeAutoCorrect: false
|
3025
3071
|
|
3026
3072
|
Style/GlobalStdStream:
|
3027
3073
|
Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
|
@@ -3101,15 +3147,17 @@ Style/HashSyntax:
|
|
3101
3147
|
PreferHashRocketsForNonAlnumEndingSymbols: false
|
3102
3148
|
|
3103
3149
|
Style/HashTransformKeys:
|
3104
|
-
Description: 'Prefer `transform_keys` over `each_with_object`
|
3150
|
+
Description: 'Prefer `transform_keys` over `each_with_object`, `map`, or `to_h`.'
|
3105
3151
|
Enabled: 'pending'
|
3106
3152
|
VersionAdded: '0.80'
|
3153
|
+
VersionChanged: '0.90'
|
3107
3154
|
Safe: false
|
3108
3155
|
|
3109
3156
|
Style/HashTransformValues:
|
3110
|
-
Description: 'Prefer `transform_values` over `each_with_object`
|
3157
|
+
Description: 'Prefer `transform_values` over `each_with_object`, `map`, or `to_h`.'
|
3111
3158
|
Enabled: 'pending'
|
3112
3159
|
VersionAdded: '0.80'
|
3160
|
+
VersionChanged: '0.90'
|
3113
3161
|
Safe: false
|
3114
3162
|
|
3115
3163
|
Style/IdenticalConditionalBranches:
|
@@ -3206,6 +3254,12 @@ Style/IpAddresses:
|
|
3206
3254
|
- "::"
|
3207
3255
|
# :: is a valid IPv6 address, but could potentially be legitimately in code
|
3208
3256
|
|
3257
|
+
Style/KeywordParametersOrder:
|
3258
|
+
Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
|
3259
|
+
StyleGuide: '#keyword-parameters-order'
|
3260
|
+
Enabled: pending
|
3261
|
+
VersionAdded: '0.90'
|
3262
|
+
|
3209
3263
|
Style/Lambda:
|
3210
3264
|
Description: 'Use the new lambda literal syntax for single-line blocks.'
|
3211
3265
|
StyleGuide: '#lambda-multi-line'
|
@@ -3579,7 +3633,6 @@ Style/NumericPredicate:
|
|
3579
3633
|
# object. Switching these methods has to be done with knowledge of the types
|
3580
3634
|
# of the variables which rubocop doesn't have.
|
3581
3635
|
SafeAutoCorrect: false
|
3582
|
-
AutoCorrect: false
|
3583
3636
|
Enabled: true
|
3584
3637
|
VersionAdded: '0.42'
|
3585
3638
|
VersionChanged: '0.59'
|
@@ -3595,12 +3648,13 @@ Style/NumericPredicate:
|
|
3595
3648
|
|
3596
3649
|
Style/OneLineConditional:
|
3597
3650
|
Description: >-
|
3598
|
-
Favor the ternary operator(?:) over
|
3599
|
-
if/then/else/end constructs.
|
3651
|
+
Favor the ternary operator (?:) or multi-line constructs over
|
3652
|
+
single-line if/then/else/end constructs.
|
3600
3653
|
StyleGuide: '#ternary-operator'
|
3601
3654
|
Enabled: true
|
3655
|
+
AlwaysCorrectToMultiline: false
|
3602
3656
|
VersionAdded: '0.9'
|
3603
|
-
VersionChanged: '0.
|
3657
|
+
VersionChanged: '0.90'
|
3604
3658
|
|
3605
3659
|
Style/OptionHash:
|
3606
3660
|
Description: "Don't use option hashes when you can use keyword arguments."
|
@@ -3831,6 +3885,12 @@ Style/RedundantSelf:
|
|
3831
3885
|
VersionAdded: '0.10'
|
3832
3886
|
VersionChanged: '0.13'
|
3833
3887
|
|
3888
|
+
Style/RedundantSelfAssignment:
|
3889
|
+
Description: 'Checks for places where redundant assignments are made for in place modification methods.'
|
3890
|
+
Enabled: pending
|
3891
|
+
Safe: false
|
3892
|
+
VersionAdded: '0.90'
|
3893
|
+
|
3834
3894
|
Style/RedundantSort:
|
3835
3895
|
Description: >-
|
3836
3896
|
Use `min` instead of `sort.first`,
|
@@ -3983,6 +4043,14 @@ Style/SlicingWithRange:
|
|
3983
4043
|
VersionAdded: '0.83'
|
3984
4044
|
Safe: false
|
3985
4045
|
|
4046
|
+
Style/SoleNestedConditional:
|
4047
|
+
Description: >-
|
4048
|
+
Finds sole nested conditional nodes
|
4049
|
+
which can be merged into outer conditional node.
|
4050
|
+
Enabled: pending
|
4051
|
+
VersionAdded: '0.89'
|
4052
|
+
AllowModifier: false
|
4053
|
+
|
3986
4054
|
Style/SpecialGlobalVars:
|
3987
4055
|
Description: 'Avoid Perl-style global variables.'
|
3988
4056
|
StyleGuide: '#no-cryptic-perlisms'
|
data/lib/rubocop.rb
CHANGED
@@ -9,6 +9,7 @@ require 'regexp_parser'
|
|
9
9
|
require 'unicode/display_width/no_string_ext'
|
10
10
|
require 'rubocop-ast'
|
11
11
|
require_relative 'rubocop/ast_aliases'
|
12
|
+
require_relative 'rubocop/ext/regexp_node'
|
12
13
|
|
13
14
|
require_relative 'rubocop/version'
|
14
15
|
|
@@ -34,6 +35,7 @@ require_relative 'rubocop/cop/registry'
|
|
34
35
|
require_relative 'rubocop/cop/base'
|
35
36
|
require_relative 'rubocop/cop/cop'
|
36
37
|
require_relative 'rubocop/cop/commissioner'
|
38
|
+
require_relative 'rubocop/cop/documentation'
|
37
39
|
require_relative 'rubocop/cop/corrector'
|
38
40
|
require_relative 'rubocop/cop/force'
|
39
41
|
require_relative 'rubocop/cop/severity'
|
@@ -116,6 +118,7 @@ require_relative 'rubocop/cop/mixin/trailing_comma'
|
|
116
118
|
require_relative 'rubocop/cop/mixin/uncommunicative_name'
|
117
119
|
require_relative 'rubocop/cop/mixin/unused_argument'
|
118
120
|
require_relative 'rubocop/cop/mixin/visibility_help'
|
121
|
+
require_relative 'rubocop/cop/mixin/comments_help' # relies on visibility_help
|
119
122
|
|
120
123
|
require_relative 'rubocop/cop/utils/format_string'
|
121
124
|
|
@@ -165,6 +168,7 @@ require_relative 'rubocop/cop/layout/else_alignment'
|
|
165
168
|
require_relative 'rubocop/cop/layout/empty_comment'
|
166
169
|
require_relative 'rubocop/cop/layout/empty_line_after_guard_clause'
|
167
170
|
require_relative 'rubocop/cop/layout/empty_line_after_magic_comment'
|
171
|
+
require_relative 'rubocop/cop/layout/empty_line_after_multiline_condition'
|
168
172
|
require_relative 'rubocop/cop/layout/empty_line_between_defs'
|
169
173
|
require_relative 'rubocop/cop/layout/empty_lines_around_access_modifier'
|
170
174
|
require_relative 'rubocop/cop/layout/empty_lines_around_arguments'
|
@@ -255,12 +259,14 @@ require_relative 'rubocop/cop/lint/duplicate_case_condition'
|
|
255
259
|
require_relative 'rubocop/cop/lint/duplicate_elsif_condition'
|
256
260
|
require_relative 'rubocop/cop/lint/duplicate_hash_key'
|
257
261
|
require_relative 'rubocop/cop/lint/duplicate_methods'
|
262
|
+
require_relative 'rubocop/cop/lint/duplicate_require'
|
258
263
|
require_relative 'rubocop/cop/lint/duplicate_rescue_exception'
|
259
264
|
require_relative 'rubocop/cop/lint/each_with_object_argument'
|
260
265
|
require_relative 'rubocop/cop/lint/else_layout'
|
261
266
|
require_relative 'rubocop/cop/lint/empty_conditional_body'
|
262
267
|
require_relative 'rubocop/cop/lint/empty_ensure'
|
263
268
|
require_relative 'rubocop/cop/lint/empty_expression'
|
269
|
+
require_relative 'rubocop/cop/lint/empty_file'
|
264
270
|
require_relative 'rubocop/cop/lint/empty_interpolation'
|
265
271
|
require_relative 'rubocop/cop/lint/empty_when'
|
266
272
|
require_relative 'rubocop/cop/lint/ensure_return'
|
@@ -320,6 +326,7 @@ require_relative 'rubocop/cop/lint/suppressed_exception'
|
|
320
326
|
require_relative 'rubocop/cop/lint/syntax'
|
321
327
|
require_relative 'rubocop/cop/lint/to_json'
|
322
328
|
require_relative 'rubocop/cop/lint/top_level_return_with_argument'
|
329
|
+
require_relative 'rubocop/cop/lint/trailing_comma_in_attribute_declaration'
|
323
330
|
require_relative 'rubocop/cop/lint/underscore_prefixed_variable_name'
|
324
331
|
require_relative 'rubocop/cop/lint/unified_integer'
|
325
332
|
require_relative 'rubocop/cop/lint/unreachable_code'
|
@@ -331,6 +338,7 @@ require_relative 'rubocop/cop/lint/uri_regexp'
|
|
331
338
|
require_relative 'rubocop/cop/lint/useless_access_modifier'
|
332
339
|
require_relative 'rubocop/cop/lint/useless_assignment'
|
333
340
|
require_relative 'rubocop/cop/lint/useless_else_without_rescue'
|
341
|
+
require_relative 'rubocop/cop/lint/useless_method_definition'
|
334
342
|
require_relative 'rubocop/cop/lint/useless_setter_call'
|
335
343
|
require_relative 'rubocop/cop/lint/void'
|
336
344
|
|
@@ -385,10 +393,12 @@ require_relative 'rubocop/cop/style/character_literal'
|
|
385
393
|
require_relative 'rubocop/cop/style/class_and_module_children'
|
386
394
|
require_relative 'rubocop/cop/style/class_check'
|
387
395
|
require_relative 'rubocop/cop/style/class_methods'
|
396
|
+
require_relative 'rubocop/cop/style/class_methods_definitions'
|
388
397
|
require_relative 'rubocop/cop/style/class_vars'
|
389
398
|
require_relative 'rubocop/cop/style/collection_methods'
|
390
399
|
require_relative 'rubocop/cop/style/colon_method_call'
|
391
400
|
require_relative 'rubocop/cop/style/colon_method_definition'
|
401
|
+
require_relative 'rubocop/cop/style/combinable_loops'
|
392
402
|
require_relative 'rubocop/cop/style/command_literal'
|
393
403
|
require_relative 'rubocop/cop/style/comment_annotation'
|
394
404
|
require_relative 'rubocop/cop/style/commented_keyword'
|
@@ -442,6 +452,7 @@ require_relative 'rubocop/cop/style/infinite_loop'
|
|
442
452
|
require_relative 'rubocop/cop/style/inverse_methods'
|
443
453
|
require_relative 'rubocop/cop/style/inline_comment'
|
444
454
|
require_relative 'rubocop/cop/style/ip_addresses'
|
455
|
+
require_relative 'rubocop/cop/style/keyword_parameters_order'
|
445
456
|
require_relative 'rubocop/cop/style/lambda'
|
446
457
|
require_relative 'rubocop/cop/style/lambda_call'
|
447
458
|
require_relative 'rubocop/cop/style/line_end_concatenation'
|
@@ -450,6 +461,8 @@ require_relative 'rubocop/cop/style/method_call_with_args_parentheses'
|
|
450
461
|
require_relative 'rubocop/cop/style/redundant_assignment'
|
451
462
|
require_relative 'rubocop/cop/style/redundant_fetch_block'
|
452
463
|
require_relative 'rubocop/cop/style/redundant_file_extension_in_require'
|
464
|
+
require_relative 'rubocop/cop/style/redundant_self_assignment'
|
465
|
+
require_relative 'rubocop/cop/style/sole_nested_conditional'
|
453
466
|
require_relative 'rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses'
|
454
467
|
require_relative 'rubocop/cop/style/method_call_with_args_parentheses/require_parentheses'
|
455
468
|
require_relative 'rubocop/cop/style/method_called_on_do_end_block'
|
data/lib/rubocop/cached_data.rb
CHANGED
data/lib/rubocop/cli/command.rb
CHANGED
@@ -4,12 +4,17 @@ module RuboCop
|
|
4
4
|
# This class parses the special `rubocop:disable` comments in a source
|
5
5
|
# and provides a way to check if each cop is enabled at arbitrary line.
|
6
6
|
class CommentConfig
|
7
|
+
# @api private
|
7
8
|
REDUNDANT_DISABLE = 'Lint/RedundantCopDisableDirective'
|
8
9
|
|
10
|
+
# @api private
|
9
11
|
COP_NAME_PATTERN = '([A-Z]\w+/)?(?:[A-Z]\w+)'
|
12
|
+
# @api private
|
10
13
|
COP_NAMES_PATTERN = "(?:#{COP_NAME_PATTERN} , )*#{COP_NAME_PATTERN}"
|
14
|
+
# @api private
|
11
15
|
COPS_PATTERN = "(all|#{COP_NAMES_PATTERN})"
|
12
16
|
|
17
|
+
# @api private
|
13
18
|
COMMENT_DIRECTIVE_REGEXP = Regexp.new(
|
14
19
|
"# rubocop : ((?:disable|enable|todo))\\b #{COPS_PATTERN}"
|
15
20
|
.gsub(' ', '\s*')
|
@@ -140,22 +140,33 @@ module RuboCop
|
|
140
140
|
@project_root ||= find_project_root
|
141
141
|
end
|
142
142
|
|
143
|
+
PENDING_BANNER = <<~BANNER
|
144
|
+
The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.
|
145
|
+
|
146
|
+
Please also note that can also opt-in to new cops by default by adding this to your config:
|
147
|
+
AllCops:
|
148
|
+
NewCops: enable
|
149
|
+
BANNER
|
150
|
+
|
143
151
|
def warn_on_pending_cops(pending_cops)
|
144
152
|
return if pending_cops.empty?
|
145
153
|
|
146
|
-
warn Rainbow(
|
147
|
-
'configured. Please set Enabled to either `true` or ' \
|
148
|
-
'`false` in your `.rubocop.yml` file:').yellow
|
154
|
+
warn Rainbow(PENDING_BANNER).yellow
|
149
155
|
|
150
156
|
pending_cops.each do |cop|
|
151
|
-
|
152
|
-
|
153
|
-
warn Rainbow(" - #{cop.name} (#{version})").yellow
|
157
|
+
warn_pending_cop cop
|
154
158
|
end
|
155
159
|
|
156
160
|
warn Rainbow('For more information: https://docs.rubocop.org/rubocop/versioning.html').yellow
|
157
161
|
end
|
158
162
|
|
163
|
+
def warn_pending_cop(cop)
|
164
|
+
version = cop.metadata['VersionAdded'] || 'N/A'
|
165
|
+
|
166
|
+
warn Rainbow("#{cop.name}: # (new in #{version})").yellow
|
167
|
+
warn Rainbow(' Enabled: true').yellow
|
168
|
+
end
|
169
|
+
|
159
170
|
# Merges the given configuration with the default one.
|
160
171
|
def merge_with_default(config, config_file, unset_nil: true)
|
161
172
|
resolver.merge_with_default(config, config_file, unset_nil: unset_nil)
|