rubocop 0.72.0 → 0.76.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 +2 -1
- data/bin/console +1 -0
- data/config/default.yml +93 -56
- data/lib/rubocop.rb +21 -10
- data/lib/rubocop/ast/builder.rb +1 -0
- data/lib/rubocop/ast/node.rb +12 -14
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +4 -4
- data/lib/rubocop/ast/node/return_node.rb +24 -0
- data/lib/rubocop/ast/traversal.rb +3 -3
- data/lib/rubocop/cli.rb +7 -4
- data/lib/rubocop/comment_config.rb +5 -4
- data/lib/rubocop/config.rb +28 -537
- data/lib/rubocop/config_loader.rb +21 -3
- data/lib/rubocop/config_loader_resolver.rb +4 -3
- data/lib/rubocop/config_obsoletion.rb +222 -0
- data/lib/rubocop/config_validator.rb +248 -0
- data/lib/rubocop/cop/autocorrect_logic.rb +71 -1
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -1
- data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -1
- data/lib/rubocop/cop/commissioner.rb +18 -16
- data/lib/rubocop/cop/cop.rb +49 -14
- data/lib/rubocop/cop/corrector.rb +10 -10
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +43 -17
- data/lib/rubocop/cop/correctors/empty_line_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -2
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +1 -1
- data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +1 -1
- data/lib/rubocop/cop/generator.rb +4 -4
- data/lib/rubocop/cop/generator/configuration_injector.rb +9 -4
- data/lib/rubocop/cop/generator/require_file_injector.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/node_destructuring.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +2 -2
- data/lib/rubocop/cop/layout/align_hash.rb +6 -2
- data/lib/rubocop/cop/layout/block_alignment.rb +3 -3
- data/lib/rubocop/cop/layout/class_structure.rb +1 -1
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/comment_indentation.rb +10 -13
- data/lib/rubocop/cop/layout/empty_comment.rb +7 -16
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +22 -7
- data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +2 -2
- data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +2 -2
- data/lib/rubocop/cop/layout/end_of_line.rb +8 -3
- data/lib/rubocop/cop/layout/extra_spacing.rb +14 -59
- data/lib/rubocop/cop/layout/indent_assignment.rb +10 -1
- data/lib/rubocop/cop/layout/indent_first_argument.rb +10 -8
- data/lib/rubocop/cop/layout/indent_first_hash_element.rb +1 -1
- data/lib/rubocop/cop/layout/indent_heredoc.rb +4 -3
- data/lib/rubocop/cop/layout/indentation_width.rb +20 -6
- data/lib/rubocop/cop/layout/leading_comment_space.rb +28 -0
- data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +24 -2
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +20 -4
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +5 -1
- data/lib/rubocop/cop/layout/space_around_operators.rb +42 -23
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +9 -7
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +8 -5
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +21 -2
- data/lib/rubocop/cop/layout/space_inside_parens.rb +6 -6
- data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +24 -40
- data/lib/rubocop/cop/layout/tab.rb +10 -22
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +18 -2
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +17 -4
- data/lib/rubocop/cop/lint/big_decimal_new.rb +1 -1
- data/lib/rubocop/cop/lint/debugger.rb +4 -6
- data/lib/rubocop/cop/lint/duplicate_methods.rb +3 -3
- data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -1
- data/lib/rubocop/cop/lint/empty_interpolation.rb +4 -4
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +62 -5
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +11 -37
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -1
- data/lib/rubocop/cop/lint/inherit_exception.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +7 -8
- data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +2 -2
- data/lib/rubocop/cop/lint/multiple_compare.rb +1 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +3 -3
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +1 -1
- data/lib/rubocop/cop/lint/number_conversion.rb +3 -3
- data/lib/rubocop/cop/lint/rand_one.rb +1 -1
- data/lib/rubocop/cop/lint/{unneeded_cop_disable_directive.rb → redundant_cop_disable_directive.rb} +24 -24
- data/lib/rubocop/cop/lint/{unneeded_cop_enable_directive.rb → redundant_cop_enable_directive.rb} +6 -8
- data/lib/rubocop/cop/lint/{unneeded_require_statement.rb → redundant_require_statement.rb} +2 -2
- data/lib/rubocop/cop/lint/{unneeded_splat_expansion.rb → redundant_splat_expansion.rb} +12 -7
- data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_with_object.rb +1 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +10 -11
- data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -1
- data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +91 -0
- data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +6 -6
- data/lib/rubocop/cop/lint/unified_integer.rb +1 -1
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
- data/lib/rubocop/cop/lint/unused_block_argument.rb +22 -6
- data/lib/rubocop/cop/lint/unused_method_argument.rb +23 -5
- data/lib/rubocop/cop/lint/uri_escape_unescape.rb +1 -1
- data/lib/rubocop/cop/lint/uri_regexp.rb +2 -2
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +6 -6
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +7 -26
- data/lib/rubocop/cop/message_annotator.rb +16 -7
- data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
- data/lib/rubocop/cop/metrics/class_length.rb +1 -1
- data/lib/rubocop/cop/metrics/line_length.rb +7 -4
- data/lib/rubocop/cop/metrics/module_length.rb +1 -1
- data/lib/rubocop/cop/metrics/parameter_lists.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +23 -6
- data/lib/rubocop/cop/migration/department_name.rb +44 -0
- data/lib/rubocop/cop/mixin/alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/def_node.rb +1 -1
- data/lib/rubocop/cop/mixin/documentation_comment.rb +0 -2
- data/lib/rubocop/cop/mixin/empty_parameter.rb +1 -1
- data/lib/rubocop/cop/mixin/enforce_superclass.rb +4 -4
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/interpolation.rb +27 -0
- data/lib/rubocop/cop/mixin/method_complexity.rb +3 -2
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +3 -3
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +87 -0
- data/lib/rubocop/cop/mixin/safe_mode.rb +2 -0
- data/lib/rubocop/cop/mixin/statement_modifier.rb +5 -2
- data/lib/rubocop/cop/mixin/surrounding_space.rb +7 -5
- data/lib/rubocop/cop/mixin/trailing_comma.rb +8 -6
- data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -1
- data/lib/rubocop/cop/naming/constant_name.rb +2 -2
- data/lib/rubocop/cop/naming/file_name.rb +12 -5
- data/lib/rubocop/cop/naming/method_name.rb +12 -1
- data/lib/rubocop/cop/naming/predicate_name.rb +1 -1
- data/lib/rubocop/cop/naming/variable_name.rb +1 -0
- data/lib/rubocop/cop/offense.rb +18 -7
- data/lib/rubocop/cop/registry.rb +22 -1
- data/lib/rubocop/cop/security/eval.rb +1 -1
- data/lib/rubocop/cop/security/json_load.rb +1 -1
- data/lib/rubocop/cop/security/marshal_load.rb +1 -1
- data/lib/rubocop/cop/security/open.rb +1 -1
- data/lib/rubocop/cop/security/yaml_load.rb +1 -1
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +1 -0
- data/lib/rubocop/cop/style/alias.rb +1 -1
- data/lib/rubocop/cop/style/attr.rb +2 -2
- data/lib/rubocop/cop/style/block_delimiters.rb +2 -1
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +35 -16
- data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
- data/lib/rubocop/cop/style/colon_method_call.rb +1 -1
- data/lib/rubocop/cop/style/comment_annotation.rb +5 -5
- data/lib/rubocop/cop/style/commented_keyword.rb +16 -30
- data/lib/rubocop/cop/style/conditional_assignment.rb +6 -8
- data/lib/rubocop/cop/style/constant_visibility.rb +14 -3
- data/lib/rubocop/cop/style/copyright.rb +11 -7
- data/lib/rubocop/cop/style/date_time.rb +3 -3
- data/lib/rubocop/cop/style/dir.rb +1 -1
- data/lib/rubocop/cop/style/documentation_method.rb +45 -1
- data/lib/rubocop/cop/style/double_cop_disable_directive.rb +55 -0
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
- data/lib/rubocop/cop/style/each_with_object.rb +1 -1
- data/lib/rubocop/cop/style/empty_case_condition.rb +2 -2
- data/lib/rubocop/cop/style/empty_literal.rb +2 -2
- data/lib/rubocop/cop/style/empty_method.rb +5 -5
- data/lib/rubocop/cop/style/eval_with_location.rb +2 -2
- data/lib/rubocop/cop/style/even_odd.rb +1 -1
- data/lib/rubocop/cop/style/expand_path_arguments.rb +4 -4
- data/lib/rubocop/cop/style/float_division.rb +4 -4
- data/lib/rubocop/cop/style/format_string.rb +17 -14
- data/lib/rubocop/cop/style/format_string_token.rb +19 -68
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +28 -33
- data/lib/rubocop/cop/style/guard_clause.rb +39 -10
- data/lib/rubocop/cop/style/hash_syntax.rb +4 -4
- data/lib/rubocop/cop/style/if_unless_modifier.rb +58 -15
- data/lib/rubocop/cop/style/infinite_loop.rb +5 -4
- data/lib/rubocop/cop/style/inverse_methods.rb +21 -15
- data/lib/rubocop/cop/style/lambda.rb +0 -2
- data/lib/rubocop/cop/style/line_end_concatenation.rb +14 -10
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +25 -25
- data/lib/rubocop/cop/style/method_def_parentheses.rb +17 -9
- data/lib/rubocop/cop/style/min_max.rb +1 -1
- data/lib/rubocop/cop/style/mixin_usage.rb +12 -2
- data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
- data/lib/rubocop/cop/style/multiline_when_then.rb +55 -0
- data/lib/rubocop/cop/style/multiple_comparison.rb +1 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +3 -3
- data/lib/rubocop/cop/style/nested_modifier.rb +22 -4
- data/lib/rubocop/cop/style/non_nil_check.rb +21 -9
- data/lib/rubocop/cop/style/numeric_predicate.rb +3 -3
- data/lib/rubocop/cop/style/option_hash.rb +1 -1
- data/lib/rubocop/cop/style/or_assignment.rb +8 -3
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +15 -1
- data/lib/rubocop/cop/style/random_with_offset.rb +6 -6
- data/lib/rubocop/cop/style/{unneeded_capital_w.rb → redundant_capital_w.rb} +1 -1
- data/lib/rubocop/cop/style/{unneeded_condition.rb → redundant_condition.rb} +3 -3
- data/lib/rubocop/cop/style/redundant_conditional.rb +2 -2
- data/lib/rubocop/cop/style/redundant_exception.rb +2 -2
- data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
- data/lib/rubocop/cop/style/{unneeded_interpolation.rb → redundant_interpolation.rb} +1 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +15 -6
- data/lib/rubocop/cop/style/{unneeded_percent_q.rb → redundant_percent_q.rb} +1 -1
- data/lib/rubocop/cop/style/redundant_return.rb +37 -21
- data/lib/rubocop/cop/style/redundant_self.rb +18 -1
- data/lib/rubocop/cop/style/{unneeded_sort.rb → redundant_sort.rb} +4 -4
- data/lib/rubocop/cop/style/redundant_sort_by.rb +1 -1
- data/lib/rubocop/cop/style/rescue_modifier.rb +24 -0
- data/lib/rubocop/cop/style/rescue_standard_error.rb +2 -2
- data/lib/rubocop/cop/style/return_nil.rb +1 -1
- data/lib/rubocop/cop/style/safe_navigation.rb +24 -4
- data/lib/rubocop/cop/style/sample.rb +1 -1
- data/lib/rubocop/cop/style/semicolon.rb +13 -2
- data/lib/rubocop/cop/style/single_line_methods.rb +8 -1
- data/lib/rubocop/cop/style/special_global_vars.rb +5 -7
- data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
- data/lib/rubocop/cop/style/string_hash_keys.rb +2 -2
- data/lib/rubocop/cop/style/strip.rb +1 -1
- data/lib/rubocop/cop/style/struct_inheritance.rb +3 -3
- data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
- data/lib/rubocop/cop/style/ternary_parentheses.rb +20 -1
- data/lib/rubocop/cop/style/trailing_method_end_statement.rb +4 -6
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/style/unpack_first.rb +1 -1
- data/lib/rubocop/cop/style/variable_interpolation.rb +6 -16
- data/lib/rubocop/cop/style/zero_length_predicate.rb +5 -5
- data/lib/rubocop/cop/team.rb +15 -14
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cop/utils/format_string.rb +120 -0
- data/lib/rubocop/cop/variable_force.rb +7 -5
- data/lib/rubocop/cop/variable_force/variable.rb +15 -2
- data/lib/rubocop/core_ext/string.rb +0 -24
- data/lib/rubocop/error.rb +23 -0
- data/lib/rubocop/formatter/clang_style_formatter.rb +8 -3
- data/lib/rubocop/formatter/emacs_style_formatter.rb +22 -9
- data/lib/rubocop/formatter/file_list_formatter.rb +1 -1
- data/lib/rubocop/formatter/formatter_set.rb +16 -15
- data/lib/rubocop/formatter/pacman_formatter.rb +80 -0
- data/lib/rubocop/formatter/simple_text_formatter.rb +16 -4
- data/lib/rubocop/formatter/tap_formatter.rb +17 -4
- data/lib/rubocop/magic_comment.rb +4 -0
- data/lib/rubocop/node_pattern.rb +5 -3
- data/lib/rubocop/options.rb +33 -21
- data/lib/rubocop/path_util.rb +1 -1
- data/lib/rubocop/processed_source.rb +4 -0
- data/lib/rubocop/result_cache.rb +1 -1
- data/lib/rubocop/rspec/expect_offense.rb +4 -1
- data/lib/rubocop/rspec/shared_contexts.rb +12 -0
- data/lib/rubocop/runner.rb +42 -31
- data/lib/rubocop/target_finder.rb +12 -4
- data/lib/rubocop/version.rb +1 -1
- metadata +21 -12
- data/lib/rubocop/cop/mixin/ignored_method_patterns.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd5622915d19930481b80ac553a18b3500306bca922491f83290451a3cd267c9
|
4
|
+
data.tar.gz: 73002e0e186887f12add4e88154bf2510280d531ecd66f73b9eb57fb842d7f2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a866f9130e0388351acd83aee37bf7a15f1e64c94c51a3d58f3c439b90cbffb5a173837b48aae3ba86ab8005bbe73e6b088c905000910c4cf523395c8887b39
|
7
|
+
data.tar.gz: e8c2655aa3c419850da067790d456ed96c67bb43eee41d4cd9389185dbb9965329f405a2146949062daf57cd15a8e0d375b00df4df09fbc03fd06d9369f213ce
|
data/README.md
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
[![Patreon](https://img.shields.io/badge/patreon-donate-orange.svg)](https://www.patreon.com/bbatsov)
|
10
10
|
[![OpenCollective](https://opencollective.com/rubocop/backers/badge.svg)](#open-collective-backers)
|
11
11
|
[![OpenCollective](https://opencollective.com/rubocop/sponsors/badge.svg)](#open-collective-sponsors)
|
12
|
+
[![Tidelift](https://tidelift.com/badges/package/rubygems/rubocop)](https://tidelift.com/subscription/pkg/rubygems-rubocop?utm_source=rubygems-rubocop&utm_medium=referral&utm_campaign=readme)
|
12
13
|
|
13
14
|
<p align="center">
|
14
15
|
<img src="https://raw.githubusercontent.com/rubocop-hq/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
|
@@ -52,7 +53,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
|
|
52
53
|
might want to use a conservative version lock in your `Gemfile`:
|
53
54
|
|
54
55
|
```rb
|
55
|
-
gem 'rubocop', '~> 0.
|
56
|
+
gem 'rubocop', '~> 0.76.0', require: false
|
56
57
|
```
|
57
58
|
|
58
59
|
## Quickstart
|
data/bin/console
CHANGED
data/config/default.yml
CHANGED
@@ -816,6 +816,8 @@ Layout/LeadingCommentSpace:
|
|
816
816
|
StyleGuide: '#hash-space'
|
817
817
|
Enabled: true
|
818
818
|
VersionAdded: '0.49'
|
819
|
+
VersionChanged: '0.73'
|
820
|
+
AllowDoxygenCommentStyle: false
|
819
821
|
|
820
822
|
Layout/MultilineArrayBraceLayout:
|
821
823
|
Description: >-
|
@@ -1510,6 +1512,29 @@ Lint/RandOne:
|
|
1510
1512
|
Enabled: true
|
1511
1513
|
VersionAdded: '0.36'
|
1512
1514
|
|
1515
|
+
Lint/RedundantCopDisableDirective:
|
1516
|
+
Description: >-
|
1517
|
+
Checks for rubocop:disable comments that can be removed.
|
1518
|
+
Note: this cop is not disabled when disabling all cops.
|
1519
|
+
It must be explicitly disabled.
|
1520
|
+
Enabled: true
|
1521
|
+
VersionAdded: '0.76'
|
1522
|
+
|
1523
|
+
Lint/RedundantCopEnableDirective:
|
1524
|
+
Description: Checks for rubocop:enable comments that can be removed.
|
1525
|
+
Enabled: true
|
1526
|
+
VersionAdded: '0.76'
|
1527
|
+
|
1528
|
+
Lint/RedundantRequireStatement:
|
1529
|
+
Description: 'Checks for unnecessary `require` statement.'
|
1530
|
+
Enabled: true
|
1531
|
+
VersionAdded: '0.76'
|
1532
|
+
|
1533
|
+
Lint/RedundantSplatExpansion:
|
1534
|
+
Description: 'Checks for splat unnecessarily being called on literals.'
|
1535
|
+
Enabled: true
|
1536
|
+
VersionChanged: '0.76'
|
1537
|
+
|
1513
1538
|
Lint/RedundantWithIndex:
|
1514
1539
|
Description: 'Checks for redundant `with_index`.'
|
1515
1540
|
Enabled: true
|
@@ -1589,6 +1614,11 @@ Lint/ScriptPermission:
|
|
1589
1614
|
VersionAdded: '0.49'
|
1590
1615
|
VersionChanged: '0.50'
|
1591
1616
|
|
1617
|
+
Lint/SendWithMixinArgument:
|
1618
|
+
Description: 'Checks for `send` method when using mixin.'
|
1619
|
+
Enabled: true
|
1620
|
+
VersionAdded: '0.75'
|
1621
|
+
|
1592
1622
|
Lint/ShadowedArgument:
|
1593
1623
|
Description: 'Avoid reassigning arguments before they were used.'
|
1594
1624
|
Enabled: true
|
@@ -1638,29 +1668,6 @@ Lint/UnifiedInteger:
|
|
1638
1668
|
Enabled: true
|
1639
1669
|
VersionAdded: '0.43'
|
1640
1670
|
|
1641
|
-
Lint/UnneededCopDisableDirective:
|
1642
|
-
Description: >-
|
1643
|
-
Checks for rubocop:disable comments that can be removed.
|
1644
|
-
Note: this cop is not disabled when disabling all cops.
|
1645
|
-
It must be explicitly disabled.
|
1646
|
-
Enabled: true
|
1647
|
-
VersionAdded: '0.53'
|
1648
|
-
|
1649
|
-
Lint/UnneededCopEnableDirective:
|
1650
|
-
Description: Checks for rubocop:enable comments that can be removed.
|
1651
|
-
Enabled: true
|
1652
|
-
VersionAdded: '0.53'
|
1653
|
-
|
1654
|
-
Lint/UnneededRequireStatement:
|
1655
|
-
Description: 'Checks for unnecessary `require` statement.'
|
1656
|
-
Enabled: true
|
1657
|
-
VersionAdded: '0.51'
|
1658
|
-
|
1659
|
-
Lint/UnneededSplatExpansion:
|
1660
|
-
Description: 'Checks for splat unnecessarily being called on literals.'
|
1661
|
-
Enabled: true
|
1662
|
-
VersionAdded: '0.43'
|
1663
|
-
|
1664
1671
|
Lint/UnreachableCode:
|
1665
1672
|
Description: 'Unreachable code.'
|
1666
1673
|
Enabled: true
|
@@ -1743,7 +1750,7 @@ Metrics/AbcSize:
|
|
1743
1750
|
branches, and conditions.
|
1744
1751
|
Reference:
|
1745
1752
|
- http://c2.com/cgi/wiki?AbcMetric
|
1746
|
-
- https://en.wikipedia.org/wiki/ABC_Software_Metric
|
1753
|
+
- https://en.wikipedia.org/wiki/ABC_Software_Metric
|
1747
1754
|
Enabled: true
|
1748
1755
|
VersionAdded: '0.27'
|
1749
1756
|
VersionChanged: '0.66'
|
@@ -1807,7 +1814,7 @@ Metrics/LineLength:
|
|
1807
1814
|
- https
|
1808
1815
|
# The IgnoreCopDirectives option causes the LineLength rule to ignore cop
|
1809
1816
|
# directives like '# rubocop: enable ...' when calculating a line's length.
|
1810
|
-
IgnoreCopDirectives:
|
1817
|
+
IgnoreCopDirectives: true
|
1811
1818
|
# The IgnoredPatterns option is a list of !ruby/regexp and/or string
|
1812
1819
|
# elements. Strings will be converted to Regexp objects. A line that matches
|
1813
1820
|
# any regular expression listed in this option will be ignored by LineLength.
|
@@ -1846,6 +1853,14 @@ Metrics/PerceivedComplexity:
|
|
1846
1853
|
VersionAdded: '0.25'
|
1847
1854
|
Max: 7
|
1848
1855
|
|
1856
|
+
################## Migration #############################
|
1857
|
+
|
1858
|
+
Migration/DepartmentName:
|
1859
|
+
Description: >-
|
1860
|
+
Check that cop names in rubocop:disable (etc) comments are
|
1861
|
+
given with department name.
|
1862
|
+
Enabled: false
|
1863
|
+
|
1849
1864
|
#################### Naming ##############################
|
1850
1865
|
|
1851
1866
|
Naming/AccessorMethodName:
|
@@ -1981,6 +1996,13 @@ Naming/MethodName:
|
|
1981
1996
|
SupportedStyles:
|
1982
1997
|
- snake_case
|
1983
1998
|
- camelCase
|
1999
|
+
# Method names matching patterns are always allowed.
|
2000
|
+
#
|
2001
|
+
# IgnoredPatterns:
|
2002
|
+
# - '\A\s*onSelectionBulkChange\s*'
|
2003
|
+
# - '\A\s*onSelectionCleared\s*'
|
2004
|
+
#
|
2005
|
+
IgnoredPatterns: []
|
1984
2006
|
|
1985
2007
|
Naming/PredicateName:
|
1986
2008
|
Description: 'Check the names of predicate methods.'
|
@@ -2053,6 +2075,7 @@ Naming/UncommunicativeMethodParamName:
|
|
2053
2075
|
- at
|
2054
2076
|
- ip
|
2055
2077
|
- db
|
2078
|
+
- os
|
2056
2079
|
# Blacklisted names that will register an offense
|
2057
2080
|
ForbiddenNames: []
|
2058
2081
|
|
@@ -2555,6 +2578,11 @@ Style/DocumentationMethod:
|
|
2555
2578
|
- 'test/**/*'
|
2556
2579
|
RequireForNonPublicMethods: false
|
2557
2580
|
|
2581
|
+
Style/DoubleCopDisableDirective:
|
2582
|
+
Description: 'Checks for double rubocop:disable comments on a single line.'
|
2583
|
+
Enabled: true
|
2584
|
+
VersionAdded: '0.73'
|
2585
|
+
|
2558
2586
|
Style/DoubleNegation:
|
2559
2587
|
Description: 'Checks for uses of double negation (!!).'
|
2560
2588
|
StyleGuide: '#no-bang-bang'
|
@@ -2698,7 +2726,7 @@ Style/FormatStringToken:
|
|
2698
2726
|
- template
|
2699
2727
|
- unannotated
|
2700
2728
|
VersionAdded: '0.49'
|
2701
|
-
VersionChanged: '0.
|
2729
|
+
VersionChanged: '0.75'
|
2702
2730
|
|
2703
2731
|
Style/FrozenStringLiteralComment:
|
2704
2732
|
Description: >-
|
@@ -2891,6 +2919,7 @@ Style/MethodCallWithArgsParentheses:
|
|
2891
2919
|
VersionChanged: '0.61'
|
2892
2920
|
IgnoreMacros: true
|
2893
2921
|
IgnoredMethods: []
|
2922
|
+
IgnoredPatterns: []
|
2894
2923
|
IncludedMacros: []
|
2895
2924
|
AllowParenthesesInMultilineCall: false
|
2896
2925
|
AllowParenthesesInChaining: false
|
@@ -3041,6 +3070,12 @@ Style/MultilineTernaryOperator:
|
|
3041
3070
|
Enabled: true
|
3042
3071
|
VersionAdded: '0.9'
|
3043
3072
|
|
3073
|
+
Style/MultilineWhenThen:
|
3074
|
+
Description: 'Do not use then for multi-line when statement.'
|
3075
|
+
StyleGuide: '#no-then'
|
3076
|
+
Enabled: true
|
3077
|
+
VersionAdded: '0.73'
|
3078
|
+
|
3044
3079
|
Style/MultipleComparison:
|
3045
3080
|
Description: >-
|
3046
3081
|
Avoid comparing a variable with multiple items in a conditional,
|
@@ -3367,6 +3402,16 @@ Style/RedundantBegin:
|
|
3367
3402
|
VersionAdded: '0.10'
|
3368
3403
|
VersionChanged: '0.21'
|
3369
3404
|
|
3405
|
+
Style/RedundantCapitalW:
|
3406
|
+
Description: 'Checks for %W when interpolation is not needed.'
|
3407
|
+
Enabled: true
|
3408
|
+
VersionAdded: '0.76'
|
3409
|
+
|
3410
|
+
Style/RedundantCondition:
|
3411
|
+
Description: 'Checks for unnecessary conditional expressions.'
|
3412
|
+
Enabled: true
|
3413
|
+
VersionAdded: '0.76'
|
3414
|
+
|
3370
3415
|
Style/RedundantConditional:
|
3371
3416
|
Description: "Don't return true/false from a conditional."
|
3372
3417
|
Enabled: true
|
@@ -3385,11 +3430,22 @@ Style/RedundantFreeze:
|
|
3385
3430
|
VersionAdded: '0.34'
|
3386
3431
|
VersionChanged: '0.66'
|
3387
3432
|
|
3433
|
+
Style/RedundantInterpolation:
|
3434
|
+
Description: 'Checks for strings that are just an interpolated expression.'
|
3435
|
+
Enabled: true
|
3436
|
+
VersionAdded: '0.76'
|
3437
|
+
|
3388
3438
|
Style/RedundantParentheses:
|
3389
3439
|
Description: "Checks for parentheses that seem not to serve any purpose."
|
3390
3440
|
Enabled: true
|
3391
3441
|
VersionAdded: '0.36'
|
3392
3442
|
|
3443
|
+
Style/RedundantPercentQ:
|
3444
|
+
Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
|
3445
|
+
StyleGuide: '#percent-q'
|
3446
|
+
Enabled: true
|
3447
|
+
VersionAdded: '0.76'
|
3448
|
+
|
3393
3449
|
Style/RedundantReturn:
|
3394
3450
|
Description: "Don't use return where it's not required."
|
3395
3451
|
StyleGuide: '#no-explicit-return'
|
@@ -3406,6 +3462,13 @@ Style/RedundantSelf:
|
|
3406
3462
|
VersionAdded: '0.10'
|
3407
3463
|
VersionChanged: '0.13'
|
3408
3464
|
|
3465
|
+
Style/RedundantSort:
|
3466
|
+
Description: >-
|
3467
|
+
Use `min` instead of `sort.first`,
|
3468
|
+
`max_by` instead of `sort_by...last`, etc.
|
3469
|
+
Enabled: true
|
3470
|
+
VersionAdded: '0.76'
|
3471
|
+
|
3409
3472
|
Style/RedundantSortBy:
|
3410
3473
|
Description: 'Use `sort` instead of `sort_by { |x| x }`.'
|
3411
3474
|
Enabled: true
|
@@ -3572,6 +3635,8 @@ Style/StringHashKeys:
|
|
3572
3635
|
StyleGuide: '#symbols-as-keys'
|
3573
3636
|
Enabled: false
|
3574
3637
|
VersionAdded: '0.52'
|
3638
|
+
VersionChanged: '0.75'
|
3639
|
+
Safe: false
|
3575
3640
|
|
3576
3641
|
Style/StringLiterals:
|
3577
3642
|
Description: 'Checks if uses of quotes match the configured preference.'
|
@@ -3791,35 +3856,6 @@ Style/UnlessElse:
|
|
3791
3856
|
Enabled: true
|
3792
3857
|
VersionAdded: '0.9'
|
3793
3858
|
|
3794
|
-
Style/UnneededCapitalW:
|
3795
|
-
Description: 'Checks for %W when interpolation is not needed.'
|
3796
|
-
Enabled: true
|
3797
|
-
VersionAdded: '0.21'
|
3798
|
-
VersionChanged: '0.24'
|
3799
|
-
|
3800
|
-
Style/UnneededCondition:
|
3801
|
-
Description: 'Checks for unnecessary conditional expressions.'
|
3802
|
-
Enabled: true
|
3803
|
-
VersionAdded: '0.57'
|
3804
|
-
|
3805
|
-
Style/UnneededInterpolation:
|
3806
|
-
Description: 'Checks for strings that are just an interpolated expression.'
|
3807
|
-
Enabled: true
|
3808
|
-
VersionAdded: '0.36'
|
3809
|
-
|
3810
|
-
Style/UnneededPercentQ:
|
3811
|
-
Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
|
3812
|
-
StyleGuide: '#percent-q'
|
3813
|
-
Enabled: true
|
3814
|
-
VersionAdded: '0.24'
|
3815
|
-
|
3816
|
-
Style/UnneededSort:
|
3817
|
-
Description: >-
|
3818
|
-
Use `min` instead of `sort.first`,
|
3819
|
-
`max_by` instead of `sort_by...last`, etc.
|
3820
|
-
Enabled: true
|
3821
|
-
VersionAdded: '0.55'
|
3822
|
-
|
3823
3859
|
Style/UnpackFirst:
|
3824
3860
|
Description: >-
|
3825
3861
|
Checks for accessing the first element of `String#unpack`
|
@@ -3890,8 +3926,9 @@ Style/YodaCondition:
|
|
3890
3926
|
- require_for_all_comparison_operators
|
3891
3927
|
# enforce yoda only for equality operators: `!=` and `==`
|
3892
3928
|
- require_for_equality_operators_only
|
3929
|
+
Safe: false
|
3893
3930
|
VersionAdded: '0.49'
|
3894
|
-
VersionChanged: '0.
|
3931
|
+
VersionChanged: '0.75'
|
3895
3932
|
|
3896
3933
|
Style/ZeroLengthPredicate:
|
3897
3934
|
Description: 'Use #empty? when testing for objects of length 0.'
|
data/lib/rubocop.rb
CHANGED
@@ -55,6 +55,7 @@ require_relative 'rubocop/ast/node/range_node'
|
|
55
55
|
require_relative 'rubocop/ast/node/regexp_node'
|
56
56
|
require_relative 'rubocop/ast/node/resbody_node'
|
57
57
|
require_relative 'rubocop/ast/node/retry_node'
|
58
|
+
require_relative 'rubocop/ast/node/return_node'
|
58
59
|
require_relative 'rubocop/ast/node/self_class_node'
|
59
60
|
require_relative 'rubocop/ast/node/send_node'
|
60
61
|
require_relative 'rubocop/ast/node/str_node'
|
@@ -120,8 +121,8 @@ require_relative 'rubocop/cop/mixin/frozen_string_literal'
|
|
120
121
|
require_relative 'rubocop/cop/mixin/hash_alignment'
|
121
122
|
require_relative 'rubocop/cop/mixin/ignored_pattern'
|
122
123
|
require_relative 'rubocop/cop/mixin/ignored_methods'
|
123
|
-
require_relative 'rubocop/cop/mixin/ignored_method_patterns'
|
124
124
|
require_relative 'rubocop/cop/mixin/integer_node'
|
125
|
+
require_relative 'rubocop/cop/mixin/interpolation'
|
125
126
|
require_relative 'rubocop/cop/mixin/match_range'
|
126
127
|
require_relative 'rubocop/cop/mixin/method_complexity'
|
127
128
|
require_relative 'rubocop/cop/mixin/method_preference'
|
@@ -157,6 +158,10 @@ require_relative 'rubocop/cop/mixin/trailing_comma'
|
|
157
158
|
require_relative 'rubocop/cop/mixin/uncommunicative_name'
|
158
159
|
require_relative 'rubocop/cop/mixin/unused_argument'
|
159
160
|
|
161
|
+
require_relative 'rubocop/cop/utils/format_string'
|
162
|
+
|
163
|
+
require_relative 'rubocop/cop/migration/department_name'
|
164
|
+
|
160
165
|
require_relative 'rubocop/cop/correctors/alignment_corrector'
|
161
166
|
require_relative 'rubocop/cop/correctors/condition_corrector'
|
162
167
|
require_relative 'rubocop/cop/correctors/each_to_for_corrector'
|
@@ -317,6 +322,10 @@ require_relative 'rubocop/cop/lint/parentheses_as_grouped_expression'
|
|
317
322
|
require_relative 'rubocop/cop/lint/percent_string_array'
|
318
323
|
require_relative 'rubocop/cop/lint/percent_symbol_array'
|
319
324
|
require_relative 'rubocop/cop/lint/rand_one'
|
325
|
+
require_relative 'rubocop/cop/lint/redundant_cop_disable_directive'
|
326
|
+
require_relative 'rubocop/cop/lint/redundant_cop_enable_directive'
|
327
|
+
require_relative 'rubocop/cop/lint/redundant_require_statement'
|
328
|
+
require_relative 'rubocop/cop/lint/redundant_splat_expansion'
|
320
329
|
require_relative 'rubocop/cop/lint/redundant_with_index'
|
321
330
|
require_relative 'rubocop/cop/lint/redundant_with_object'
|
322
331
|
require_relative 'rubocop/cop/lint/regexp_as_condition'
|
@@ -328,6 +337,7 @@ require_relative 'rubocop/cop/lint/safe_navigation_consistency'
|
|
328
337
|
require_relative 'rubocop/cop/lint/safe_navigation_chain'
|
329
338
|
require_relative 'rubocop/cop/lint/safe_navigation_with_empty'
|
330
339
|
require_relative 'rubocop/cop/lint/script_permission'
|
340
|
+
require_relative 'rubocop/cop/lint/send_with_mixin_argument'
|
331
341
|
require_relative 'rubocop/cop/lint/shadowed_argument'
|
332
342
|
require_relative 'rubocop/cop/lint/shadowed_exception'
|
333
343
|
require_relative 'rubocop/cop/lint/shadowing_outer_local_variable'
|
@@ -336,10 +346,6 @@ require_relative 'rubocop/cop/lint/syntax'
|
|
336
346
|
require_relative 'rubocop/cop/lint/to_json'
|
337
347
|
require_relative 'rubocop/cop/lint/underscore_prefixed_variable_name'
|
338
348
|
require_relative 'rubocop/cop/lint/unified_integer'
|
339
|
-
require_relative 'rubocop/cop/lint/unneeded_cop_disable_directive'
|
340
|
-
require_relative 'rubocop/cop/lint/unneeded_cop_enable_directive'
|
341
|
-
require_relative 'rubocop/cop/lint/unneeded_require_statement'
|
342
|
-
require_relative 'rubocop/cop/lint/unneeded_splat_expansion'
|
343
349
|
require_relative 'rubocop/cop/lint/unreachable_code'
|
344
350
|
require_relative 'rubocop/cop/lint/unused_block_argument'
|
345
351
|
require_relative 'rubocop/cop/lint/unused_method_argument'
|
@@ -414,6 +420,7 @@ require_relative 'rubocop/cop/style/def_with_parentheses'
|
|
414
420
|
require_relative 'rubocop/cop/style/dir'
|
415
421
|
require_relative 'rubocop/cop/style/documentation_method'
|
416
422
|
require_relative 'rubocop/cop/style/documentation'
|
423
|
+
require_relative 'rubocop/cop/style/double_cop_disable_directive'
|
417
424
|
require_relative 'rubocop/cop/style/double_negation'
|
418
425
|
require_relative 'rubocop/cop/style/each_for_simple_loop'
|
419
426
|
require_relative 'rubocop/cop/style/each_with_object'
|
@@ -466,6 +473,7 @@ require_relative 'rubocop/cop/style/multiline_if_modifier'
|
|
466
473
|
require_relative 'rubocop/cop/style/multiline_method_signature'
|
467
474
|
require_relative 'rubocop/cop/style/multiline_memoization'
|
468
475
|
require_relative 'rubocop/cop/style/multiline_ternary_operator'
|
476
|
+
require_relative 'rubocop/cop/style/multiline_when_then'
|
469
477
|
require_relative 'rubocop/cop/style/multiple_comparison'
|
470
478
|
require_relative 'rubocop/cop/style/mutable_constant'
|
471
479
|
require_relative 'rubocop/cop/style/negated_if'
|
@@ -495,12 +503,17 @@ require_relative 'rubocop/cop/style/proc'
|
|
495
503
|
require_relative 'rubocop/cop/style/raise_args'
|
496
504
|
require_relative 'rubocop/cop/style/random_with_offset'
|
497
505
|
require_relative 'rubocop/cop/style/redundant_begin'
|
506
|
+
require_relative 'rubocop/cop/style/redundant_capital_w'
|
507
|
+
require_relative 'rubocop/cop/style/redundant_condition'
|
498
508
|
require_relative 'rubocop/cop/style/redundant_conditional'
|
499
509
|
require_relative 'rubocop/cop/style/redundant_exception'
|
500
510
|
require_relative 'rubocop/cop/style/redundant_freeze'
|
511
|
+
require_relative 'rubocop/cop/style/redundant_interpolation'
|
501
512
|
require_relative 'rubocop/cop/style/redundant_parentheses'
|
513
|
+
require_relative 'rubocop/cop/style/redundant_percent_q'
|
502
514
|
require_relative 'rubocop/cop/style/redundant_return'
|
503
515
|
require_relative 'rubocop/cop/style/redundant_self'
|
516
|
+
require_relative 'rubocop/cop/style/redundant_sort'
|
504
517
|
require_relative 'rubocop/cop/style/redundant_sort_by'
|
505
518
|
require_relative 'rubocop/cop/style/regexp_literal'
|
506
519
|
require_relative 'rubocop/cop/style/rescue_modifier'
|
@@ -537,11 +550,6 @@ require_relative 'rubocop/cop/style/trailing_method_end_statement'
|
|
537
550
|
require_relative 'rubocop/cop/style/trailing_underscore_variable'
|
538
551
|
require_relative 'rubocop/cop/style/trivial_accessors'
|
539
552
|
require_relative 'rubocop/cop/style/unless_else'
|
540
|
-
require_relative 'rubocop/cop/style/unneeded_capital_w'
|
541
|
-
require_relative 'rubocop/cop/style/unneeded_condition'
|
542
|
-
require_relative 'rubocop/cop/style/unneeded_interpolation'
|
543
|
-
require_relative 'rubocop/cop/style/unneeded_percent_q'
|
544
|
-
require_relative 'rubocop/cop/style/unneeded_sort'
|
545
553
|
require_relative 'rubocop/cop/style/unpack_first'
|
546
554
|
require_relative 'rubocop/cop/style/variable_interpolation'
|
547
555
|
require_relative 'rubocop/cop/style/when_then'
|
@@ -575,6 +583,7 @@ require_relative 'rubocop/formatter/progress_formatter'
|
|
575
583
|
require_relative 'rubocop/formatter/quiet_formatter'
|
576
584
|
require_relative 'rubocop/formatter/tap_formatter'
|
577
585
|
require_relative 'rubocop/formatter/worst_offenders_formatter'
|
586
|
+
require_relative 'rubocop/formatter/pacman_formatter'
|
578
587
|
# relies on progress formatter
|
579
588
|
require_relative 'rubocop/formatter/auto_gen_config_formatter'
|
580
589
|
|
@@ -584,7 +593,9 @@ require_relative 'rubocop/cached_data'
|
|
584
593
|
require_relative 'rubocop/config'
|
585
594
|
require_relative 'rubocop/config_loader_resolver'
|
586
595
|
require_relative 'rubocop/config_loader'
|
596
|
+
require_relative 'rubocop/config_obsoletion'
|
587
597
|
require_relative 'rubocop/config_store'
|
598
|
+
require_relative 'rubocop/config_validator'
|
588
599
|
require_relative 'rubocop/target_finder'
|
589
600
|
require_relative 'rubocop/token'
|
590
601
|
require_relative 'rubocop/comment_config'
|
data/lib/rubocop/ast/builder.rb
CHANGED
data/lib/rubocop/ast/node.rb
CHANGED
@@ -302,12 +302,10 @@ module RuboCop
|
|
302
302
|
|
303
303
|
## Destructuring
|
304
304
|
|
305
|
-
def_node_matcher :receiver,
|
305
|
+
def_node_matcher :receiver, <<~PATTERN
|
306
306
|
{(send $_ ...) (block (send $_ ...) ...)}
|
307
307
|
PATTERN
|
308
308
|
|
309
|
-
# Note: for masgn, #asgn_rhs will be an array node
|
310
|
-
def_node_matcher :asgn_rhs, '[assignment? (... $_)]'
|
311
309
|
def_node_matcher :str_content, '(str $_)'
|
312
310
|
|
313
311
|
def const_name
|
@@ -321,7 +319,7 @@ module RuboCop
|
|
321
319
|
end
|
322
320
|
end
|
323
321
|
|
324
|
-
def_node_matcher :defined_module0,
|
322
|
+
def_node_matcher :defined_module0, <<~PATTERN
|
325
323
|
{(class (const $_ $_) ...)
|
326
324
|
(module (const $_ $_) ...)
|
327
325
|
(casgn $_ $_ (send (const nil? {:Class :Module}) :new ...))
|
@@ -367,7 +365,7 @@ module RuboCop
|
|
367
365
|
end
|
368
366
|
|
369
367
|
# Some cops treat the shovel operator as a kind of assignment.
|
370
|
-
def_node_matcher :assignment_or_similar?,
|
368
|
+
def_node_matcher :assignment_or_similar?, <<~PATTERN
|
371
369
|
{assignment? (send _recv :<< ...)}
|
372
370
|
PATTERN
|
373
371
|
|
@@ -471,6 +469,10 @@ module RuboCop
|
|
471
469
|
parent&.send_type? && parent.arguments.include?(self)
|
472
470
|
end
|
473
471
|
|
472
|
+
def boolean_type?
|
473
|
+
true_type? || false_type?
|
474
|
+
end
|
475
|
+
|
474
476
|
def numeric_type?
|
475
477
|
int_type? || float_type?
|
476
478
|
end
|
@@ -479,11 +481,11 @@ module RuboCop
|
|
479
481
|
irange_type? || erange_type?
|
480
482
|
end
|
481
483
|
|
482
|
-
def_node_matcher :guard_clause?,
|
483
|
-
[{(send nil? {:raise :fail} ...) return break next} single_line?]
|
484
|
+
def_node_matcher :guard_clause?, <<~PATTERN
|
485
|
+
[${(send nil? {:raise :fail} ...) return break next} single_line?]
|
484
486
|
PATTERN
|
485
487
|
|
486
|
-
def_node_matcher :proc?,
|
488
|
+
def_node_matcher :proc?, <<~PATTERN
|
487
489
|
{(block (send nil? :proc) ...)
|
488
490
|
(block (send (const nil? :Proc) :new) ...)
|
489
491
|
(send (const nil? :Proc) :new)}
|
@@ -492,15 +494,11 @@ module RuboCop
|
|
492
494
|
def_node_matcher :lambda?, '(block (send nil? :lambda) ...)'
|
493
495
|
def_node_matcher :lambda_or_proc?, '{lambda? proc?}'
|
494
496
|
|
495
|
-
def_node_matcher :class_constructor?,
|
497
|
+
def_node_matcher :class_constructor?, <<~PATTERN
|
496
498
|
{ (send (const nil? {:Class :Module}) :new ...)
|
497
499
|
(block (send (const nil? {:Class :Module}) :new ...) ...)}
|
498
500
|
PATTERN
|
499
501
|
|
500
|
-
def_node_matcher :module_definition?, <<-PATTERN
|
501
|
-
{class module (casgn _ _ class_constructor?)}
|
502
|
-
PATTERN
|
503
|
-
|
504
502
|
# Some expressions are evaluated for their value, some for their side
|
505
503
|
# effects, and some for both
|
506
504
|
# If we know that an expression is useful only for its side effects, that
|
@@ -638,7 +636,7 @@ module RuboCop
|
|
638
636
|
end
|
639
637
|
end
|
640
638
|
|
641
|
-
def_node_matcher :new_class_or_module_block?,
|
639
|
+
def_node_matcher :new_class_or_module_block?, <<~PATTERN
|
642
640
|
^(casgn _ _ (block (send (const _ {:Class :Module}) :new) ...))
|
643
641
|
PATTERN
|
644
642
|
end
|