rubocop 0.70.0 → 0.72.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -10
  3. data/config/default.yml +50 -491
  4. data/lib/rubocop.rb +5 -53
  5. data/lib/rubocop/ast/builder.rb +2 -0
  6. data/lib/rubocop/ast/node.rb +1 -1
  7. data/lib/rubocop/ast/node/float_node.rb +12 -0
  8. data/lib/rubocop/ast/node/int_node.rb +12 -0
  9. data/lib/rubocop/ast/node/mixin/numeric_node.rb +21 -0
  10. data/lib/rubocop/ast/node/resbody_node.rb +1 -6
  11. data/lib/rubocop/cached_data.rb +1 -1
  12. data/lib/rubocop/config.rb +35 -6
  13. data/lib/rubocop/config_loader.rb +2 -2
  14. data/lib/rubocop/config_loader_resolver.rb +0 -6
  15. data/lib/rubocop/cop/cop.rb +0 -4
  16. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +55 -0
  17. data/lib/rubocop/cop/layout/class_structure.rb +1 -1
  18. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +3 -1
  19. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +4 -0
  20. data/lib/rubocop/cop/layout/indent_first_argument.rb +6 -2
  21. data/lib/rubocop/cop/layout/indent_first_parameter.rb +7 -3
  22. data/lib/rubocop/cop/layout/indent_heredoc.rb +0 -1
  23. data/lib/rubocop/cop/layout/indentation_consistency.rb +13 -12
  24. data/lib/rubocop/cop/layout/indentation_width.rb +8 -4
  25. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +2 -0
  26. data/lib/rubocop/cop/lint/number_conversion.rb +1 -1
  27. data/lib/rubocop/cop/mixin/hash_alignment.rb +4 -0
  28. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +20 -22
  29. data/lib/rubocop/cop/style/commented_keyword.rb +1 -1
  30. data/lib/rubocop/cop/style/conditional_assignment.rb +2 -1
  31. data/lib/rubocop/cop/style/float_division.rb +94 -0
  32. data/lib/rubocop/cop/style/format_string.rb +7 -3
  33. data/lib/rubocop/cop/style/if_inside_else.rb +42 -0
  34. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +7 -1
  35. data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
  36. data/lib/rubocop/cop/style/ternary_parentheses.rb +12 -2
  37. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +4 -0
  38. data/lib/rubocop/cop/style/word_array.rb +2 -2
  39. data/lib/rubocop/cop/style/zero_length_predicate.rb +1 -1
  40. data/lib/rubocop/node_pattern.rb +84 -5
  41. data/lib/rubocop/options.rb +0 -2
  42. data/lib/rubocop/processed_source.rb +5 -1
  43. data/lib/rubocop/rspec/cop_helper.rb +0 -1
  44. data/lib/rubocop/rspec/shared_contexts.rb +0 -17
  45. data/lib/rubocop/rspec/support.rb +0 -1
  46. data/lib/rubocop/runner.rb +6 -7
  47. data/lib/rubocop/version.rb +1 -1
  48. data/lib/rubocop/yaml_duplication_checker.rb +8 -2
  49. metadata +7 -69
  50. data/lib/rubocop/cop/mixin/target_rails_version.rb +0 -16
  51. data/lib/rubocop/cop/rails/action_filter.rb +0 -117
  52. data/lib/rubocop/cop/rails/active_record_aliases.rb +0 -48
  53. data/lib/rubocop/cop/rails/active_record_override.rb +0 -82
  54. data/lib/rubocop/cop/rails/active_support_aliases.rb +0 -69
  55. data/lib/rubocop/cop/rails/application_job.rb +0 -40
  56. data/lib/rubocop/cop/rails/application_record.rb +0 -40
  57. data/lib/rubocop/cop/rails/assert_not.rb +0 -44
  58. data/lib/rubocop/cop/rails/belongs_to.rb +0 -102
  59. data/lib/rubocop/cop/rails/blank.rb +0 -164
  60. data/lib/rubocop/cop/rails/bulk_change_table.rb +0 -289
  61. data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +0 -91
  62. data/lib/rubocop/cop/rails/date.rb +0 -161
  63. data/lib/rubocop/cop/rails/delegate.rb +0 -132
  64. data/lib/rubocop/cop/rails/delegate_allow_blank.rb +0 -37
  65. data/lib/rubocop/cop/rails/dynamic_find_by.rb +0 -91
  66. data/lib/rubocop/cop/rails/enum_uniqueness.rb +0 -45
  67. data/lib/rubocop/cop/rails/environment_comparison.rb +0 -68
  68. data/lib/rubocop/cop/rails/exit.rb +0 -67
  69. data/lib/rubocop/cop/rails/file_path.rb +0 -108
  70. data/lib/rubocop/cop/rails/find_by.rb +0 -55
  71. data/lib/rubocop/cop/rails/find_each.rb +0 -51
  72. data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +0 -25
  73. data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +0 -106
  74. data/lib/rubocop/cop/rails/http_positional_arguments.rb +0 -117
  75. data/lib/rubocop/cop/rails/http_status.rb +0 -179
  76. data/lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb +0 -94
  77. data/lib/rubocop/cop/rails/inverse_of.rb +0 -246
  78. data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +0 -175
  79. data/lib/rubocop/cop/rails/link_to_blank.rb +0 -98
  80. data/lib/rubocop/cop/rails/not_null_column.rb +0 -67
  81. data/lib/rubocop/cop/rails/output.rb +0 -49
  82. data/lib/rubocop/cop/rails/output_safety.rb +0 -99
  83. data/lib/rubocop/cop/rails/pluralization_grammar.rb +0 -107
  84. data/lib/rubocop/cop/rails/presence.rb +0 -124
  85. data/lib/rubocop/cop/rails/present.rb +0 -153
  86. data/lib/rubocop/cop/rails/read_write_attribute.rb +0 -74
  87. data/lib/rubocop/cop/rails/redundant_allow_nil.rb +0 -111
  88. data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +0 -136
  89. data/lib/rubocop/cop/rails/reflection_class_name.rb +0 -37
  90. data/lib/rubocop/cop/rails/refute_methods.rb +0 -76
  91. data/lib/rubocop/cop/rails/relative_date_constant.rb +0 -93
  92. data/lib/rubocop/cop/rails/request_referer.rb +0 -56
  93. data/lib/rubocop/cop/rails/reversible_migration.rb +0 -286
  94. data/lib/rubocop/cop/rails/safe_navigation.rb +0 -87
  95. data/lib/rubocop/cop/rails/save_bang.rb +0 -316
  96. data/lib/rubocop/cop/rails/scope_args.rb +0 -29
  97. data/lib/rubocop/cop/rails/skips_model_validations.rb +0 -87
  98. data/lib/rubocop/cop/rails/time_zone.rb +0 -238
  99. data/lib/rubocop/cop/rails/uniq_before_pluck.rb +0 -105
  100. data/lib/rubocop/cop/rails/unknown_env.rb +0 -63
  101. data/lib/rubocop/cop/rails/validation.rb +0 -109
  102. data/lib/rubocop/rspec/shared_examples.rb +0 -59
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f98c70ae4897b3f4c793fa73cb716986f9d63815928c278accf6879a0190e97e
4
- data.tar.gz: 89111e2312bdf926aab76ca58bfb90a414ff3b5f58ba48257e5d1949763d4776
3
+ metadata.gz: eba7ed97b0ff87530eaaac338ed31f332f89dd4c86ca8afc3046d8141d3f1c03
4
+ data.tar.gz: 23a2c2e2c59efb26294495c94b33e1849feef60b8afe26e98064ff01e98cbccf
5
5
  SHA512:
