rubocop 1.6.1 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +4 -3
  4. data/config/default.yml +145 -19
  5. data/lib/rubocop.rb +16 -1
  6. data/lib/rubocop/cli/command/auto_genenerate_config.rb +5 -4
  7. data/lib/rubocop/comment_config.rb +6 -6
  8. data/lib/rubocop/config.rb +13 -7
  9. data/lib/rubocop/config_loader.rb +11 -14
  10. data/lib/rubocop/config_loader_resolver.rb +21 -4
  11. data/lib/rubocop/config_obsoletion.rb +5 -3
  12. data/lib/rubocop/config_store.rb +12 -1
  13. data/lib/rubocop/cop/base.rb +2 -1
  14. data/lib/rubocop/cop/exclude_limit.rb +26 -0
  15. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +3 -2
  16. data/lib/rubocop/cop/generator.rb +1 -3
  17. data/lib/rubocop/cop/internal_affairs.rb +6 -1
  18. data/lib/rubocop/cop/internal_affairs/empty_line_between_expect_offense_and_correction.rb +68 -0
  19. data/lib/rubocop/cop/internal_affairs/example_description.rb +89 -0
  20. data/lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb +61 -0
  21. data/lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb +64 -0
  22. data/lib/rubocop/cop/internal_affairs/style_detected_api_use.rb +145 -0
  23. data/lib/rubocop/cop/layout/class_structure.rb +7 -2
  24. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +56 -20
  25. data/lib/rubocop/cop/layout/first_argument_indentation.rb +16 -2
  26. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +14 -0
  27. data/lib/rubocop/cop/layout/line_length.rb +2 -1
  28. data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +2 -2
  29. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +3 -10
  30. data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +1 -0
  31. data/lib/rubocop/cop/layout/space_before_block_braces.rb +2 -0
  32. data/lib/rubocop/cop/layout/space_before_brackets.rb +67 -0
  33. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +13 -10
  34. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +2 -2
  35. data/lib/rubocop/cop/lint/ambiguous_assignment.rb +59 -0
  36. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +7 -2
  37. data/lib/rubocop/cop/lint/deprecated_constants.rb +80 -0
  38. data/lib/rubocop/cop/lint/duplicate_branch.rb +64 -2
  39. data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +44 -0
  40. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +10 -6
  41. data/lib/rubocop/cop/lint/number_conversion.rb +41 -6
  42. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +47 -0
  43. data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +39 -0
  44. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +2 -1
  45. data/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb +50 -0
  46. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +50 -17
  47. data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -11
  48. data/lib/rubocop/cop/lint/symbol_conversion.rb +103 -0
  49. data/lib/rubocop/cop/lint/triple_quotes.rb +71 -0
  50. data/lib/rubocop/cop/lint/unreachable_loop.rb +17 -0
  51. data/lib/rubocop/cop/message_annotator.rb +4 -1
  52. data/lib/rubocop/cop/metrics/block_nesting.rb +2 -2
  53. data/lib/rubocop/cop/metrics/parameter_lists.rb +5 -2
  54. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -1
  55. data/lib/rubocop/cop/mixin/allowed_identifiers.rb +18 -0
  56. data/lib/rubocop/cop/mixin/check_line_breakable.rb +5 -0
  57. data/lib/rubocop/cop/mixin/code_length.rb +3 -1
  58. data/lib/rubocop/cop/mixin/comments_help.rb +1 -11
  59. data/lib/rubocop/cop/mixin/configurable_max.rb +1 -0
  60. data/lib/rubocop/cop/mixin/first_element_line_break.rb +1 -1
  61. data/lib/rubocop/cop/mixin/method_complexity.rb +3 -1
  62. data/lib/rubocop/cop/mixin/uncommunicative_name.rb +5 -1
  63. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +59 -5
  64. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +38 -5
  65. data/lib/rubocop/cop/naming/variable_name.rb +2 -0
  66. data/lib/rubocop/cop/naming/variable_number.rb +2 -9
  67. data/lib/rubocop/cop/registry.rb +10 -0
  68. data/lib/rubocop/cop/severity.rb +3 -3
  69. data/lib/rubocop/cop/style/access_modifier_declarations.rb +3 -1
  70. data/lib/rubocop/cop/style/ascii_comments.rb +1 -1
  71. data/lib/rubocop/cop/style/collection_methods.rb +14 -1
  72. data/lib/rubocop/cop/style/commented_keyword.rb +22 -5
  73. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +49 -9
  74. data/lib/rubocop/cop/style/empty_literal.rb +6 -2
  75. data/lib/rubocop/cop/style/endless_method.rb +102 -0
  76. data/lib/rubocop/cop/style/eval_with_location.rb +63 -34
  77. data/lib/rubocop/cop/style/explicit_block_argument.rb +10 -0
  78. data/lib/rubocop/cop/style/float_division.rb +3 -0
  79. data/lib/rubocop/cop/style/for.rb +2 -0
  80. data/lib/rubocop/cop/style/format_string_token.rb +18 -2
  81. data/lib/rubocop/cop/style/hash_except.rb +95 -0
  82. data/lib/rubocop/cop/style/hash_like_case.rb +2 -1
  83. data/lib/rubocop/cop/style/if_inside_else.rb +22 -10
  84. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +120 -0
  85. data/lib/rubocop/cop/style/keyword_parameters_order.rb +12 -2
  86. data/lib/rubocop/cop/style/lambda_call.rb +2 -1
  87. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +7 -0
  88. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +16 -6
  89. data/lib/rubocop/cop/style/method_def_parentheses.rb +7 -0
  90. data/lib/rubocop/cop/style/multiline_method_signature.rb +26 -1
  91. data/lib/rubocop/cop/style/multiline_when_then.rb +3 -1
  92. data/lib/rubocop/cop/style/mutable_constant.rb +13 -3
  93. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +4 -0
  94. data/lib/rubocop/cop/style/nil_comparison.rb +3 -0
  95. data/lib/rubocop/cop/style/non_nil_check.rb +23 -13
  96. data/lib/rubocop/cop/style/numeric_literals.rb +6 -9
  97. data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
  98. data/lib/rubocop/cop/style/raise_args.rb +5 -2
  99. data/lib/rubocop/cop/style/redundant_argument.rb +7 -1
  100. data/lib/rubocop/cop/style/redundant_freeze.rb +8 -4
  101. data/lib/rubocop/cop/style/redundant_return.rb +1 -1
  102. data/lib/rubocop/cop/style/single_line_methods.rb +36 -2
  103. data/lib/rubocop/cop/style/sole_nested_conditional.rb +29 -5
  104. data/lib/rubocop/cop/style/string_concatenation.rb +1 -1
  105. data/lib/rubocop/cop/style/symbol_proc.rb +5 -4
  106. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
  107. data/lib/rubocop/cop/style/while_until_modifier.rb +2 -4
  108. data/lib/rubocop/cop/util.rb +3 -1
  109. data/lib/rubocop/formatter/git_hub_actions_formatter.rb +1 -0
  110. data/lib/rubocop/formatter/simple_text_formatter.rb +2 -1
  111. data/lib/rubocop/magic_comment.rb +30 -1
  112. data/lib/rubocop/options.rb +10 -10
  113. data/lib/rubocop/rspec/cop_helper.rb +0 -4
  114. data/lib/rubocop/rspec/expect_offense.rb +37 -22
  115. data/lib/rubocop/runner.rb +17 -1
  116. data/lib/rubocop/target_finder.rb +4 -2
  117. data/lib/rubocop/target_ruby.rb +47 -11
  118. data/lib/rubocop/util.rb +16 -0
  119. data/lib/rubocop/version.rb +8 -2
  120. metadata +27 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7e78bdb76ac54d034e71f715292180a9982c1c08096fd8546c52f8786b703bd
