rubocop 0.71.0 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -8
- data/config/default.yml +42 -484
- data/lib/rubocop.rb +5 -53
- data/lib/rubocop/ast/builder.rb +2 -0
- data/lib/rubocop/ast/node.rb +1 -1
- data/lib/rubocop/ast/node/float_node.rb +12 -0
- data/lib/rubocop/ast/node/int_node.rb +12 -0
- data/lib/rubocop/ast/node/mixin/numeric_node.rb +21 -0
- data/lib/rubocop/ast/node/resbody_node.rb +1 -6
- data/lib/rubocop/cached_data.rb +1 -1
- data/lib/rubocop/config.rb +34 -5
- data/lib/rubocop/config_loader.rb +2 -6
- data/lib/rubocop/config_loader_resolver.rb +0 -14
- data/lib/rubocop/cop/cop.rb +0 -4
- data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +55 -0
- data/lib/rubocop/cop/layout/class_structure.rb +1 -1
- data/lib/rubocop/cop/layout/indent_first_argument.rb +6 -2
- data/lib/rubocop/cop/layout/indent_first_parameter.rb +7 -3
- data/lib/rubocop/cop/layout/indent_heredoc.rb +0 -1
- data/lib/rubocop/cop/layout/indentation_consistency.rb +13 -12
- data/lib/rubocop/cop/layout/indentation_width.rb +8 -4
- data/lib/rubocop/cop/lint/number_conversion.rb +1 -1
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +21 -20
- data/lib/rubocop/cop/style/commented_keyword.rb +1 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +2 -1
- data/lib/rubocop/cop/style/float_division.rb +94 -0
- data/lib/rubocop/cop/style/format_string.rb +7 -3
- data/lib/rubocop/cop/style/if_inside_else.rb +42 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +7 -1
- data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
- data/lib/rubocop/cop/style/ternary_parentheses.rb +12 -2
- data/lib/rubocop/cop/style/word_array.rb +2 -2
- data/lib/rubocop/cop/style/zero_length_predicate.rb +1 -1
- data/lib/rubocop/options.rb +0 -2
- data/lib/rubocop/processed_source.rb +2 -1
- data/lib/rubocop/rspec/cop_helper.rb +0 -1
- data/lib/rubocop/rspec/shared_contexts.rb +0 -17
- data/lib/rubocop/rspec/support.rb +0 -1
- data/lib/rubocop/runner.rb +0 -17
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop/yaml_duplication_checker.rb +8 -2
- metadata +8 -91
- data/lib/rubocop/cop/mixin/target_rails_version.rb +0 -16
- data/lib/rubocop/cop/rails/action_filter.rb +0 -117
- data/lib/rubocop/cop/rails/active_record_aliases.rb +0 -48
- data/lib/rubocop/cop/rails/active_record_override.rb +0 -82
- data/lib/rubocop/cop/rails/active_support_aliases.rb +0 -69
- data/lib/rubocop/cop/rails/application_job.rb +0 -40
- data/lib/rubocop/cop/rails/application_record.rb +0 -40
- data/lib/rubocop/cop/rails/assert_not.rb +0 -44
- data/lib/rubocop/cop/rails/belongs_to.rb +0 -102
- data/lib/rubocop/cop/rails/blank.rb +0 -164
- data/lib/rubocop/cop/rails/bulk_change_table.rb +0 -289
- data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +0 -91
- data/lib/rubocop/cop/rails/date.rb +0 -161
- data/lib/rubocop/cop/rails/delegate.rb +0 -132
- data/lib/rubocop/cop/rails/delegate_allow_blank.rb +0 -37
- data/lib/rubocop/cop/rails/dynamic_find_by.rb +0 -91
- data/lib/rubocop/cop/rails/enum_uniqueness.rb +0 -45
- data/lib/rubocop/cop/rails/environment_comparison.rb +0 -68
- data/lib/rubocop/cop/rails/exit.rb +0 -67
- data/lib/rubocop/cop/rails/file_path.rb +0 -108
- data/lib/rubocop/cop/rails/find_by.rb +0 -55
- data/lib/rubocop/cop/rails/find_each.rb +0 -51
- data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +0 -25
- data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +0 -106
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +0 -117
- data/lib/rubocop/cop/rails/http_status.rb +0 -179
- data/lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb +0 -94
- data/lib/rubocop/cop/rails/inverse_of.rb +0 -246
- data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +0 -175
- data/lib/rubocop/cop/rails/link_to_blank.rb +0 -98
- data/lib/rubocop/cop/rails/not_null_column.rb +0 -67
- data/lib/rubocop/cop/rails/output.rb +0 -49
- data/lib/rubocop/cop/rails/output_safety.rb +0 -99
- data/lib/rubocop/cop/rails/pluralization_grammar.rb +0 -107
- data/lib/rubocop/cop/rails/presence.rb +0 -124
- data/lib/rubocop/cop/rails/present.rb +0 -153
- data/lib/rubocop/cop/rails/read_write_attribute.rb +0 -74
- data/lib/rubocop/cop/rails/redundant_allow_nil.rb +0 -111
- data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +0 -136
- data/lib/rubocop/cop/rails/reflection_class_name.rb +0 -37
- data/lib/rubocop/cop/rails/refute_methods.rb +0 -76
- data/lib/rubocop/cop/rails/relative_date_constant.rb +0 -93
- data/lib/rubocop/cop/rails/request_referer.rb +0 -56
- data/lib/rubocop/cop/rails/reversible_migration.rb +0 -286
- data/lib/rubocop/cop/rails/safe_navigation.rb +0 -87
- data/lib/rubocop/cop/rails/save_bang.rb +0 -316
- data/lib/rubocop/cop/rails/scope_args.rb +0 -29
- data/lib/rubocop/cop/rails/skips_model_validations.rb +0 -87
- data/lib/rubocop/cop/rails/time_zone.rb +0 -238
- data/lib/rubocop/cop/rails/uniq_before_pluck.rb +0 -105
- data/lib/rubocop/cop/rails/unknown_env.rb +0 -63
- data/lib/rubocop/cop/rails/validation.rb +0 -109
- data/lib/rubocop/rspec/shared_examples.rb +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eba7ed97b0ff87530eaaac338ed31f332f89dd4c86ca8afc3046d8141d3f1c03
|
4
|
+
data.tar.gz: 23a2c2e2c59efb26294495c94b33e1849feef60b8afe26e98064ff01e98cbccf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72a13a6ca2580bc1613ee8cb5a2432f564fb6f53f68558bd716046d4f5c28b73a57535d9eb4c96542f9cbaa5f29ee1226ec71e1b66a342ac4810106b69f3ef5d
|
7
|
+
data.tar.gz: aa480f20807bf7d31c878eeade72cf09a4963174b7490738f77cc8a8cf5a59b2a40b2f20dbc969719863aed1c672136ef32b7173f5d231c3f387dc25a62f77ac
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
**RuboCop** is a Ruby static code analyzer and code formatter. Out of
|
21
21
|
the box it will enforce many of the guidelines outlined in the
|
22
22
|
community [Ruby Style
|
23
|
-
Guide](https://
|
23
|
+
Guide](https://rubystyle.guide).
|
24
24
|
|
25
25
|
RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various
|
26
26
|
[configuration options](https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml).
|
@@ -52,7 +52,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
|
|
52
52
|
might want to use a conservative version lock in your `Gemfile`:
|
53
53
|
|
54
54
|
```rb
|
55
|
-
gem 'rubocop', '~> 0.
|
55
|
+
gem 'rubocop', '~> 0.72.0', require: false
|
56
56
|
```
|
57
57
|
|
58
58
|
## Quickstart
|
@@ -64,9 +64,9 @@ $ cd my/cool/ruby/project
|
|
64
64
|
$ rubocop
|
65
65
|
```
|
66
66
|
|
67
|
-
##
|
67
|
+
## Documentation
|
68
68
|
|
69
|
-
You can read a
|
69
|
+
You can read a lot more about RuboCop in its [official docs](https://docs.rubocop.org).
|
70
70
|
|
71
71
|
## Compatibility
|
72
72
|
|
@@ -75,10 +75,6 @@ RuboCop supports the following Ruby implementations:
|
|
75
75
|
* MRI 2.3+
|
76
76
|
* JRuby 9.1+
|
77
77
|
|
78
|
-
The Rails cops support the following versions:
|
79
|
-
|
80
|
-
* Rails 4.0+
|
81
|
-
|
82
78
|
## Team
|
83
79
|
|
84
80
|
Here's a list of RuboCop's core developers:
|
data/config/default.yml
CHANGED
@@ -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://
|
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 `
|
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
|
-
-
|
789
|
+
- indented_internal_methods
|
791
790
|
Reference:
|
792
|
-
# A reference to `EnforcedStyle:
|
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.
|
@@ -1619,7 +1618,7 @@ Lint/StringConversionInInterpolation:
|
|
1619
1618
|
VersionChanged: '0.20'
|
1620
1619
|
|
1621
1620
|
Lint/Syntax:
|
1622
|
-
Description: 'Checks syntax error'
|
1621
|
+
Description: 'Checks syntax error.'
|
1623
1622
|
Enabled: true
|
1624
1623
|
VersionAdded: '0.9'
|
1625
1624
|
|
@@ -1635,7 +1634,7 @@ Lint/UnderscorePrefixedVariableName:
|
|
1635
1634
|
AllowKeywordBlockArguments: false
|
1636
1635
|
|
1637
1636
|
Lint/UnifiedInteger:
|
1638
|
-
Description: 'Use Integer instead of Fixnum or Bignum'
|
1637
|
+
Description: 'Use Integer instead of Fixnum or Bignum.'
|
1639
1638
|
Enabled: true
|
1640
1639
|
VersionAdded: '0.43'
|
1641
1640
|
|
@@ -1658,7 +1657,7 @@ Lint/UnneededRequireStatement:
|
|
1658
1657
|
VersionAdded: '0.51'
|
1659
1658
|
|
1660
1659
|
Lint/UnneededSplatExpansion:
|
1661
|
-
Description: 'Checks for splat unnecessarily being called on literals'
|
1660
|
+
Description: 'Checks for splat unnecessarily being called on literals.'
|
1662
1661
|
Enabled: true
|
1663
1662
|
VersionAdded: '0.43'
|
1664
1663
|
|
@@ -1767,7 +1766,7 @@ Metrics/BlockLength:
|
|
1767
1766
|
- '**/*.gemspec'
|
1768
1767
|
|
1769
1768
|
Metrics/BlockNesting:
|
1770
|
-
Description: 'Avoid excessive block nesting'
|
1769
|
+
Description: 'Avoid excessive block nesting.'
|
1771
1770
|
StyleGuide: '#three-is-the-number-thou-shalt-count'
|
1772
1771
|
Enabled: true
|
1773
1772
|
VersionAdded: '0.25'
|
@@ -2078,461 +2077,6 @@ Naming/VariableNumber:
|
|
2078
2077
|
- normalcase
|
2079
2078
|
- non_integer
|
2080
2079
|
|
2081
|
-
#################### Rails #################################
|
2082
|
-
|
2083
|
-
# By default, the rails cops are not run. Override in project or home
|
2084
|
-
# directory .rubocop.yml files, or by giving the -R/--rails option.
|
2085
|
-
Rails:
|
2086
|
-
Enabled: false
|
2087
|
-
|
2088
|
-
Rails/ActionFilter:
|
2089
|
-
Description: 'Enforces consistent use of action filter methods.'
|
2090
|
-
Enabled: true
|
2091
|
-
VersionAdded: '0.19'
|
2092
|
-
EnforcedStyle: action
|
2093
|
-
SupportedStyles:
|
2094
|
-
- action
|
2095
|
-
- filter
|
2096
|
-
Include:
|
2097
|
-
- app/controllers/**/*.rb
|
2098
|
-
|
2099
|
-
Rails/ActiveRecordAliases:
|
2100
|
-
Description: >-
|
2101
|
-
Avoid Active Record aliases:
|
2102
|
-
Use `update` instead of `update_attributes`.
|
2103
|
-
Use `update!` instead of `update_attributes!`.
|
2104
|
-
Enabled: true
|
2105
|
-
VersionAdded: '0.53'
|
2106
|
-
|
2107
|
-
Rails/ActiveRecordOverride:
|
2108
|
-
Description: >-
|
2109
|
-
Check for overriding Active Record methods instead of using
|
2110
|
-
callbacks.
|
2111
|
-
Enabled: true
|
2112
|
-
VersionAdded: '0.67'
|
2113
|
-
Include:
|
2114
|
-
- app/models/**/*.rb
|
2115
|
-
|
2116
|
-
Rails/ActiveSupportAliases:
|
2117
|
-
Description: >-
|
2118
|
-
Avoid ActiveSupport aliases of standard ruby methods:
|
2119
|
-
`String#starts_with?`, `String#ends_with?`,
|
2120
|
-
`Array#append`, `Array#prepend`.
|
2121
|
-
Enabled: true
|
2122
|
-
VersionAdded: '0.48'
|
2123
|
-
|
2124
|
-
Rails/ApplicationJob:
|
2125
|
-
Description: 'Check that jobs subclass ApplicationJob.'
|
2126
|
-
Enabled: true
|
2127
|
-
VersionAdded: '0.49'
|
2128
|
-
|
2129
|
-
Rails/ApplicationRecord:
|
2130
|
-
Description: 'Check that models subclass ApplicationRecord.'
|
2131
|
-
Enabled: true
|
2132
|
-
VersionAdded: '0.49'
|
2133
|
-
|
2134
|
-
Rails/AssertNot:
|
2135
|
-
Description: 'Use `assert_not` instead of `assert !`.'
|
2136
|
-
Enabled: true
|
2137
|
-
VersionAdded: '0.56'
|
2138
|
-
Include:
|
2139
|
-
- '**/test/**/*'
|
2140
|
-
|
2141
|
-
Rails/BelongsTo:
|
2142
|
-
Description: >-
|
2143
|
-
Use `optional: true` instead of `required: false` for
|
2144
|
-
`belongs_to` relations'
|
2145
|
-
Enabled: true
|
2146
|
-
VersionAdded: '0.62'
|
2147
|
-
|
2148
|
-
Rails/Blank:
|
2149
|
-
Description: 'Enforces use of `blank?`.'
|
2150
|
-
Enabled: true
|
2151
|
-
VersionAdded: '0.48'
|
2152
|
-
VersionChanged: '0.67'
|
2153
|
-
# Convert usages of `nil? || empty?` to `blank?`
|
2154
|
-
NilOrEmpty: true
|
2155
|
-
# Convert usages of `!present?` to `blank?`
|
2156
|
-
NotPresent: true
|
2157
|
-
# Convert usages of `unless present?` to `if blank?`
|
2158
|
-
UnlessPresent: true
|
2159
|
-
|
2160
|
-
Rails/BulkChangeTable:
|
2161
|
-
Description: 'Check whether alter queries are combinable.'
|
2162
|
-
Enabled: true
|
2163
|
-
VersionAdded: '0.57'
|
2164
|
-
Database: null
|
2165
|
-
SupportedDatabases:
|
2166
|
-
- mysql
|
2167
|
-
- postgresql
|
2168
|
-
Include:
|
2169
|
-
- db/migrate/*.rb
|
2170
|
-
|
2171
|
-
Rails/CreateTableWithTimestamps:
|
2172
|
-
Description: >-
|
2173
|
-
Checks the migration for which timestamps are not included
|
2174
|
-
when creating a new table.
|
2175
|
-
Enabled: true
|
2176
|
-
VersionAdded: '0.52'
|
2177
|
-
Include:
|
2178
|
-
- db/migrate/*.rb
|
2179
|
-
|
2180
|
-
Rails/Date:
|
2181
|
-
Description: >-
|
2182
|
-
Checks the correct usage of date aware methods,
|
2183
|
-
such as Date.today, Date.current etc.
|
2184
|
-
Enabled: true
|
2185
|
-
VersionAdded: '0.30'
|
2186
|
-
VersionChanged: '0.33'
|
2187
|
-
# The value `strict` disallows usage of `Date.today`, `Date.current`,
|
2188
|
-
# `Date#to_time` etc.
|
2189
|
-
# The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc
|
2190
|
-
# (but not `Date.today`) which are overridden by ActiveSupport to handle current
|
2191
|
-
# time zone.
|
2192
|
-
EnforcedStyle: flexible
|
2193
|
-
SupportedStyles:
|
2194
|
-
- strict
|
2195
|
-
- flexible
|
2196
|
-
|
2197
|
-
Rails/Delegate:
|
2198
|
-
Description: 'Prefer delegate method for delegations.'
|
2199
|
-
Enabled: true
|
2200
|
-
VersionAdded: '0.21'
|
2201
|
-
VersionChanged: '0.50'
|
2202
|
-
# When set to true, using the target object as a prefix of the
|
2203
|
-
# method name without using the `delegate` method will be a
|
2204
|
-
# violation. When set to false, this case is legal.
|
2205
|
-
EnforceForPrefixed: true
|
2206
|
-
|
2207
|
-
Rails/DelegateAllowBlank:
|
2208
|
-
Description: 'Do not use allow_blank as an option to delegate.'
|
2209
|
-
Enabled: true
|
2210
|
-
VersionAdded: '0.44'
|
2211
|
-
|
2212
|
-
Rails/DynamicFindBy:
|
2213
|
-
Description: 'Use `find_by` instead of dynamic `find_by_*`.'
|
2214
|
-
StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find_by'
|
2215
|
-
Enabled: true
|
2216
|
-
VersionAdded: '0.44'
|
2217
|
-
Whitelist:
|
2218
|
-
- find_by_sql
|
2219
|
-
|
2220
|
-
Rails/EnumUniqueness:
|
2221
|
-
Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
|
2222
|
-
Enabled: true
|
2223
|
-
VersionAdded: '0.46'
|
2224
|
-
Include:
|
2225
|
-
- app/models/**/*.rb
|
2226
|
-
|
2227
|
-
Rails/EnvironmentComparison:
|
2228
|
-
Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`"
|
2229
|
-
Enabled: true
|
2230
|
-
VersionAdded: '0.52'
|
2231
|
-
|
2232
|
-
Rails/Exit:
|
2233
|
-
Description: >-
|
2234
|
-
Favor `fail`, `break`, `return`, etc. over `exit` in
|
2235
|
-
application or library code outside of Rake files to avoid
|
2236
|
-
exits during unit testing or running in production.
|
2237
|
-
Enabled: true
|
2238
|
-
VersionAdded: '0.41'
|
2239
|
-
Include:
|
2240
|
-
- app/**/*.rb
|
2241
|
-
- config/**/*.rb
|
2242
|
-
- lib/**/*.rb
|
2243
|
-
Exclude:
|
2244
|
-
- lib/**/*.rake
|
2245
|
-
|
2246
|
-
Rails/FilePath:
|
2247
|
-
Description: 'Use `Rails.root.join` for file path joining.'
|
2248
|
-
Enabled: true
|
2249
|
-
VersionAdded: '0.47'
|
2250
|
-
VersionChanged: '0.57'
|
2251
|
-
EnforcedStyle: arguments
|
2252
|
-
SupportedStyles:
|
2253
|
-
- slashes
|
2254
|
-
- arguments
|
2255
|
-
|
2256
|
-
Rails/FindBy:
|
2257
|
-
Description: 'Prefer find_by over where.first.'
|
2258
|
-
StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find_by'
|
2259
|
-
Enabled: true
|
2260
|
-
VersionAdded: '0.30'
|
2261
|
-
Include:
|
2262
|
-
- app/models/**/*.rb
|
2263
|
-
|
2264
|
-
Rails/FindEach:
|
2265
|
-
Description: 'Prefer all.find_each over all.find.'
|
2266
|
-
StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find-each'
|
2267
|
-
Enabled: true
|
2268
|
-
VersionAdded: '0.30'
|
2269
|
-
Include:
|
2270
|
-
- app/models/**/*.rb
|
2271
|
-
|
2272
|
-
Rails/HasAndBelongsToMany:
|
2273
|
-
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
|
2274
|
-
StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#has-many-through'
|
2275
|
-
Enabled: true
|
2276
|
-
VersionAdded: '0.12'
|
2277
|
-
Include:
|
2278
|
-
- app/models/**/*.rb
|
2279
|
-
|
2280
|
-
Rails/HasManyOrHasOneDependent:
|
2281
|
-
Description: 'Define the dependent option to the has_many and has_one associations.'
|
2282
|
-
StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#has_many-has_one-dependent-option'
|
2283
|
-
Enabled: true
|
2284
|
-
VersionAdded: '0.50'
|
2285
|
-
Include:
|
2286
|
-
- app/models/**/*.rb
|
2287
|
-
|
2288
|
-
Rails/HttpPositionalArguments:
|
2289
|
-
Description: 'Use keyword arguments instead of positional arguments in http method calls.'
|
2290
|
-
Enabled: true
|
2291
|
-
VersionAdded: '0.44'
|
2292
|
-
Include:
|
2293
|
-
- 'spec/**/*'
|
2294
|
-
- 'test/**/*'
|
2295
|
-
|
2296
|
-
Rails/HttpStatus:
|
2297
|
-
Description: 'Enforces use of symbolic or numeric value to define HTTP status.'
|
2298
|
-
Enabled: true
|
2299
|
-
VersionAdded: '0.54'
|
2300
|
-
EnforcedStyle: symbolic
|
2301
|
-
SupportedStyles:
|
2302
|
-
- numeric
|
2303
|
-
- symbolic
|
2304
|
-
|
2305
|
-
Rails/IgnoredSkipActionFilterOption:
|
2306
|
-
Description: 'Checks that `if` and `only` (or `except`) are not used together as options of `skip_*` action filter.'
|
2307
|
-
Reference: 'https://api.rubyonrails.org/classes/AbstractController/Callbacks/ClassMethods.html#method-i-_normalize_callback_options'
|
2308
|
-
Enabled: true
|
2309
|
-
VersionAdded: '0.63'
|
2310
|
-
Include:
|
2311
|
-
- app/controllers/**/*.rb
|
2312
|
-
|
2313
|
-
Rails/InverseOf:
|
2314
|
-
Description: 'Checks for associations where the inverse cannot be determined automatically.'
|
2315
|
-
Enabled: true
|
2316
|
-
VersionAdded: '0.52'
|
2317
|
-
Include:
|
2318
|
-
- app/models/**/*.rb
|
2319
|
-
|
2320
|
-
Rails/LexicallyScopedActionFilter:
|
2321
|
-
Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the controller."
|
2322
|
-
StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#lexically-scoped-action-filter'
|
2323
|
-
Enabled: true
|
2324
|
-
Safe: false
|
2325
|
-
VersionAdded: '0.52'
|
2326
|
-
Include:
|
2327
|
-
- app/controllers/**/*.rb
|
2328
|
-
|
2329
|
-
Rails/LinkToBlank:
|
2330
|
-
Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.'
|
2331
|
-
Reference:
|
2332
|
-
- https://mathiasbynens.github.io/rel-noopener/
|
2333
|
-
- https://html.spec.whatwg.org/multipage/links.html#link-type-noopener
|
2334
|
-
- https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer
|
2335
|
-
Enabled: true
|
2336
|
-
VersionAdded: '0.62'
|
2337
|
-
|
2338
|
-
Rails/NotNullColumn:
|
2339
|
-
Description: 'Do not add a NOT NULL column without a default value'
|
2340
|
-
Enabled: true
|
2341
|
-
VersionAdded: '0.43'
|
2342
|
-
Include:
|
2343
|
-
- db/migrate/*.rb
|
2344
|
-
|
2345
|
-
Rails/Output:
|
2346
|
-
Description: 'Checks for calls to puts, print, etc.'
|
2347
|
-
Enabled: true
|
2348
|
-
VersionAdded: '0.15'
|
2349
|
-
VersionChanged: '0.19'
|
2350
|
-
Include:
|
2351
|
-
- app/**/*.rb
|
2352
|
-
- config/**/*.rb
|
2353
|
-
- db/**/*.rb
|
2354
|
-
- lib/**/*.rb
|
2355
|
-
|
2356
|
-
Rails/OutputSafety:
|
2357
|
-
Description: 'The use of `html_safe` or `raw` may be a security risk.'
|
2358
|
-
Enabled: true
|
2359
|
-
VersionAdded: '0.41'
|
2360
|
-
|
2361
|
-
Rails/PluralizationGrammar:
|
2362
|
-
Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
|
2363
|
-
Enabled: true
|
2364
|
-
VersionAdded: '0.35'
|
2365
|
-
|
2366
|
-
Rails/Presence:
|
2367
|
-
Description: 'Checks code that can be written more easily using `Object#presence` defined by Active Support.'
|
2368
|
-
Enabled: true
|
2369
|
-
VersionAdded: '0.52'
|
2370
|
-
|
2371
|
-
Rails/Present:
|
2372
|
-
Description: 'Enforces use of `present?`.'
|
2373
|
-
Enabled: true
|
2374
|
-
VersionAdded: '0.48'
|
2375
|
-
VersionChanged: '0.67'
|
2376
|
-
# Convert usages of `!nil? && !empty?` to `present?`
|
2377
|
-
NotNilAndNotEmpty: true
|
2378
|
-
# Convert usages of `!blank?` to `present?`
|
2379
|
-
NotBlank: true
|
2380
|
-
# Convert usages of `unless blank?` to `if present?`
|
2381
|
-
UnlessBlank: true
|
2382
|
-
|
2383
|
-
Rails/ReadWriteAttribute:
|
2384
|
-
Description: >-
|
2385
|
-
Checks for read_attribute(:attr) and
|
2386
|
-
write_attribute(:attr, val).
|
2387
|
-
StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#read-attribute'
|
2388
|
-
Enabled: true
|
2389
|
-
VersionAdded: '0.20'
|
2390
|
-
VersionChanged: '0.29'
|
2391
|
-
Include:
|
2392
|
-
- app/models/**/*.rb
|
2393
|
-
|
2394
|
-
Rails/RedundantAllowNil:
|
2395
|
-
Description: >-
|
2396
|
-
Finds redundant use of `allow_nil` when `allow_blank` is set to
|
2397
|
-
certain values in model validations.
|
2398
|
-
Enabled: true
|
2399
|
-
VersionAdded: '0.67'
|
2400
|
-
Include:
|
2401
|
-
- app/models/**/*.rb
|
2402
|
-
|
2403
|
-
Rails/RedundantReceiverInWithOptions:
|
2404
|
-
Description: 'Checks for redundant receiver in `with_options`.'
|
2405
|
-
Enabled: true
|
2406
|
-
VersionAdded: '0.52'
|
2407
|
-
|
2408
|
-
Rails/ReflectionClassName:
|
2409
|
-
Description: 'Use a string for `class_name` option value in the definition of a reflection.'
|
2410
|
-
Enabled: true
|
2411
|
-
VersionAdded: '0.64'
|
2412
|
-
|
2413
|
-
Rails/RefuteMethods:
|
2414
|
-
Description: 'Use `assert_not` methods instead of `refute` methods.'
|
2415
|
-
Enabled: true
|
2416
|
-
VersionAdded: '0.56'
|
2417
|
-
Include:
|
2418
|
-
- '**/test/**/*'
|
2419
|
-
|
2420
|
-
Rails/RelativeDateConstant:
|
2421
|
-
Description: 'Do not assign relative date to constants.'
|
2422
|
-
Enabled: true
|
2423
|
-
VersionAdded: '0.48'
|
2424
|
-
VersionChanged: '0.59'
|
2425
|
-
AutoCorrect: false
|
2426
|
-
|
2427
|
-
Rails/RequestReferer:
|
2428
|
-
Description: 'Use consistent syntax for request.referer.'
|
2429
|
-
Enabled: true
|
2430
|
-
VersionAdded: '0.41'
|
2431
|
-
EnforcedStyle: referer
|
2432
|
-
SupportedStyles:
|
2433
|
-
- referer
|
2434
|
-
- referrer
|
2435
|
-
|
2436
|
-
Rails/ReversibleMigration:
|
2437
|
-
Description: 'Checks whether the change method of the migration file is reversible.'
|
2438
|
-
StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#reversible-migration'
|
2439
|
-
Reference: 'https://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
|
2440
|
-
Enabled: true
|
2441
|
-
VersionAdded: '0.47'
|
2442
|
-
Include:
|
2443
|
-
- db/migrate/*.rb
|
2444
|
-
|
2445
|
-
Rails/SafeNavigation:
|
2446
|
-
Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
|
2447
|
-
Enabled: true
|
2448
|
-
VersionAdded: '0.43'
|
2449
|
-
# This will convert usages of `try` to use safe navigation as well as `try!`.
|
2450
|
-
# `try` and `try!` work slightly differently. `try!` and safe navigation will
|
2451
|
-
# both raise a `NoMethodError` if the receiver of the method call does not
|
2452
|
-
# implement the intended method. `try` will not raise an exception for this.
|
2453
|
-
ConvertTry: false
|
2454
|
-
|
2455
|
-
Rails/SaveBang:
|
2456
|
-
Description: 'Identifies possible cases where Active Record save! or related should be used.'
|
2457
|
-
StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#save-bang'
|
2458
|
-
Enabled: false
|
2459
|
-
VersionAdded: '0.42'
|
2460
|
-
VersionChanged: '0.59'
|
2461
|
-
AllowImplicitReturn: true
|
2462
|
-
AllowedReceivers: []
|
2463
|
-
|
2464
|
-
Rails/ScopeArgs:
|
2465
|
-
Description: 'Checks the arguments of ActiveRecord scopes.'
|
2466
|
-
Enabled: true
|
2467
|
-
VersionAdded: '0.19'
|
2468
|
-
Include:
|
2469
|
-
- app/models/**/*.rb
|
2470
|
-
|
2471
|
-
Rails/SkipsModelValidations:
|
2472
|
-
Description: >-
|
2473
|
-
Use methods that skips model validations with caution.
|
2474
|
-
See reference for more information.
|
2475
|
-
Reference: 'https://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
|
2476
|
-
Enabled: true
|
2477
|
-
VersionAdded: '0.47'
|
2478
|
-
VersionChanged: '0.60'
|
2479
|
-
Blacklist:
|
2480
|
-
- decrement!
|
2481
|
-
- decrement_counter
|
2482
|
-
- increment!
|
2483
|
-
- increment_counter
|
2484
|
-
- toggle!
|
2485
|
-
- touch
|
2486
|
-
- update_all
|
2487
|
-
- update_attribute
|
2488
|
-
- update_column
|
2489
|
-
- update_columns
|
2490
|
-
- update_counters
|
2491
|
-
Whitelist: []
|
2492
|
-
|
2493
|
-
Rails/TimeZone:
|
2494
|
-
Description: 'Checks the correct usage of time zone aware methods.'
|
2495
|
-
StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#time'
|
2496
|
-
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
|
2497
|
-
Enabled: true
|
2498
|
-
Safe: false
|
2499
|
-
VersionAdded: '0.30'
|
2500
|
-
VersionChanged: '0.68'
|
2501
|
-
# The value `strict` means that `Time` should be used with `zone`.
|
2502
|
-
# The value `flexible` allows usage of `in_time_zone` instead of `zone`.
|
2503
|
-
EnforcedStyle: flexible
|
2504
|
-
SupportedStyles:
|
2505
|
-
- strict
|
2506
|
-
- flexible
|
2507
|
-
|
2508
|
-
Rails/UniqBeforePluck:
|
2509
|
-
Description: 'Prefer the use of uniq or distinct before pluck.'
|
2510
|
-
Enabled: true
|
2511
|
-
VersionAdded: '0.40'
|
2512
|
-
VersionChanged: '0.47'
|
2513
|
-
EnforcedStyle: conservative
|
2514
|
-
SupportedStyles:
|
2515
|
-
- conservative
|
2516
|
-
- aggressive
|
2517
|
-
AutoCorrect: false
|
2518
|
-
|
2519
|
-
Rails/UnknownEnv:
|
2520
|
-
Description: 'Use correct environment name.'
|
2521
|
-
Enabled: true
|
2522
|
-
VersionAdded: '0.51'
|
2523
|
-
Environments:
|
2524
|
-
- development
|
2525
|
-
- test
|
2526
|
-
- production
|
2527
|
-
|
2528
|
-
Rails/Validation:
|
2529
|
-
Description: 'Use validates :attribute, hash of validations.'
|
2530
|
-
Enabled: true
|
2531
|
-
VersionAdded: '0.9'
|
2532
|
-
VersionChanged: '0.41'
|
2533
|
-
Include:
|
2534
|
-
- app/models/**/*.rb
|
2535
|
-
|
2536
2080
|
#################### Security ##############################
|
2537
2081
|
|
2538
2082
|
Security/Eval:
|
@@ -2589,7 +2133,7 @@ Style/AccessModifierDeclarations:
|
|
2589
2133
|
|
2590
2134
|
Style/Alias:
|
2591
2135
|
Description: 'Use alias instead of alias_method.'
|
2592
|
-
StyleGuide: '#alias-method'
|
2136
|
+
StyleGuide: '#alias-method-lexically'
|
2593
2137
|
Enabled: true
|
2594
2138
|
VersionAdded: '0.9'
|
2595
2139
|
VersionChanged: '0.36'
|
@@ -3095,7 +2639,7 @@ Style/EvalWithLocation:
|
|
3095
2639
|
VersionAdded: '0.52'
|
3096
2640
|
|
3097
2641
|
Style/EvenOdd:
|
3098
|
-
Description: 'Favor the use of Integer#even
|
2642
|
+
Description: 'Favor the use of `Integer#even?` && `Integer#odd?`.'
|
3099
2643
|
StyleGuide: '#predicate-methods'
|
3100
2644
|
Enabled: true
|
3101
2645
|
VersionAdded: '0.12'
|
@@ -3106,6 +2650,19 @@ Style/ExpandPathArguments:
|
|
3106
2650
|
Enabled: true
|
3107
2651
|
VersionAdded: '0.53'
|
3108
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
|
+
|
3109
2666
|
Style/For:
|
3110
2667
|
Description: 'Checks use of for or each in multiline loops.'
|
3111
2668
|
StyleGuide: '#no-for-loops'
|
@@ -3171,7 +2728,7 @@ Style/GlobalVars:
|
|
3171
2728
|
AllowedVariables: []
|
3172
2729
|
|
3173
2730
|
Style/GuardClause:
|
3174
|
-
Description: 'Check for conditionals that can be replaced with guard clauses'
|
2731
|
+
Description: 'Check for conditionals that can be replaced with guard clauses.'
|
3175
2732
|
StyleGuide: '#no-nested-conditionals'
|
3176
2733
|
Enabled: true
|
3177
2734
|
VersionAdded: '0.20'
|
@@ -3214,6 +2771,7 @@ Style/IdenticalConditionalBranches:
|
|
3214
2771
|
Style/IfInsideElse:
|
3215
2772
|
Description: 'Finds if nodes inside else, which can be converted to elsif.'
|
3216
2773
|
Enabled: true
|
2774
|
+
AllowIfModifier: false
|
3217
2775
|
VersionAdded: '0.36'
|
3218
2776
|
|
3219
2777
|
Style/IfUnlessModifier:
|
@@ -3379,7 +2937,7 @@ Style/MethodMissingSuper:
|
|
3379
2937
|
Style/MinMax:
|
3380
2938
|
Description: >-
|
3381
2939
|
Use `Enumerable#minmax` instead of `Enumerable#min`
|
3382
|
-
and `Enumerable#max` in conjunction.
|
2940
|
+
and `Enumerable#max` in conjunction.
|
3383
2941
|
Enabled: true
|
3384
2942
|
VersionAdded: '0.50'
|
3385
2943
|
|
@@ -3389,7 +2947,7 @@ Style/MissingElse:
|
|
3389
2947
|
If enabled, it is recommended that
|
3390
2948
|
Style/UnlessElse and Style/EmptyElse be enabled.
|
3391
2949
|
This will conflict with Style/EmptyElse if
|
3392
|
-
Style/EmptyElse is configured to style "both"
|
2950
|
+
Style/EmptyElse is configured to style "both".
|
3393
2951
|
Enabled: false
|
3394
2952
|
VersionAdded: '0.30'
|
3395
2953
|
VersionChanged: '0.38'
|
@@ -3701,7 +3259,7 @@ Style/OptionHash:
|
|
3701
3259
|
Style/OptionalArguments:
|
3702
3260
|
Description: >-
|
3703
3261
|
Checks for optional arguments that do not appear at the end
|
3704
|
-
of the argument list
|
3262
|
+
of the argument list.
|
3705
3263
|
StyleGuide: '#optional-arguments'
|
3706
3264
|
Enabled: true
|
3707
3265
|
VersionAdded: '0.33'
|
@@ -3733,7 +3291,7 @@ Style/ParenthesesAroundCondition:
|
|
3733
3291
|
AllowInMultilineConditions: false
|
3734
3292
|
|
3735
3293
|
Style/PercentLiteralDelimiters:
|
3736
|
-
Description: 'Use `%`-literal delimiters consistently'
|
3294
|
+
Description: 'Use `%`-literal delimiters consistently.'
|
3737
3295
|
StyleGuide: '#percent-literal-braces'
|
3738
3296
|
Enabled: true
|
3739
3297
|
VersionAdded: '0.19'
|
@@ -4265,7 +3823,7 @@ Style/UnneededSort:
|
|
4265
3823
|
Style/UnpackFirst:
|
4266
3824
|
Description: >-
|
4267
3825
|
Checks for accessing the first element of `String#unpack`
|
4268
|
-
instead of using `unpack1
|
3826
|
+
instead of using `unpack1`.
|
4269
3827
|
Enabled: true
|
4270
3828
|
VersionAdded: '0.54'
|
4271
3829
|
|
@@ -4316,7 +3874,7 @@ Style/WordArray:
|
|
4316
3874
|
# whose element count is greater than or equal to `MinSize`.
|
4317
3875
|
MinSize: 2
|
4318
3876
|
# The regular expression `WordRegex` decides what is considered a word.
|
4319
|
-
WordRegex: !ruby/regexp '/\A
|
3877
|
+
WordRegex: !ruby/regexp '/\A(?:\p{Word}|\p{Word}-\p{Word}|\n|\t)+\z/'
|
4320
3878
|
|
4321
3879
|
Style/YodaCondition:
|
4322
3880
|
Description: 'Forbid or enforce yoda conditions.'
|