6
- metadata.gz: 83462908a6383ab72503c4af338d395a118e435d8f4f73e7cdda54b6d8d1cc05f40a5ebdb6a3197bf9a2734046665c7c2d6616e0bb0847f198d11b410ae4b7f8
7
- data.tar.gz: 39c1a0fca5a9251e3a60f9ca3958d228d79f5797de21da608f69cb133611c683913673bbdc426a537c9578bc4394607a20617d394d1abc3454878373589a0fdd
6
+ metadata.gz: 72a13a6ca2580bc1613ee8cb5a2432f564fb6f53f68558bd716046d4f5c28b73a57535d9eb4c96542f9cbaa5f29ee1226ec71e1b66a342ac4810106b69f3ef5d
7
+ data.tar.gz: aa480f20807bf7d31c878eeade72cf09a4963174b7490738f77cc8a8cf5a59b2a40b2f20dbc969719863aed1c672136ef32b7173f5d231c3f387dc25a62f77ac
data/README.md CHANGED
@@ -7,7 +7,6 @@
7
7
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=rubocop&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=rubocop&package-manager=bundler&version-scheme=semver)
8
8
 
9
9
  [![Patreon](https://img.shields.io/badge/patreon-donate-orange.svg)](https://www.patreon.com/bbatsov)
10
- [![Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/bbatsov/donate)
11
10
  [![OpenCollective](https://opencollective.com/rubocop/backers/badge.svg)](#open-collective-backers)
12
11
  [![OpenCollective](https://opencollective.com/rubocop/sponsors/badge.svg)](#open-collective-sponsors)
13
12
 
@@ -21,7 +20,7 @@
21
20
  **RuboCop** is a Ruby static code analyzer and code formatter. Out of
22
21
  the box it will enforce many of the guidelines outlined in the
23
22
  community [Ruby Style
24
- Guide](https://github.com/rubocop-hq/ruby-style-guide).
23
+ Guide](https://rubystyle.guide).
25
24
 
26
25
  RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various
27
26
  [configuration options](https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml).
@@ -53,7 +52,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
53
52
  might want to use a conservative version lock in your `Gemfile`:
54
53
 
55
54
  ```rb
56
- gem 'rubocop', '~> 0.70.0', require: false
55
+ gem 'rubocop', '~> 0.72.0', require: false
57
56
  ```
58
57
 
59
58
  ## Quickstart
@@ -65,9 +64,9 @@ $ cd my/cool/ruby/project
65
64
  $ rubocop
66
65
  ```
67
66
 
68
- ## Official manual
67
+ ## Documentation
69
68
 
70
- You can read a ton more about RuboCop in its [official manual](https://docs.rubocop.org).
69
+ You can read a lot more about RuboCop in its [official docs](https://docs.rubocop.org).
71
70
 
72
71
  ## Compatibility
73
72
 
@@ -76,10 +75,6 @@ RuboCop supports the following Ruby implementations:
76
75
  * MRI 2.3+
77
76
  * JRuby 9.1+
78
77
 
79
- The Rails cops support the following versions:
80
-
81
- * Rails 4.0+
82
-
83
78
  ## Team
84
79
 
85
80
  Here's a list of RuboCop's core developers:
@@ -138,7 +133,7 @@ to become a RuboCop sponsor.
138
133
  You can support the development of RuboCop via
139
134
  [Salt](https://salt.bountysource.com/teams/rubocop),
140
135
  [Patreon](https://www.patreon.com/bbatsov),
141
- [Liberapay](https://liberapay.com/bbatsov/donate),
136
+ [PayPal](https://paypal.me/bbatsov)
142
137
  and [Open Collective](https://opencollective.com/rubocop).
143
138
 
144
139
  ### Open Collective Backers
@@ -73,7 +73,7 @@ AllCops:
73
73
  DisplayStyleGuide: false
74
74
  # When specifying style guide URLs, any paths and/or fragments will be
75
75
  # evaluated relative to the base URL.
76
- StyleGuideBaseURL: https://github.com/rubocop-hq/ruby-style-guide
76
+ StyleGuideBaseURL: https://rubystyle.guide
77
77
  # Extra details are not displayed in offense messages by default. Change
78
78
  # behavior by overriding ExtraDetails, or by giving the
79
79
  # `-E/--extra-details` option.
@@ -125,14 +125,6 @@ AllCops:
125
125
  # from the lock file.) If the Ruby version is still unresolved, RuboCop will
126
126
  # use the oldest officially supported Ruby version (currently Ruby 2.3).
127
127
  TargetRubyVersion: ~
128
- # What version of Rails is the inspected code using? If a value is specified
129
- # for TargetRailsVersion then it is used. Acceptable values are specificed
130
- # as a float (i.e. 5.1); the patch version of Rails should not be included.
131
- # If TargetRailsVersion is not set, RuboCop will parse the Gemfile.lock or
132
- # gems.locked file to find the version of Rails that has been bound to the
133
- # application. If neither of those files exist, RuboCop will use Rails 5.0
134
- # as the default.
135
- TargetRailsVersion: ~
136
128
 
137
129
  #################### Bundler ###############################
138
130
 
@@ -203,6 +195,13 @@ Gemspec/RequiredRubyVersion:
203
195
  VersionAdded: '0.52'
204
196
  Include:
205
197
  - '**/*.gemspec'
198
+ -
199
+ Gemspec/RubyVersionGlobalsUsage:
200
+ Description: Checks usage of RUBY_VERSION in gemspec.
201
+ Enabled: true
202
+ VersionAdded: '0.72'
203
+ Include:
204
+ - '**/*.gemspec'
206
205
 
207
206
  #################### Layout ###########################
208
207
 
@@ -778,8 +777,8 @@ Layout/IndentationConsistency:
778
777
  StyleGuide: '#spaces-indentation'
779
778
  Enabled: true
780
779
  VersionAdded: '0.49'
781
- # The difference between `rails` and `normal` is that the `rails` style
782
- # prescribes that in classes and modules the `protected` and `private`
780
+ # The difference between `indented` and `normal` is that the `indented_internal_methods`
781
+ # style prescribes that in classes and modules the `protected` and `private`
783
782
  # modifier keywords shall be indented the same as public methods and that
784
783
  # protected and private members shall be indented one step more than the
785
784
  # modifiers. Other than that, both styles mean that entities on the same
@@ -787,9 +786,9 @@ Layout/IndentationConsistency:
787
786
  EnforcedStyle: normal
788
787
  SupportedStyles:
789
788
  - normal
790
- - rails
789
+ - indented_internal_methods
791
790
  Reference:
792
- # A reference to `EnforcedStyle: rails`.
791
+ # A reference to `EnforcedStyle: indented_internal_methods`.
793
792
  - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
794
793
 
795
794
  Layout/IndentationWidth:
@@ -1349,7 +1348,7 @@ Lint/ErbNewArguments:
1349
1348
  VersionAdded: '0.56'
1350
1349
 
1351
1350
  Lint/FlipFlop:
1352
- Description: 'Checks for flip-flops'
1351
+ Description: 'Checks for flip-flops.'
1353
1352
  StyleGuide: '#no-flip-flops'
1354
1353
  Enabled: true
1355
1354
  VersionAdded: '0.16'
@@ -1407,7 +1406,7 @@ Lint/InheritException:
1407
1406
  - standard_error
1408
1407
 
1409
1408
  Lint/InterpolationCheck:
1410
- Description: 'Raise warning for interpolation in single q strs'
1409
+ Description: 'Raise warning for interpolation in single q strs.'
1411
1410
  Enabled: true
1412
1411
  VersionAdded: '0.50'
1413
1412
 
@@ -1431,7 +1430,7 @@ Lint/Loop:
1431
1430
  VersionAdded: '0.9'
1432
1431
 
1433
1432
  Lint/MissingCopEnableDirective:
1434
- Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`'
1433
+ Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.'
1435
1434
  Enabled: true
1436
1435
  VersionAdded: '0.52'
1437
1436
  # Maximum number of consecutive lines the cop can be disabled for.
@@ -1495,6 +1494,7 @@ Lint/PercentStringArray:
1495
1494
  Description: >-
1496
1495
  Checks for unwanted commas and quotes in %w/%W literals.
1497
1496
  Enabled: true
1497
+ Safe: false
1498
1498
  VersionAdded: '0.41'
1499
1499
 
1500
1500
  Lint/PercentSymbolArray:
@@ -1618,7 +1618,7 @@ Lint/StringConversionInInterpolation:
1618
1618
  VersionChanged: '0.20'
1619
1619
 
1620
1620
  Lint/Syntax:
1621
- Description: 'Checks syntax error'
1621
+ Description: 'Checks syntax error.'
1622
1622
  Enabled: true
1623
1623
  VersionAdded: '0.9'
1624
1624
 
@@ -1634,7 +1634,7 @@ Lint/UnderscorePrefixedVariableName:
1634
1634
  AllowKeywordBlockArguments: false
1635
1635
 
1636
1636
  Lint/UnifiedInteger:
1637
- Description: 'Use Integer instead of Fixnum or Bignum'
1637
+ Description: 'Use Integer instead of Fixnum or Bignum.'
1638
1638
  Enabled: true
1639
1639
  VersionAdded: '0.43'
1640
1640
 
@@ -1657,7 +1657,7 @@ Lint/UnneededRequireStatement:
1657
1657
  VersionAdded: '0.51'
1658
1658
 
1659
1659
  Lint/UnneededSplatExpansion:
1660
- Description: 'Checks for splat unnecessarily being called on literals'
1660
+ Description: 'Checks for splat unnecessarily being called on literals.'
1661
1661
  Enabled: true
1662
1662
  VersionAdded: '0.43'
1663
1663
 
@@ -1766,7 +1766,7 @@ Metrics/BlockLength:
1766
1766
  - '**/*.gemspec'
1767
1767
 
1768
1768
  Metrics/BlockNesting:
1769
- Description: 'Avoid excessive block nesting'
1769
+ Description: 'Avoid excessive block nesting.'
1770
1770
  StyleGuide: '#three-is-the-number-thou-shalt-count'
1771
1771
  Enabled: true
1772
1772
  VersionAdded: '0.25'
@@ -2077,461 +2077,6 @@ Naming/VariableNumber:
2077
2077
  - normalcase
2078
2078
  - non_integer
2079
2079
 
2080
- #################### Rails #################################
2081
-
2082
- # By default, the rails cops are not run. Override in project or home
2083
- # directory .rubocop.yml files, or by giving the -R/--rails option.
2084
- Rails:
2085
- Enabled: false
2086
-
2087
- Rails/ActionFilter:
2088
- Description: 'Enforces consistent use of action filter methods.'
2089
- Enabled: true
2090
- VersionAdded: '0.19'
2091
- EnforcedStyle: action
2092
- SupportedStyles:
2093
- - action
2094
- - filter
2095
- Include:
2096
- - app/controllers/**/*.rb
2097
-
2098
- Rails/ActiveRecordAliases:
2099
- Description: >-
2100
- Avoid Active Record aliases:
2101
- Use `update` instead of `update_attributes`.
2102
- Use `update!` instead of `update_attributes!`.
2103
- Enabled: true
2104
- VersionAdded: '0.53'
2105
-
2106
- Rails/ActiveRecordOverride:
2107
- Description: >-
2108
- Check for overriding Active Record methods instead of using
2109
- callbacks.
2110
- Enabled: true
2111
- VersionAdded: '0.67'
2112
- Include:
2113
- - app/models/**/*.rb
2114
-
2115
- Rails/ActiveSupportAliases:
2116
- Description: >-
2117
- Avoid ActiveSupport aliases of standard ruby methods:
2118
- `String#starts_with?`, `String#ends_with?`,
2119
- `Array#append`, `Array#prepend`.
2120
- Enabled: true
2121
- VersionAdded: '0.48'
2122
-
2123
- Rails/ApplicationJob:
2124
- Description: 'Check that jobs subclass ApplicationJob.'
2125
- Enabled: true
2126
- VersionAdded: '0.49'
2127
-
2128
- Rails/ApplicationRecord:
2129
- Description: 'Check that models subclass ApplicationRecord.'
2130
- Enabled: true
2131
- VersionAdded: '0.49'
2132
-
2133
- Rails/AssertNot:
2134
- Description: 'Use `assert_not` instead of `assert !`.'
2135
- Enabled: true
2136
- VersionAdded: '0.56'
2137
- Include:
2138
- - '**/test/**/*'
2139
-
2140
- Rails/BelongsTo:
2141
- Description: >-
2142
- Use `optional: true` instead of `required: false` for
2143
- `belongs_to` relations'
2144
- Enabled: true
2145
- VersionAdded: '0.62'
2146
-
2147
- Rails/Blank:
2148
- Description: 'Enforces use of `blank?`.'
2149
- Enabled: true
2150
- VersionAdded: '0.48'
2151
- VersionChanged: '0.67'
2152
- # Convert usages of `nil? || empty?` to `blank?`
2153
- NilOrEmpty: true
2154
- # Convert usages of `!present?` to `blank?`
2155
- NotPresent: true
2156
- # Convert usages of `unless present?` to `if blank?`
2157
- UnlessPresent: true
2158
-
2159
- Rails/BulkChangeTable:
2160
- Description: 'Check whether alter queries are combinable.'
2161
- Enabled: true
2162
- VersionAdded: '0.57'
2163
- Database: null
2164
- SupportedDatabases:
2165
- - mysql
2166
- - postgresql
2167
- Include:
2168
- - db/migrate/*.rb
2169
-
2170
- Rails/CreateTableWithTimestamps:
2171
- Description: >-
2172
- Checks the migration for which timestamps are not included
2173
- when creating a new table.
2174
- Enabled: true
2175
- VersionAdded: '0.52'
2176
- Include:
2177
- - db/migrate/*.rb
2178
-
2179
- Rails/Date:
2180
- Description: >-
2181
- Checks the correct usage of date aware methods,
2182
- such as Date.today, Date.current etc.
2183
- Enabled: true
2184
- VersionAdded: '0.30'
2185
- VersionChanged: '0.33'
2186
- # The value `strict` disallows usage of `Date.today`, `Date.current`,
2187
- # `Date#to_time` etc.
2188
- # The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc
2189
- # (but not `Date.today`) which are overridden by ActiveSupport to handle current
2190
- # time zone.
2191
- EnforcedStyle: flexible
2192
- SupportedStyles:
2193
- - strict
2194
- - flexible
2195
-
2196
- Rails/Delegate:
2197
- Description: 'Prefer delegate method for delegations.'
2198
- Enabled: true
2199
- VersionAdded: '0.21'
2200
- VersionChanged: '0.50'
2201
- # When set to true, using the target object as a prefix of the
2202
- # method name without using the `delegate` method will be a
2203
- # violation. When set to false, this case is legal.
2204
- EnforceForPrefixed: true
2205
-
2206
- Rails/DelegateAllowBlank:
2207
- Description: 'Do not use allow_blank as an option to delegate.'
2208
- Enabled: true
2209
- VersionAdded: '0.44'
2210
-
2211
- Rails/DynamicFindBy:
2212
- Description: 'Use `find_by` instead of dynamic `find_by_*`.'
2213
- StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find_by'
2214
- Enabled: true
2215
- VersionAdded: '0.44'
2216
- Whitelist:
2217
- - find_by_sql
2218
-
2219
- Rails/EnumUniqueness:
2220
- Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
2221
- Enabled: true
2222
- VersionAdded: '0.46'
2223
- Include:
2224
- - app/models/**/*.rb
2225
-
2226
- Rails/EnvironmentComparison:
2227
- Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`"
2228
- Enabled: true
2229
- VersionAdded: '0.52'
2230
-
2231
- Rails/Exit:
2232
- Description: >-
2233
- Favor `fail`, `break`, `return`, etc. over `exit` in
2234
- application or library code outside of Rake files to avoid
2235
- exits during unit testing or running in production.
2236
- Enabled: true
2237
- VersionAdded: '0.41'
2238
- Include:
2239
- - app/**/*.rb
2240
- - config/**/*.rb
2241
- - lib/**/*.rb
2242
- Exclude:
2243
- - lib/**/*.rake
2244
-
2245
- Rails/FilePath:
2246
- Description: 'Use `Rails.root.join` for file path joining.'
2247
- Enabled: true
2248
- VersionAdded: '0.47'
2249
- VersionChanged: '0.57'
2250
- EnforcedStyle: arguments
2251
- SupportedStyles:
2252
- - slashes
2253
- - arguments
2254
-
2255
- Rails/FindBy:
2256
- Description: 'Prefer find_by over where.first.'
2257
- StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find_by'
2258
- Enabled: true
2259
- VersionAdded: '0.30'
2260
- Include:
2261
- - app/models/**/*.rb
2262
-
2263
- Rails/FindEach:
2264
- Description: 'Prefer all.find_each over all.find.'
2265
- StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find-each'
2266
- Enabled: true
2267
- VersionAdded: '0.30'
2268
- Include:
2269
- - app/models/**/*.rb
2270
-
2271
- Rails/HasAndBelongsToMany:
2272
- Description: 'Prefer has_many :through to has_and_belongs_to_many.'
2273
- StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#has-many-through'
2274
- Enabled: true
2275
- VersionAdded: '0.12'
2276
- Include:
2277
- - app/models/**/*.rb
2278
-
2279
- Rails/HasManyOrHasOneDependent:
2280
- Description: 'Define the dependent option to the has_many and has_one associations.'
2281
- StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#has_many-has_one-dependent-option'
2282
- Enabled: true
2283
- VersionAdded: '0.50'
2284
- Include:
2285
- - app/models/**/*.rb
2286
-
2287
- Rails/HttpPositionalArguments:
2288
- Description: 'Use keyword arguments instead of positional arguments in http method calls.'
2289
- Enabled: true
2290
- VersionAdded: '0.44'
2291
- Include:
2292
- - 'spec/**/*'
2293
- - 'test/**/*'
2294
-
2295
- Rails/HttpStatus:
2296
- Description: 'Enforces use of symbolic or numeric value to define HTTP status.'
2297
- Enabled: true
2298
- VersionAdded: '0.54'
2299
- EnforcedStyle: symbolic
2300
- SupportedStyles:
2301
- - numeric
2302
- - symbolic
2303
-
2304
- Rails/IgnoredSkipActionFilterOption:
2305
- Description: 'Checks that `if` and `only` (or `except`) are not used together as options of `skip_*` action filter.'
2306
- Reference: 'https://api.rubyonrails.org/classes/AbstractController/Callbacks/ClassMethods.html#method-i-_normalize_callback_options'
2307
- Enabled: true
2308
- VersionAdded: '0.63'
2309
- Include:
2310
- - app/controllers/**/*.rb
2311
-
2312
- Rails/InverseOf:
2313
- Description: 'Checks for associations where the inverse cannot be determined automatically.'
2314
- Enabled: true
2315
- VersionAdded: '0.52'
2316
- Include:
2317
- - app/models/**/*.rb
2318
-
2319
- Rails/LexicallyScopedActionFilter:
2320
- Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the controller."
2321
- StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#lexically-scoped-action-filter'
2322
- Enabled: true
2323
- Safe: false
2324
- VersionAdded: '0.52'
2325
- Include:
2326
- - app/controllers/**/*.rb
2327
-
2328
- Rails/LinkToBlank:
2329
- Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.'
2330
- Reference:
2331
- - https://mathiasbynens.github.io/rel-noopener/
2332
- - https://html.spec.whatwg.org/multipage/links.html#link-type-noopener
2333
- - https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer
2334
- Enabled: true
2335
- VersionAdded: '0.62'
2336
-
2337
- Rails/NotNullColumn:
2338
- Description: 'Do not add a NOT NULL column without a default value'
2339
- Enabled: true
2340
- VersionAdded: '0.43'
2341
- Include:
2342
- - db/migrate/*.rb
2343
-
2344
- Rails/Output:
2345
- Description: 'Checks for calls to puts, print, etc.'
2346
- Enabled: true
2347
- VersionAdded: '0.15'
2348
- VersionChanged: '0.19'
2349
- Include:
2350
- - app/**/*.rb
2351
- - config/**/*.rb
2352
- - db/**/*.rb
2353
- - lib/**/*.rb
2354
-
2355
- Rails/OutputSafety:
2356
- Description: 'The use of `html_safe` or `raw` may be a security risk.'
2357
- Enabled: true
2358
- VersionAdded: '0.41'
2359
-
2360
- Rails/PluralizationGrammar:
2361
- Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
2362
- Enabled: true
2363
- VersionAdded: '0.35'
2364
-
2365
- Rails/Presence:
2366
- Description: 'Checks code that can be written more easily using `Object#presence` defined by Active Support.'
2367
- Enabled: true
2368
- VersionAdded: '0.52'
2369
-
2370
- Rails/Present:
2371
- Description: 'Enforces use of `present?`.'
2372
- Enabled: true
2373
- VersionAdded: '0.48'
2374
- VersionChanged: '0.67'
2375
- # Convert usages of `!nil? && !empty?` to `present?`
2376
- NotNilAndNotEmpty: true
2377
- # Convert usages of `!blank?` to `present?`
2378
- NotBlank: true
2379
- # Convert usages of `unless blank?` to `if present?`
2380
- UnlessBlank: true
2381
-
2382
- Rails/ReadWriteAttribute:
2383
- Description: >-
2384
- Checks for read_attribute(:attr) and
2385
- write_attribute(:attr, val).
2386
- StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#read-attribute'
2387
- Enabled: true
2388
- VersionAdded: '0.20'
2389
- VersionChanged: '0.29'
2390
- Include:
2391
- - app/models/**/*.rb
2392
-
2393
- Rails/RedundantAllowNil:
2394
- Description: >-
2395
- Finds redundant use of `allow_nil` when `allow_blank` is set to
2396
- certain values in model validations.
2397
- Enabled: true
2398
- VersionAdded: '0.67'
2399
- Include:
2400
- - app/models/**/*.rb
2401
-
2402
- Rails/RedundantReceiverInWithOptions:
2403
- Description: 'Checks for redundant receiver in `with_options`.'
2404
- Enabled: true
2405
- VersionAdded: '0.52'
2406
-
2407
- Rails/ReflectionClassName:
2408
- Description: 'Use a string for `class_name` option value in the definition of a reflection.'
2409
- Enabled: true
2410
- VersionAdded: '0.64'
2411
-
2412
- Rails/RefuteMethods:
2413
- Description: 'Use `assert_not` methods instead of `refute` methods.'
2414
- Enabled: true
2415
- VersionAdded: '0.56'
2416
- Include:
2417
- - '**/test/**/*'
2418
-
2419
- Rails/RelativeDateConstant:
2420
- Description: 'Do not assign relative date to constants.'
2421
- Enabled: true
2422
- VersionAdded: '0.48'
2423
- VersionChanged: '0.59'
2424
- AutoCorrect: false
2425
-
2426
- Rails/RequestReferer:
2427
- Description: 'Use consistent syntax for request.referer.'
2428
- Enabled: true
2429
- VersionAdded: '0.41'
2430
- EnforcedStyle: referer
2431
- SupportedStyles:
2432
- - referer
2433
- - referrer
2434
-
2435
- Rails/ReversibleMigration:
2436
- Description: 'Checks whether the change method of the migration file is reversible.'
2437
- StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#reversible-migration'
2438
- Reference: 'https://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
2439
- Enabled: true
2440
- VersionAdded: '0.47'
2441
- Include:
2442
- - db/migrate/*.rb
2443
-
2444
- Rails/SafeNavigation:
2445
- Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
2446
- Enabled: true
2447
- VersionAdded: '0.43'
2448
- # This will convert usages of `try` to use safe navigation as well as `try!`.
2449
- # `try` and `try!` work slightly differently. `try!` and safe navigation will
2450
- # both raise a `NoMethodError` if the receiver of the method call does not
2451
- # implement the intended method. `try` will not raise an exception for this.
2452
- ConvertTry: false
2453
-
2454
- Rails/SaveBang:
2455
- Description: 'Identifies possible cases where Active Record save! or related should be used.'
2456
- StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#save-bang'
2457
- Enabled: false
2458
- VersionAdded: '0.42'
2459
- VersionChanged: '0.59'
2460
- AllowImplicitReturn: true
2461
- AllowedReceivers: []
2462
-
2463
- Rails/ScopeArgs:
2464
- Description: 'Checks the arguments of ActiveRecord scopes.'
2465
- Enabled: true
2466
- VersionAdded: '0.19'
2467
- Include:
2468
- - app/models/**/*.rb
2469
-
2470
- Rails/SkipsModelValidations:
2471
- Description: >-
2472
- Use methods that skips model validations with caution.
2473
- See reference for more information.
2474
- Reference: 'https://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
2475
- Enabled: true
2476
- VersionAdded: '0.47'
2477
- VersionChanged: '0.60'
2478
- Blacklist:
2479
- - decrement!
2480
- - decrement_counter
2481
- - increment!
2482
- - increment_counter
2483
- - toggle!
2484
- - touch
2485
- - update_all
2486
- - update_attribute
2487
- - update_column
2488
- - update_columns
2489
- - update_counters
2490
- Whitelist: []
2491
-
2492
- Rails/TimeZone:
2493
- Description: 'Checks the correct usage of time zone aware methods.'
2494
- StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#time'
2495
- Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
2496
- Enabled: true
2497
- Safe: false
2498
- VersionAdded: '0.30'
2499
- VersionChanged: '0.68'
2500
- # The value `strict` means that `Time` should be used with `zone`.
2501
- # The value `flexible` allows usage of `in_time_zone` instead of `zone`.
2502
- EnforcedStyle: flexible
2503
- SupportedStyles:
2504
- - strict
2505
- - flexible
2506
-
2507
- Rails/UniqBeforePluck:
2508
- Description: 'Prefer the use of uniq or distinct before pluck.'
2509
- Enabled: true
2510
- VersionAdded: '0.40'
2511
- VersionChanged: '0.47'
2512
- EnforcedStyle: conservative
2513
- SupportedStyles:
2514
- - conservative
2515
- - aggressive
2516
- AutoCorrect: false
2517
-
2518
- Rails/UnknownEnv:
2519
- Description: 'Use correct environment name.'
2520
- Enabled: true
2521
- VersionAdded: '0.51'
2522
- Environments:
2523
- - development
2524
- - test
2525
- - production
2526
-
2527
- Rails/Validation:
2528
- Description: 'Use validates :attribute, hash of validations.'
2529
- Enabled: true
2530
- VersionAdded: '0.9'
2531
- VersionChanged: '0.41'
2532
- Include:
2533
- - app/models/**/*.rb
2534
-
2535
2080
  #################### Security ##############################
2536
2081
 
2537
2082
  Security/Eval:
@@ -2588,7 +2133,7 @@ Style/AccessModifierDeclarations:
2588
2133
 
2589
2134
  Style/Alias:
2590
2135
  Description: 'Use alias instead of alias_method.'
2591
- StyleGuide: '#alias-method'
2136
+ StyleGuide: '#alias-method-lexically'
2592
2137
  Enabled: true
2593
2138
  VersionAdded: '0.9'
2594
2139
  VersionChanged: '0.36'
@@ -2939,6 +2484,13 @@ Style/ConditionalAssignment:
2939
2484
  SingleLineConditionsOnly: true
2940
2485
  IncludeTernaryExpressions: true
2941
2486
 
2487
+ Style/ConstantVisibility:
2488
+ Description: >-
2489
+ Check that class- and module constants have
2490
+ visibility declarations.
2491
+ Enabled: false
2492
+ VersionAdded: '0.66'
2493
+
2942
2494
  # Checks that you have put a copyright in a comment before any code.
2943
2495
  #
2944
2496
  # You can override the default Notice in your .rubocop.yml file.
@@ -2957,13 +2509,6 @@ Style/ConditionalAssignment:
2957
2509
  # Notice: 'Copyright (\(c\) )?2015 Yahoo! Inc'
2958
2510
  # AutocorrectNotice: '# Copyright (c) 2015 Yahoo! Inc.'
2959
2511
  #
2960
- Style/ConstantVisibility:
2961
- Description: >-
2962
- Check that class- and module constants have
2963
- visibility declarations.
2964
- Enabled: false
2965
- VersionAdded: '0.66'
2966
-
2967
2512
  Style/Copyright:
2968
2513
  Description: 'Include a copyright notice in each file before any code.'
2969
2514
  Enabled: false
@@ -3094,7 +2639,7 @@ Style/EvalWithLocation:
3094
2639
  VersionAdded: '0.52'
3095
2640
 
3096
2641
  Style/EvenOdd:
3097
- Description: 'Favor the use of Integer#even? && Integer#odd?'
2642
+ Description: 'Favor the use of `Integer#even?` && `Integer#odd?`.'
3098
2643
  StyleGuide: '#predicate-methods'
3099
2644
  Enabled: true
3100
2645
  VersionAdded: '0.12'
@@ -3105,6 +2650,19 @@ Style/ExpandPathArguments:
3105
2650
  Enabled: true
3106
2651
  VersionAdded: '0.53'
3107
2652
 
2653
+ Style/FloatDivision:
2654
+ Description: 'For performing float division, coerce one side only.'
2655
+ StyleGuide: '#float-division'
2656
+ Reference: 'https://github.com/rubocop-hq/ruby-style-guide/issues/628'
2657
+ Enabled: true
2658
+ VersionAdded: '0.72'
2659
+ EnforcedStyle: single_coerce
2660
+ SupportedStyles:
2661
+ - left_coerce
2662
+ - right_coerce
2663
+ - single_coerce
2664
+ - fdiv
2665
+
3108
2666
  Style/For:
3109
2667
  Description: 'Checks use of for or each in multiline loops.'
3110
2668
  StyleGuide: '#no-for-loops'
@@ -3170,7 +2728,7 @@ Style/GlobalVars:
3170
2728
  AllowedVariables: []
3171
2729
 
3172
2730
  Style/GuardClause:
3173
- Description: 'Check for conditionals that can be replaced with guard clauses'
2731
+ Description: 'Check for conditionals that can be replaced with guard clauses.'
3174
2732
  StyleGuide: '#no-nested-conditionals'
3175
2733
  Enabled: true
3176
2734
  VersionAdded: '0.20'
@@ -3213,6 +2771,7 @@ Style/IdenticalConditionalBranches:
3213
2771
  Style/IfInsideElse:
3214
2772
  Description: 'Finds if nodes inside else, which can be converted to elsif.'
3215
2773
  Enabled: true
2774
+ AllowIfModifier: false
3216
2775
  VersionAdded: '0.36'
3217
2776
 
3218
2777
  Style/IfUnlessModifier:
@@ -3378,7 +2937,7 @@ Style/MethodMissingSuper:
3378
2937
  Style/MinMax:
3379
2938
  Description: >-
3380
2939
  Use `Enumerable#minmax` instead of `Enumerable#min`
3381
- and `Enumerable#max` in conjunction.'
2940
+ and `Enumerable#max` in conjunction.
3382
2941
  Enabled: true
3383
2942
  VersionAdded: '0.50'
3384
2943
 
@@ -3388,7 +2947,7 @@ Style/MissingElse:
3388
2947
  If enabled, it is recommended that
3389
2948
  Style/UnlessElse and Style/EmptyElse be enabled.
3390
2949
  This will conflict with Style/EmptyElse if
3391
- Style/EmptyElse is configured to style "both"
2950
+ Style/EmptyElse is configured to style "both".
3392
2951
  Enabled: false
3393
2952
  VersionAdded: '0.30'
3394
2953
  VersionChanged: '0.38'
@@ -3700,7 +3259,7 @@ Style/OptionHash:
3700
3259
  Style/OptionalArguments:
3701
3260
  Description: >-
3702
3261
  Checks for optional arguments that do not appear at the end
3703
- of the argument list
3262
+ of the argument list.
3704
3263
  StyleGuide: '#optional-arguments'
3705
3264
  Enabled: true
3706
3265
  VersionAdded: '0.33'
@@ -3732,7 +3291,7 @@ Style/ParenthesesAroundCondition:
3732
3291
  AllowInMultilineConditions: false
3733
3292
 
3734
3293
  Style/PercentLiteralDelimiters:
3735
- Description: 'Use `%`-literal delimiters consistently'
3294
+ Description: 'Use `%`-literal delimiters consistently.'
3736
3295
  StyleGuide: '#percent-literal-braces'
3737
3296
  Enabled: true
3738
3297
  VersionAdded: '0.19'
@@ -4264,7 +3823,7 @@ Style/UnneededSort:
4264
3823
  Style/UnpackFirst:
4265
3824
  Description: >-
4266
3825
  Checks for accessing the first element of `String#unpack`
4267
- instead of using `unpack1`
3826
+ instead of using `unpack1`.
4268
3827
  Enabled: true
4269
3828
  VersionAdded: '0.54'
4270
3829
 
@@ -4315,7 +3874,7 @@ Style/WordArray:
4315
3874
  # whose element count is greater than or equal to `MinSize`.
4316
3875
  MinSize: 2
4317
3876
  # The regular expression `WordRegex` decides what is considered a word.
4318
- WordRegex: !ruby/regexp '/\A[\p{Word}\n\t]+\z/'
3877
+ WordRegex: !ruby/regexp '/\A(?:\p{Word}|\p{Word}-\p{Word}|\n|\t)+\z/'
4319
3878
 
4320
3879
  Style/YodaCondition:
4321
3880
  Description: 'Forbid or enforce yoda conditions.'