4
- data.tar.gz: e94b644cff4449332cd0be3dda1e41d2911f3bfd88fb14862534c0e29736a374
3
+ metadata.gz: 86b427813730f667d5978bd4b4ca7e8f6766adf4ddf713e413cf07a0345b84b2
4
+ data.tar.gz: ede1028f4ebe7b6b1cd59de4d604e655c7115d928d38393ebd7febdbbff5b3e7
5
5
  SHA512:
6
- metadata.gz: 54d96669e8524f0fc27ccc4ed75c44c2ce6c143298ed26affe5739eff1dd3aa9f24d0278e9df8e764c6ceb53b7f868764df783ccfd51d8a9bd633623124e150c
7
- data.tar.gz: f6516450c7473cf56f6d330da24fd2b73827a07603ecda6bba672c470ae7490e97071a118d168f4288e37792289e97cb4503362915e9daa0ce1c79bd1d0def28
6
+ metadata.gz: b5e3ca723e7530916204e9bfce59bec1452232765a0903093ba2b4783fc35f109e655251c2fce8e3b08dbebcf4a4e67a4301b00c8113d45f5f0bb2a63cc4be7f
7
+ data.tar.gz: d91068c77da3ea787a5c36c287f1913bc94c23d98fc315604883cb21742f4c1031014e10c9470c67dca2fa3dfdc41eb848134f0a9565ff5a82e65aed5d6d2cf3
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-20 Bozhidar Batsov
1
+ Copyright (c) 2012-21 Bozhidar Batsov
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -45,13 +45,13 @@ gem 'rubocop', require: false
45
45
  ```
46
46
 
47
47
  RuboCop is stable between major versions, both in terms of API and cop configuration.
48
- We aim the ease the maintenance of RuboCop extensions and the upgrades between RuboCop
48
+ We aim to ease the maintenance of RuboCop extensions and the upgrades between RuboCop
49
49
  releases. All big changes are reserved for major releases.
50
50
  To prevent an unwanted RuboCop update you might want to use a conservative version lock
51
51
  in your `Gemfile`:
52
52
 
53
53
  ```rb
54
- gem 'rubocop', '~> 1.6', require: false
54
+ gem 'rubocop', '~> 1.9', require: false
55
55
  ```
56
56
 
57
57
  See [versioning](https://docs.rubocop.org/rubocop/1.0/versioning.html) for further details.
@@ -109,6 +109,7 @@ Here's a list of RuboCop's core developers:
109
109
  * [Maxim Krizhanovski](https://github.com/darhazer)
110
110
  * [Benjamin Quorning](https://github.com/bquorning)
111
111
  * [Marc-André Lafortune](https://github.com/marcandre)
112
+ * [Daniel Vandersluis](https://github.com/dvandersluis)
112
113
 
113
114
  See the [team page](https://docs.rubocop.org/rubocop/about/team.html) for more details.
114
115
 
@@ -241,5 +242,5 @@ RuboCop's changelog is available [here](CHANGELOG.md).
241
242
 
242
243
  ## Copyright
243
244
 
244
- Copyright (c) 2012-2020 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
245
+ Copyright (c) 2012-2021 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
245
246
  further details.
@@ -132,12 +132,13 @@ AllCops:
132
132
  # If a value is specified for TargetRubyVersion then it is used. Acceptable
133
133
  # values are specificed as a float (i.e. 2.5); the teeny version of Ruby
134
134
  # should not be included. If the project specifies a Ruby version in the
135
- # .ruby-version file, Gemfile or gems.rb file, RuboCop will try to determine
136
- # the desired version of Ruby by inspecting the .ruby-version file first,
137
- # followed by the Gemfile.lock or gems.locked file. (Although the Ruby version
138
- # is specified in the Gemfile or gems.rb file, RuboCop reads the final value
139
- # from the lock file.) If the Ruby version is still unresolved, RuboCop will
140
- # use the oldest officially supported Ruby version (currently Ruby 2.4).
135
+ # .tool-versions or .ruby-version files, Gemfile or gems.rb file, RuboCop will
136
+ # try to determine the desired version of Ruby by inspecting the
137
+ # .tool-versions file first, then .ruby-version, followed by the Gemfile.lock
138
+ # or gems.locked file. (Although the Ruby version is specified in the Gemfile
139
+ # or gems.rb file, RuboCop reads the final value from the lock file.) If the
140
+ # Ruby version is still unresolved, RuboCop will use the oldest officially
141
+ # supported Ruby version (currently Ruby 2.4).
141
142
  TargetRubyVersion: ~
142
143
  # Determines if a notification for extension libraries should be shown when
143
144
  # rubocop is run. Keys are the name of the extension, and values are an array
@@ -473,7 +474,7 @@ Layout/EmptyLineBetweenDefs:
473
474
  StyleGuide: '#empty-lines-between-methods'
474
475
  Enabled: true
475
476
  VersionAdded: '0.49'
476
- VersionChanged: '1.4'
477
+ VersionChanged: '1.7'
477
478
  EmptyLineBetweenMethodDefs: true
478
479
  EmptyLineBetweenClassDefs: true
479
480
  EmptyLineBetweenModuleDefs: true
@@ -1192,6 +1193,12 @@ Layout/SpaceBeforeBlockBraces:
1192
1193
  - no_space
1193
1194
  VersionChanged: '0.52'
1194
1195
 
1196
+ Layout/SpaceBeforeBrackets:
1197
+ Description: 'Checks for receiver with a space before the opening brackets.'
1198
+ StyleGuide: '#space-in-brackets-access'
1199
+ Enabled: pending
1200
+ VersionAdded: '1.7'
1201
+
1195
1202
  Layout/SpaceBeforeComma:
1196
1203
  Description: 'No spaces before commas.'
1197
1204
  Enabled: true
@@ -1354,6 +1361,11 @@ Layout/TrailingWhitespace:
1354
1361
  #################### Lint ##################################
1355
1362
  ### Warnings
1356
1363
 
1364
+ Lint/AmbiguousAssignment:
1365
+ Description: 'Checks for mistyped shorthand assignments.'
1366
+ Enabled: pending
1367
+ VersionAdded: '1.7'
1368
+
1357
1369
  Lint/AmbiguousBlockAssociation:
1358
1370
  Description: >-
1359
1371
  Checks for ambiguous block association with method when param passed without
@@ -1396,6 +1408,7 @@ Lint/BinaryOperatorWithIdenticalOperands:
1396
1408
  Enabled: true
1397
1409
  Safe: false
1398
1410
  VersionAdded: '0.89'
1411
+ VersionChanged: '1.7'
1399
1412
 
1400
1413
  Lint/BooleanSymbol:
1401
1414
  Description: 'Check for `:true` and `:false` symbols.'
@@ -1456,6 +1469,34 @@ Lint/DeprecatedClassMethods:
1456
1469
  Enabled: true
1457
1470
  VersionAdded: '0.19'
1458
1471
 
1472
+ Lint/DeprecatedConstants:
1473
+ Description: 'Checks for deprecated constants.'
1474
+ Enabled: pending
1475
+ VersionAdded: '1.8'
1476
+ # You can configure deprecated constants.
1477
+ # If there is an alternative method, you can set alternative value as `Alternative`.
1478
+ # And you can set the deprecated version as `DeprecatedVersion`.
1479
+ # These options can be omitted if they are not needed.
1480
+ #
1481
+ # DeprecatedConstants:
1482
+ # 'DEPRECATED_CONSTANT':
1483
+ # Alternative: 'alternative_value'
1484
+ # DeprecatedVersion: 'deprecated_version'
1485
+ #
1486
+ DeprecatedConstants:
1487
+ 'NIL':
1488
+ Alternative: 'nil'
1489
+ DeprecatedVersion: '2.4'
1490
+ 'TRUE':
1491
+ Alternative: 'true'
1492
+ DeprecatedVersion: '2.4'
1493
+ 'FALSE':
1494
+ Alternative: 'false'
1495
+ DeprecatedVersion: '2.4'
1496
+ 'Random::DEFAULT':
1497
+ Alternative: 'Random.new'
1498
+ DeprecatedVersion: '3.0'
1499
+
1459
1500
  Lint/DeprecatedOpenSSLConstant:
1460
1501
  Description: "Don't use algorithm constants for `OpenSSL::Cipher` and `OpenSSL::Digest`."
1461
1502
  Enabled: true
@@ -1472,6 +1513,9 @@ Lint/DuplicateBranch:
1472
1513
  Description: Checks that there are no repeated bodies within `if/unless`, `case-when` and `rescue` constructs.
1473
1514
  Enabled: pending
1474
1515
  VersionAdded: '1.3'
1516
+ VersionChanged: '1.7'
1517
+ IgnoreLiteralBranches: false
1518
+ IgnoreConstantBranches: false
1475
1519
 
1476
1520
  Lint/DuplicateCaseCondition:
1477
1521
  Description: 'Do not repeat values in case conditionals.'
@@ -1658,6 +1702,11 @@ Lint/InterpolationCheck:
1658
1702
  VersionAdded: '0.50'
1659
1703
  VersionChanged: '0.87'
1660
1704
 
1705
+ Lint/LambdaWithoutLiteralBlock:
1706
+ Description: 'Checks uses of lambda without a literal block.'
1707
+ Enabled: pending
1708
+ VersionAdded: '1.8'
1709
+
1661
1710
  Lint/LiteralAsCondition:
1662
1711
  Description: 'Checks of literals used in conditions.'
1663
1712
  Enabled: true
@@ -1757,6 +1806,17 @@ Lint/NumberConversion:
1757
1806
  - Time
1758
1807
  - DateTime
1759
1808
 
1809
+ Lint/NumberedParameterAssignment:
1810
+ Description: 'Checks for uses of numbered parameter assignment.'
1811
+ Enabled: pending
1812
+ VersionAdded: '1.9'
1813
+
1814
+ Lint/OrAssignmentToConstant:
1815
+ Description: 'Checks unintended or-assignment to constant.'
1816
+ Enabled: pending
1817
+ Safe: false
1818
+ VersionAdded: '1.9'
1819
+
1760
1820
  Lint/OrderedMagicComments:
1761
1821
  Description: 'Checks the proper ordering of magic comments and whether a magic comment is not placed before a shebang.'
1762
1822
  Enabled: true
@@ -1820,6 +1880,11 @@ Lint/RedundantCopEnableDirective:
1820
1880
  Enabled: true
1821
1881
  VersionAdded: '0.76'
1822
1882
 
1883
+ Lint/RedundantDirGlobSort:
1884
+ Description: 'Checks for redundant `sort` method to `Dir.glob` and `Dir[]`.'
1885
+ Enabled: pending
1886
+ VersionAdded: '1.8'
1887
+
1823
1888
  Lint/RedundantRequireStatement:
1824
1889
  Description: 'Checks for unnecessary `require` statement.'
1825
1890
  Enabled: true
@@ -1842,6 +1907,8 @@ Lint/RedundantSplatExpansion:
1842
1907
  Description: 'Checks for splat unnecessarily being called on literals.'
1843
1908
  Enabled: true
1844
1909
  VersionAdded: '0.76'
1910
+ VersionChanged: '1.7'
1911
+ AllowPercentLiteralArrayArgument: true
1845
1912
 
1846
1913
  Lint/RedundantStringCoercion:
1847
1914
  Description: 'Checks for Object#to_s usage in string interpolation.'
@@ -1976,12 +2043,16 @@ Lint/SuppressedException:
1976
2043
  VersionAdded: '0.9'
1977
2044
  VersionChanged: '0.81'
1978
2045
 
2046
+ Lint/SymbolConversion:
2047
+ Description: 'Checks for unnecessary symbol conversions.'
2048
+ Enabled: pending
2049
+ VersionAdded: '1.9'
2050
+
1979
2051
  Lint/Syntax:
1980
- Description: 'Checks syntax error.'
2052
+ Description: 'Checks for syntax errors.'
1981
2053
  Enabled: true
1982
2054
  VersionAdded: '0.9'
1983
2055
 
1984
-
1985
2056
  Lint/ToEnumArguments:
1986
2057
  Description: 'This cop ensures that `to_enum`/`enum_for`, called for the current method, has correct arguments.'
1987
2058
  Enabled: pending
@@ -2002,6 +2073,11 @@ Lint/TrailingCommaInAttributeDeclaration:
2002
2073
  Enabled: true
2003
2074
  VersionAdded: '0.90'
2004
2075
 
2076
+ Lint/TripleQuotes:
2077
+ Description: 'Checks for useless triple quote constructs.'
2078
+ Enabled: pending
2079
+ VersionAdded: '1.9'
2080
+
2005
2081
  Lint/UnderscorePrefixedVariableName:
2006
2082
  Description: 'Do not use prefix `_` for a variable that is used.'
2007
2083
  Enabled: true
@@ -2045,6 +2121,11 @@ Lint/UnreachableLoop:
2045
2121
  Description: 'This cop checks for loops that will have at most one iteration.'
2046
2122
  Enabled: true
2047
2123
  VersionAdded: '0.89'
2124
+ VersionChanged: '1.7'
2125
+ IgnoredPatterns:
2126
+ # RSpec uses `times` in its message expectations
2127
+ # eg. `exactly(2).times`
2128
+ - !ruby/regexp /(exactly|at_least|at_most)\(\d+\)\.times/
2048
2129
 
2049
2130
  Lint/UnusedBlockArgument:
2050
2131
  Description: 'Checks for unused block arguments.'
@@ -2479,10 +2560,12 @@ Naming/VariableName:
2479
2560
  StyleGuide: '#snake-case-symbols-methods-vars'
2480
2561
  Enabled: true
2481
2562
  VersionAdded: '0.50'
2563
+ VersionChanged: '1.8'
2482
2564
  EnforcedStyle: snake_case
2483
2565
  SupportedStyles:
2484
2566
  - snake_case
2485
2567
  - camelCase
2568
+ AllowedIdentifiers: []
2486
2569
 
2487
2570
  Naming/VariableNumber:
2488
2571
  Description: 'Use the configured style when numbering symbols, methods and variables.'
@@ -2626,7 +2709,8 @@ Style/AsciiComments:
2626
2709
  Enabled: true
2627
2710
  VersionAdded: '0.9'
2628
2711
  VersionChanged: '0.52'
2629
- AllowedChars: []
2712
+ AllowedChars:
2713
+ - ©
2630
2714
 
2631
2715
  Style/Attr:
2632
2716
  Description: 'Checks for uses of Module#attr.'
@@ -2895,7 +2979,7 @@ Style/CollectionMethods:
2895
2979
  StyleGuide: '#map-find-select-reduce-include-size'
2896
2980
  Enabled: false
2897
2981
  VersionAdded: '0.9'
2898
- VersionChanged: '0.27'
2982
+ VersionChanged: '1.7'
2899
2983
  Safe: false
2900
2984
  # Mapping from undesired method to desired method
2901
2985
  # e.g. to use `detect` over `find`:
@@ -2910,6 +2994,11 @@ Style/CollectionMethods:
2910
2994
  detect: 'find'
2911
2995
  find_all: 'select'
2912
2996
  member?: 'include?'
2997
+ # Methods in this array accept a final symbol as an implicit block
2998
+ # eg. `inject(:+)`
2999
+ MethodsAcceptingSymbol:
3000
+ - inject
3001
+ - reduce
2913
3002
 
2914
3003
  Style/ColonMethodCall:
2915
3004
  Description: 'Do not use :: for method call.'
@@ -2969,6 +3058,7 @@ Style/CommentedKeyword:
2969
3058
  Description: 'Do not place comments on the same line as certain keywords.'
2970
3059
  Enabled: true
2971
3060
  VersionAdded: '0.51'
3061
+ VersionChanged: '1.7'
2972
3062
 
2973
3063
  Style/ConditionalAssignment:
2974
3064
  Description: >-
@@ -3051,6 +3141,8 @@ Style/DisableCopsWithinSourceCodeDirective:
3051
3141
  Forbids disabling/enabling cops within source code.
3052
3142
  Enabled: false
3053
3143
  VersionAdded: '0.82'
3144
+ VersionChanged: '1.9'
3145
+ AllowedCops: []
3054
3146
 
3055
3147
  Style/DocumentDynamicEvalDefinition:
3056
3148
  Description: >-
@@ -3168,6 +3260,17 @@ Style/EndBlock:
3168
3260
  VersionAdded: '0.9'
3169
3261
  VersionChanged: '0.81'
3170
3262
 
3263
+ Style/EndlessMethod:
3264
+ Description: 'Avoid the use of multi-lined endless method definitions.'
3265
+ StyleGuide: '#endless-methods'
3266
+ Enabled: pending
3267
+ VersionAdded: '1.8'
3268
+ EnforcedStyle: allow_single_line
3269
+ SupportedStyles:
3270
+ - allow_single_line
3271
+ - allow_always
3272
+ - disallow
3273
+
3171
3274
  Style/EvalWithLocation:
3172
3275
  Description: 'Pass `__FILE__` and `__LINE__` to `eval` method, as they are used by backtraces.'
3173
3276
  Enabled: true
@@ -3191,9 +3294,8 @@ Style/ExplicitBlockArgument:
3191
3294
  that just passes its arguments to another block.
3192
3295
  StyleGuide: '#block-argument'
3193
3296
  Enabled: true
3194
- # May change the yielding arity.
3195
- Safe: false
3196
3297
  VersionAdded: '0.89'
3298
+ VersionChanged: '1.8'
3197
3299
 
3198
3300
  Style/ExponentialNotation:
3199
3301
  Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
@@ -3212,7 +3314,8 @@ Style/FloatDivision:
3212
3314
  Reference: 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
3213
3315
  Enabled: true
3214
3316
  VersionAdded: '0.72'
3215
- VersionChanged: '1.6'
3317
+ VersionChanged: '1.9'
3318
+ Safe: false
3216
3319
  EnforcedStyle: single_coerce
3217
3320
  SupportedStyles:
3218
3321
  - left_coerce
@@ -3260,6 +3363,7 @@ Style/FormatStringToken:
3260
3363
  MaxUnannotatedPlaceholdersAllowed: 1
3261
3364
  VersionAdded: '0.49'
3262
3365
  VersionChanged: '1.0'
3366
+ IgnoredMethods: []
3263
3367
 
3264
3368
  Style/FrozenStringLiteralComment:
3265
3369
  Description: >-
@@ -3328,6 +3432,13 @@ Style/HashEachMethods:
3328
3432
  VersionAdded: '0.80'
3329
3433
  Safe: false
3330
3434
 
3435
+ Style/HashExcept:
3436
+ Description: >-
3437
+ Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
3438
+ that can be replaced with `Hash#except` method.
3439
+ Enabled: pending
3440
+ VersionAdded: '1.7'
3441
+
3331
3442
  Style/HashLikeCase:
3332
3443
  Description: >-
3333
3444
  Checks for places where `case-when` represents a simple 1:1
@@ -3406,6 +3517,14 @@ Style/IfUnlessModifierOfIfUnless:
3406
3517
  VersionAdded: '0.39'
3407
3518
  VersionChanged: '0.87'
3408
3519
 
3520
+ Style/IfWithBooleanLiteralBranches:
3521
+ Description: 'Checks for redundant `if` with boolean literal branches.'
3522
+ Enabled: pending
3523
+ VersionAdded: '1.9'
3524
+ SafeAutoCorrect: false
3525
+ AllowedMethods:
3526
+ - nonzero?
3527
+
3409
3528
  Style/IfWithSemicolon:
3410
3529
  Description: 'Do not use if x; .... Use the ternary operator instead.'
3411
3530
  StyleGuide: '#no-semicolon-ifs'
@@ -3482,6 +3601,7 @@ Style/KeywordParametersOrder:
3482
3601
  StyleGuide: '#keyword-parameters-order'
3483
3602
  Enabled: true
3484
3603
  VersionAdded: '0.90'
3604
+ VersionChanged: '1.7'
3485
3605
 
3486
3606
  Style/Lambda:
3487
3607
  Description: 'Use the new lambda literal syntax for single-line blocks.'
@@ -3520,7 +3640,7 @@ Style/MethodCallWithArgsParentheses:
3520
3640
  StyleGuide: '#method-invocation-parens'
3521
3641
  Enabled: false
3522
3642
  VersionAdded: '0.47'
3523
- VersionChanged: '0.61'
3643
+ VersionChanged: '1.7'
3524
3644
  IgnoreMacros: true
3525
3645
  IgnoredMethods: []
3526
3646
  IgnoredPatterns: []
@@ -3554,7 +3674,7 @@ Style/MethodDefParentheses:
3554
3674
  StyleGuide: '#method-parens'
3555
3675
  Enabled: true
3556
3676
  VersionAdded: '0.16'
3557
- VersionChanged: '0.35'
3677
+ VersionChanged: '1.7'
3558
3678
  EnforcedStyle: require_parentheses
3559
3679
  SupportedStyles:
3560
3680
  - require_parentheses
@@ -3660,6 +3780,7 @@ Style/MultilineMethodSignature:
3660
3780
  Description: 'Avoid multi-line method signatures.'
3661
3781
  Enabled: false
3662
3782
  VersionAdded: '0.59'
3783
+ VersionChanged: '1.7'
3663
3784
 
3664
3785
  Style/MultilineTernaryOperator:
3665
3786
  Description: >-
@@ -3688,7 +3809,8 @@ Style/MutableConstant:
3688
3809
  Description: 'Do not assign mutable objects to constants.'
3689
3810
  Enabled: true
3690
3811
  VersionAdded: '0.34'
3691
- VersionChanged: '0.65'
3812
+ VersionChanged: '1.8'
3813
+ SafeAutoCorrect: false
3692
3814
  EnforcedStyle: literals
3693
3815
  SupportedStyles:
3694
3816
  # literals: freeze literals assigned to constants
@@ -4026,12 +4148,16 @@ Style/RedundantArgument:
4026
4148
  Enabled: pending
4027
4149
  Safe: false
4028
4150
  VersionAdded: '1.4'
4029
- VersionChanged: '1.6'
4151
+ VersionChanged: '1.7'
4030
4152
  Methods:
4031
4153
  # Array#join
4032
4154
  join: ''
4033
4155
  # String#split
4034
4156
  split: ' '
4157
+ # String#chomp
4158
+ chomp: "\n"
4159
+ # String#chomp!
4160
+ chomp!: "\n"
4035
4161
 
4036
4162
  Style/RedundantAssignment:
4037
4163
  Description: 'Checks for redundant assignment before returning.'
@@ -4288,7 +4414,7 @@ Style/SingleLineMethods:
4288
4414
  StyleGuide: '#no-single-line-methods'
4289
4415
  Enabled: true
4290
4416
  VersionAdded: '0.9'
4291
- VersionChanged: '0.19'
4417
+ VersionChanged: '1.8'
4292
4418
  AllowIfMethodIsEmpty: true
4293
4419
 
4294
4420
  Style/SlicingWithRange:
@@ -7,7 +7,7 @@ require 'rainbow'
7
7
  require 'set'
8
8
  require 'forwardable'
9
9
  require 'regexp_parser'
10
- require 'unicode/display_width/no_string_ext'
10
+ require 'unicode/display_width'
11
11
 
12
12
  # we have to require RuboCop's version, before rubocop-ast's
13
13
  require_relative 'rubocop/version'
@@ -28,12 +28,14 @@ require_relative 'rubocop/name_similarity'
28
28
  require_relative 'rubocop/string_interpreter'
29
29
  require_relative 'rubocop/error'
30
30
  require_relative 'rubocop/warning'
31
+ require_relative 'rubocop/util'
31
32
 
32
33
  require_relative 'rubocop/cop/util'
33
34
  require_relative 'rubocop/cop/offense'
34
35
  require_relative 'rubocop/cop/message_annotator'
35
36
  require_relative 'rubocop/cop/ignored_node'
36
37
  require_relative 'rubocop/cop/autocorrect_logic'
38
+ require_relative 'rubocop/cop/exclude_limit'
37
39
  require_relative 'rubocop/cop/badge'
38
40
  require_relative 'rubocop/cop/registry'
39
41
  require_relative 'rubocop/cop/base'
@@ -60,6 +62,7 @@ require_relative 'rubocop/cop/mixin/annotation_comment'
60
62
  require_relative 'rubocop/cop/mixin/array_min_size'
61
63
  require_relative 'rubocop/cop/mixin/array_syntax'
62
64
  require_relative 'rubocop/cop/mixin/alignment'
65
+ require_relative 'rubocop/cop/mixin/allowed_identifiers'
63
66
  require_relative 'rubocop/cop/mixin/allowed_methods'
64
67
  require_relative 'rubocop/cop/mixin/auto_corrector'
65
68
  require_relative 'rubocop/cop/mixin/check_assignment'
@@ -230,6 +233,7 @@ require_relative 'rubocop/cop/layout/space_around_keyword'
230
233
  require_relative 'rubocop/cop/layout/space_around_method_call_operator'
231
234
  require_relative 'rubocop/cop/layout/space_around_operators'
232
235
  require_relative 'rubocop/cop/layout/space_before_block_braces'
236
+ require_relative 'rubocop/cop/layout/space_before_brackets'
233
237
  require_relative 'rubocop/cop/layout/space_before_comma'
234
238
  require_relative 'rubocop/cop/layout/space_before_comment'
235
239
  require_relative 'rubocop/cop/layout/space_before_first_arg'
@@ -247,6 +251,7 @@ require_relative 'rubocop/cop/layout/space_inside_string_interpolation'
247
251
  require_relative 'rubocop/cop/layout/trailing_empty_lines'
248
252
  require_relative 'rubocop/cop/layout/trailing_whitespace'
249
253
 
254
+ require_relative 'rubocop/cop/lint/ambiguous_assignment'
250
255
  require_relative 'rubocop/cop/lint/ambiguous_block_association'
251
256
  require_relative 'rubocop/cop/lint/ambiguous_operator'
252
257
  require_relative 'rubocop/cop/lint/ambiguous_regexp_literal'
@@ -259,6 +264,7 @@ require_relative 'rubocop/cop/lint/constant_definition_in_block'
259
264
  require_relative 'rubocop/cop/lint/constant_resolution'
260
265
  require_relative 'rubocop/cop/lint/debugger'
261
266
  require_relative 'rubocop/cop/lint/deprecated_class_methods'
267
+ require_relative 'rubocop/cop/lint/deprecated_constants'
262
268
  require_relative 'rubocop/cop/lint/deprecated_open_ssl_constant'
263
269
  require_relative 'rubocop/cop/lint/disjunctive_assignment_in_constructor'
264
270
  require_relative 'rubocop/cop/lint/duplicate_branch'
@@ -292,6 +298,7 @@ require_relative 'rubocop/cop/lint/implicit_string_concatenation'
292
298
  require_relative 'rubocop/cop/lint/inherit_exception'
293
299
  require_relative 'rubocop/cop/lint/ineffective_access_modifier'
294
300
  require_relative 'rubocop/cop/lint/interpolation_check'
301
+ require_relative 'rubocop/cop/lint/lambda_without_literal_block'
295
302
  require_relative 'rubocop/cop/lint/literal_as_condition'
296
303
  require_relative 'rubocop/cop/lint/literal_in_interpolation'
297
304
  require_relative 'rubocop/cop/lint/loop'
@@ -306,6 +313,8 @@ require_relative 'rubocop/cop/lint/no_return_in_begin_end_blocks'
306
313
  require_relative 'rubocop/cop/lint/non_deterministic_require_order'
307
314
  require_relative 'rubocop/cop/lint/non_local_exit_from_iterator'
308
315
  require_relative 'rubocop/cop/lint/number_conversion'
316
+ require_relative 'rubocop/cop/lint/numbered_parameter_assignment'
317
+ require_relative 'rubocop/cop/lint/or_assignment_to_constant'
309
318
  require_relative 'rubocop/cop/lint/ordered_magic_comments'
310
319
  require_relative 'rubocop/cop/lint/out_of_range_regexp_ref'
311
320
  require_relative 'rubocop/cop/lint/parentheses_as_grouped_expression'
@@ -315,6 +324,7 @@ require_relative 'rubocop/cop/lint/raise_exception'
315
324
  require_relative 'rubocop/cop/lint/rand_one'
316
325
  require_relative 'rubocop/cop/lint/redundant_cop_disable_directive'
317
326
  require_relative 'rubocop/cop/lint/redundant_cop_enable_directive'
327
+ require_relative 'rubocop/cop/lint/redundant_dir_glob_sort'
318
328
  require_relative 'rubocop/cop/lint/redundant_require_statement'
319
329
  require_relative 'rubocop/cop/lint/redundant_safe_navigation'
320
330
  require_relative 'rubocop/cop/lint/redundant_splat_expansion'
@@ -337,11 +347,13 @@ require_relative 'rubocop/cop/lint/shadowed_exception'
337
347
  require_relative 'rubocop/cop/lint/shadowing_outer_local_variable'
338
348
  require_relative 'rubocop/cop/lint/struct_new_override'
339
349
  require_relative 'rubocop/cop/lint/suppressed_exception'
350
+ require_relative 'rubocop/cop/lint/symbol_conversion'
340
351
  require_relative 'rubocop/cop/lint/syntax'
341
352
  require_relative 'rubocop/cop/lint/to_enum_arguments'
342
353
  require_relative 'rubocop/cop/lint/to_json'
343
354
  require_relative 'rubocop/cop/lint/top_level_return_with_argument'
344
355
  require_relative 'rubocop/cop/lint/trailing_comma_in_attribute_declaration'
356
+ require_relative 'rubocop/cop/lint/triple_quotes'
345
357
  require_relative 'rubocop/cop/lint/underscore_prefixed_variable_name'
346
358
  require_relative 'rubocop/cop/lint/unexpected_block_arity'
347
359
  require_relative 'rubocop/cop/lint/unified_integer'
@@ -443,6 +455,7 @@ require_relative 'rubocop/cop/style/empty_else'
443
455
  require_relative 'rubocop/cop/style/empty_lambda_parameter'
444
456
  require_relative 'rubocop/cop/style/empty_literal'
445
457
  require_relative 'rubocop/cop/style/empty_method'
458
+ require_relative 'rubocop/cop/style/endless_method'
446
459
  require_relative 'rubocop/cop/style/encoding'
447
460
  require_relative 'rubocop/cop/style/end_block'
448
461
  require_relative 'rubocop/cop/style/eval_with_location'
@@ -460,6 +473,7 @@ require_relative 'rubocop/cop/style/global_vars'
460
473
  require_relative 'rubocop/cop/style/guard_clause'
461
474
  require_relative 'rubocop/cop/style/hash_as_last_array_item'
462
475
  require_relative 'rubocop/cop/style/hash_each_methods'
476
+ require_relative 'rubocop/cop/style/hash_except'
463
477
  require_relative 'rubocop/cop/style/hash_like_case'
464
478
  require_relative 'rubocop/cop/style/hash_syntax'
465
479
  require_relative 'rubocop/cop/style/hash_transform_keys'
@@ -468,6 +482,7 @@ require_relative 'rubocop/cop/style/identical_conditional_branches'
468
482
  require_relative 'rubocop/cop/style/if_inside_else'
469
483
  require_relative 'rubocop/cop/style/if_unless_modifier'
470
484
  require_relative 'rubocop/cop/style/if_unless_modifier_of_if_unless'
485
+ require_relative 'rubocop/cop/style/if_with_boolean_literal_branches'
471
486
  require_relative 'rubocop/cop/style/if_with_semicolon'
472
487
  require_relative 'rubocop/cop/style/implicit_runtime_error'
473
488
  require_relative 'rubocop/cop/style/infinite_loop'