silvercop 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 852ef35bae8abe1459190817d9841ea648fbb37f
4
- data.tar.gz: 89d2b86d9485c6f4e451accc1dfabed9810df5ce
3
+ metadata.gz: 0df095af4326d53c149685deae59285a707dfe7f
4
+ data.tar.gz: 83d53bacfe1abd88970e04a10a119e8209c48cf9
5
5
  SHA512:
6
- metadata.gz: 06427cca55fe38d6be48c588358c80b147b075c38cb6d4689eb83a91d3c9588a8d08dd26606e96215213bd6a6532b1506faf0d5c9218ab4ef8b7dff499622907
7
- data.tar.gz: '097c3136d48c5d226074aa9ecbcab6fe6b587aa204e555fdd2bd5e1176155c5e4b4402cb881636a84d7d9ed4d2c524e0438596d553eadc9a600da7b584c6bdfd'
6
+ metadata.gz: 56f78d3c2f8459fb920cfc584ad93a759971ac9ecd7e3e46121f769f26c43e0d5d869ac4df1887f7ee5cb854755fd2d818c8f1c991bfb53c852cbb60edda2d2d
7
+ data.tar.gz: 464c4b8494d78c0bb506e1d9f4bd6e7c7e4014379a18df1be4cba7c61ee257b9ff6b99e3b26a0d528cd9f3ff471c7f74bcaea865c80dfd341af7a79be9dfaae2
data/.rubocop.yml CHANGED
@@ -1,25 +1,10 @@
1
- inherit_from: config/default.yml
1
+ inherit_from: config/rubocop.yml
2
+
3
+ AllCops:
4
+ NewCops: enable
2
5
 
3
6
  require:
4
7
  - rubocop-performance
5
8
  - rubocop-rails
9
+ - rubocop-rake
6
10
  - rubocop-thread_safety
7
-
8
- Style/Documentation:
9
- Enabled: false
10
-
11
- Layout/MultilineMethodCallIndentation:
12
- EnforcedStyle: indented
13
-
14
- Layout/HashAlignment:
15
- EnforcedColonStyle: key
16
- EnforcedLastArgumentHashStyle: ignore_implicit
17
-
18
- Layout/ParameterAlignment:
19
- EnforcedStyle: with_fixed_indentation
20
-
21
- Layout/FirstArrayElementIndentation:
22
- EnforcedStyle: consistent
23
-
24
- Layout/FirstHashElementIndentation:
25
- EnforcedStyle: consistent
data/README.md CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
  After merging your changes to master, create a tag in the github repo. This will trigger a CircleCi build
21
21
  which will push the gem to RubyGems.
22
22
 
23
- **Note**: Make sure you update the `Silvercop::VERSION`, otherwise the build will fail saying the package already
23
+ **Note**: Make sure you update the gemspec `spec.version`, otherwise the build will fail saying the package already
24
24
  exists.
25
25
 
26
26
  ## Usage
@@ -36,6 +36,28 @@ inherit_gem:
36
36
  It is recommended to use this gem as `bundle exec rubocop -D`, which will output the violated
37
37
  cop for that line of code
38
38
 
39
+ ## Intent of Linting Configuration
40
+
41
+ Rubocop supports the generation of a todo file that helps add linting to a legacy project
42
+ without needing to address all the linting violations up front. However, this does split
43
+ the linting configuration across multiple files.
44
+
45
+ For consistency within Ruby projects, the following conventions should be followed:
46
+
47
+ #### .rubocop.yml
48
+ Inherits from silvercop's .rubocop.yml file and contains project level settings. Adding configuration to this file indicates the project is overriding silvercop's or rubocop's default configuration. These settings can change over time.
49
+
50
+ #### .rubocop_todo.yml
51
+ Contains explicit exclusions so that Rubocop can lint the project without addressing all violations within the project. Any cops or files that exist in this file are expected to be resolved and come into alignment with rules established within `.rubocop.yml`. Code modifications can temporarily allow for style alignment to be addressed as follow-up, depending on the scope of effort. Newly written code should follow styling and conventions, using this file as a last resort.
52
+
53
+ #### rubocop:disable, rubocop:enable
54
+ Used inline within code to locally disable and re-enable specific cops. This conveys the same intent as configuration within `.rubocop.yml` because generation and maintenance of `.rubocop_todo.yml` will not take into account locally disabled cops. If the intent of the styling changing is intended and permanent, the configuration must exist in `.rubocop.yml` and not use `rubocop:disable` locally.
55
+
56
+ #### rubocop:todo, rubocop:enable
57
+ Used inline within code to locally disable and re-enable specific cops. `rubocop:todo` is aliased to `rubocop:disable` but conveys the intent that addressing the styling or convention issue will be addressed as follow-up. Prefer using `rubocop_todo.yml` over this method.
58
+
59
+ ## Creating TODO List
60
+
39
61
  If many offenses are detected, it is recommended to generate a TODO list that can be handled over
40
62
  time without needing to fix all of the existing offenses. This can be done by generating and
41
63
  including the following config:
@@ -45,6 +67,22 @@ including the following config:
45
67
  Then add `inherit_from: .rubocop_todo.yml` to your `.rubocop.yml` file. Adding `--exclude-limit 10000` can help prevent
46
68
  the generated config from disabling cops entirely with `Enabled: false`.
47
69
 
70
+ Many of the `Metric/*` cops will analyze the code to find the worst offender and make that the new threshold. It is
71
+ recommended to set a sane limit and manually exclude violations beyond that sane threshold. For example, generating the
72
+ todo file in one repo attempts to set the `Metrics/LineLength` at a `Max` of 295 because that's the longest method in
73
+ the code base, which means the cop will no longer trigger any violations unless methods exceed 295 lines. Instead, set
74
+ the `Max` to something which creates a balance between a reasonable length and number of violations. As those violations
75
+ get addressed, the threshold can be tightened toward the organization/project standard or to the default. In this
76
+ example, the `Max` was set to 20 with an eventual goal of 10.
77
+
78
+ An example of doing this and easily capturing the violations is to set the `Max` to 20 in the todo file, then run:
79
+ `bundle exec rubocop -D --only Metrics/MethodLength --format files`
80
+
81
+ which will output a list of files that can then be pasted as the `Exclude` list in the todo file.
82
+
83
+ Putting these defaults in `.rubocop.yml` can help to remember the current threshold and indicate the target goal, but
84
+ that `Max` will not be taken into account when generating the todo file.
85
+
48
86
  Example usage of configuration inside Ruby project:
49
87
 
50
88
  ```ruby
@@ -0,0 +1,18 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Layout/MultilineMethodCallIndentation:
5
+ EnforcedStyle: indented
6
+
7
+ Layout/HashAlignment:
8
+ EnforcedColonStyle: key
9
+ EnforcedLastArgumentHashStyle: ignore_implicit
10
+
11
+ Layout/ParameterAlignment:
12
+ EnforcedStyle: with_fixed_indentation
13
+
14
+ Layout/FirstArrayElementIndentation:
15
+ EnforcedStyle: consistent
16
+
17
+ Layout/FirstHashElementIndentation:
18
+ EnforcedStyle: consistent
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: silvercop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Silvercar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-03 00:00:00.000000000 Z
11
+ date: 2021-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,56 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.78.0
19
+ version: 1.18.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.78.0
26
+ version: 1.18.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubocop-performance
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 1.5.1
33
+ version: 1.11.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 1.5.1
40
+ version: 1.11.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rubocop-rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 2.4.0
47
+ version: 2.11.3
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 2.4.0
54
+ version: 2.11.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.6.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.6.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rubocop-thread_safety
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - '='
60
74
  - !ruby/object:Gem::Version
61
- version: 0.3.4
75
+ version: 0.4.1
62
76
  type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - '='
67
81
  - !ruby/object:Gem::Version
68
- version: 0.3.4
82
+ version: 0.4.1
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -103,7 +117,7 @@ extra_rdoc_files: []
103
117
  files:
104
118
  - ".rubocop.yml"
105
119
  - README.md
106
- - config/default.yml
120
+ - config/rubocop.yml
107
121
  - lib/silvercop.rb
108
122
  homepage: https://github.com/silvercar/silvercop
109
123
  licenses:
data/config/default.yml DELETED
@@ -1,3963 +0,0 @@
1
- # Common configuration.
2
-
3
- AllCops:
4
- RubyInterpreters:
5
- - ruby
6
- - macruby
7
- - rake
8
- - jruby
9
- - rbx
10
- # Include common Ruby source files.
11
- Include:
12
- - '**/*.rb'
13
- - '**/*.arb'
14
- - '**/*.axlsx'
15
- - '**/*.builder'
16
- - '**/*.fcgi'
17
- - '**/*.gemfile'
18
- - '**/*.gemspec'
19
- - '**/*.god'
20
- - '**/*.jb'
21
- - '**/*.jbuilder'
22
- - '**/*.mspec'
23
- - '**/*.opal'
24
- - '**/*.pluginspec'
25
- - '**/*.podspec'
26
- - '**/*.rabl'
27
- - '**/*.rake'
28
- - '**/*.rbuild'
29
- - '**/*.rbw'
30
- - '**/*.rbx'
31
- - '**/*.ru'
32
- - '**/*.ruby'
33
- - '**/*.spec'
34
- - '**/*.thor'
35
- - '**/*.watchr'
36
- - '**/.irbrc'
37
- - '**/.pryrc'
38
- - '**/buildfile'
39
- - '**/Appraisals'
40
- - '**/Berksfile'
41
- - '**/Brewfile'
42
- - '**/Buildfile'
43
- - '**/Capfile'
44
- - '**/Cheffile'
45
- - '**/Dangerfile'
46
- - '**/Deliverfile'
47
- - '**/Fastfile'
48
- - '**/*Fastfile'
49
- - '**/Gemfile'
50
- - '**/Guardfile'
51
- - '**/Jarfile'
52
- - '**/Mavenfile'
53
- - '**/Podfile'
54
- - '**/Puppetfile'
55
- - '**/Rakefile'
56
- - '**/Snapfile'
57
- - '**/Thorfile'
58
- - '**/Vagabondfile'
59
- - '**/Vagrantfile'
60
- Exclude:
61
- - 'node_modules/**/*'
62
- - 'tmp/**/*'
63
- - 'vendor/**/*'
64
- - '.git/**/*'
65
- # Default formatter will be used if no `-f/--format` option is given.
66
- DefaultFormatter: progress
67
- # Cop names are displayed in offense messages by default. Change behavior
68
- # by overriding DisplayCopNames, or by giving the `--no-display-cop-names`
69
- # option.
70
- DisplayCopNames: true
71
- # Style guide URLs are not displayed in offense messages by default. Change
72
- # behavior by overriding `DisplayStyleGuide`, or by giving the
73
- # `-S/--display-style-guide` option.
74
- DisplayStyleGuide: false
75
- # When specifying style guide URLs, any paths and/or fragments will be
76
- # evaluated relative to the base URL.
77
- StyleGuideBaseURL: https://rubystyle.guide
78
- # Extra details are not displayed in offense messages by default. Change
79
- # behavior by overriding ExtraDetails, or by giving the
80
- # `-E/--extra-details` option.
81
- ExtraDetails: false
82
- # Additional cops that do not reference a style guide rule may be enabled by
83
- # default. Change behavior by overriding `StyleGuideCopsOnly`, or by giving
84
- # the `--only-guide-cops` option.
85
- StyleGuideCopsOnly: false
86
- # All cops except the ones configured `Enabled: false` in this file are enabled by default.
87
- # Change this behavior by overriding either `DisabledByDefault` or `EnabledByDefault`.
88
- # When `DisabledByDefault` is `true`, all cops in the default configuration
89
- # are disabled, and only cops in user configuration are enabled. This makes
90
- # cops opt-in instead of opt-out. Note that when `DisabledByDefault` is `true`,
91
- # cops in user configuration will be enabled even if they don't set the
92
- # Enabled parameter.
93
- # When `EnabledByDefault` is `true`, all cops, even those configured `Enabled: false`
94
- # in this file are enabled by default. Cops can still be disabled in user configuration.
95
- # Note that it is invalid to set both EnabledByDefault and DisabledByDefault
96
- # to true in the same configuration.
97
- EnabledByDefault: false
98
- DisabledByDefault: false
99
- # Enables the result cache if `true`. Can be overridden by the `--cache` command
100
- # line option.
101
- UseCache: true
102
- # Threshold for how many files can be stored in the result cache before some
103
- # of the files are automatically removed.
104
- MaxFilesInCache: 20000
105
- # The cache will be stored in "rubocop_cache" under this directory. If
106
- # CacheRootDirectory is ~ (nil), which it is by default, the root will be
107
- # taken from the environment variable `$XDG_CACHE_HOME` if it is set, or if
108
- # `$XDG_CACHE_HOME` is not set, it will be `$HOME/.cache/`.
109
- CacheRootDirectory: ~
110
- # It is possible for a malicious user to know the location of RuboCop's cache
111
- # directory by looking at CacheRootDirectory, and create a symlink in its
112
- # place that could cause RuboCop to overwrite unintended files, or read
113
- # malicious input. If you are certain that your cache location is secure from
114
- # this kind of attack, and wish to use a symlinked cache location, set this
115
- # value to "true".
116
- AllowSymlinksInCacheRootDirectory: false
117
- # What MRI version of the Ruby interpreter is the inspected code intended to
118
- # run on? (If there is more than one, set this to the lowest version.)
119
- # If a value is specified for TargetRubyVersion then it is used. Acceptable
120
- # values are specificed as a float (i.e. 2.5); the teeny version of Ruby
121
- # should not be included. If the project specifies a Ruby version in the
122
- # .ruby-version file, Gemfile or gems.rb file, RuboCop will try to determine
123
- # the desired version of Ruby by inspecting the .ruby-version file first,
124
- # followed by the Gemfile.lock or gems.locked file. (Although the Ruby version
125
- # is specified in the Gemfile or gems.rb file, RuboCop reads the final value
126
- # from the lock file.) If the Ruby version is still unresolved, RuboCop will
127
- # use the oldest officially supported Ruby version (currently Ruby 2.3).
128
- TargetRubyVersion: ~
129
-
130
- #################### Bundler ###############################
131
-
132
- Bundler/DuplicatedGem:
133
- Description: 'Checks for duplicate gem entries in Gemfile.'
134
- Enabled: true
135
- VersionAdded: '0.46'
136
- Include:
137
- - '**/*.gemfile'
138
- - '**/Gemfile'
139
- - '**/gems.rb'
140
-
141
- Bundler/GemComment:
142
- Description: 'Add a comment describing each gem.'
143
- Enabled: false
144
- VersionAdded: '0.59'
145
- VersionChanged: '0.77'
146
- Include:
147
- - '**/*.gemfile'
148
- - '**/Gemfile'
149
- - '**/gems.rb'
150
- IgnoredGems: []
151
-
152
- Bundler/InsecureProtocolSource:
153
- Description: >-
154
- The source `:gemcutter`, `:rubygems` and `:rubyforge` are deprecated
155
- because HTTP requests are insecure. Please change your source to
156
- 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
157
- Enabled: true
158
- VersionAdded: '0.50'
159
- Include:
160
- - '**/*.gemfile'
161
- - '**/Gemfile'
162
- - '**/gems.rb'
163
-
164
- Bundler/OrderedGems:
165
- Description: >-
166
- Gems within groups in the Gemfile should be alphabetically sorted.
167
- Enabled: true
168
- VersionAdded: '0.46'
169
- VersionChanged: '0.47'
170
- TreatCommentsAsGroupSeparators: true
171
- Include:
172
- - '**/*.gemfile'
173
- - '**/Gemfile'
174
- - '**/gems.rb'
175
-
176
- #################### Gemspec ###############################
177
-
178
- Gemspec/DuplicatedAssignment:
179
- Description: 'An attribute assignment method calls should be listed only once in a gemspec.'
180
- Enabled: true
181
- VersionAdded: '0.52'
182
- Include:
183
- - '**/*.gemspec'
184
-
185
- Gemspec/OrderedDependencies:
186
- Description: >-
187
- Dependencies in the gemspec should be alphabetically sorted.
188
- Enabled: true
189
- VersionAdded: '0.51'
190
- TreatCommentsAsGroupSeparators: true
191
- Include:
192
- - '**/*.gemspec'
193
-
194
- Gemspec/RequiredRubyVersion:
195
- Description: 'Checks that `required_ruby_version` of gemspec and `TargetRubyVersion` of .rubocop.yml are equal.'
196
- Enabled: true
197
- VersionAdded: '0.52'
198
- Include:
199
- - '**/*.gemspec'
200
-
201
- Gemspec/RubyVersionGlobalsUsage:
202
- Description: Checks usage of RUBY_VERSION in gemspec.
203
- StyleGuide: '#no-ruby-version-in-the-gemspec'
204
- Enabled: true
205
- VersionAdded: '0.72'
206
- Include:
207
- - '**/*.gemspec'
208
-
209
- #################### Layout ###########################
210
-
211
- Layout/AccessModifierIndentation:
212
- Description: Check indentation of private/protected visibility modifiers.
213
- StyleGuide: '#indent-public-private-protected'
214
- Enabled: true
215
- VersionAdded: '0.49'
216
- EnforcedStyle: indent
217
- SupportedStyles:
218
- - outdent
219
- - indent
220
- # By default, the indentation width from Layout/IndentationWidth is used
221
- # But it can be overridden by setting this parameter
222
- IndentationWidth: ~
223
-
224
- Layout/ArgumentAlignment:
225
- Description: >-
226
- Align the arguments of a method call if they span more
227
- than one line.
228
- StyleGuide: '#no-double-indent'
229
- Enabled: true
230
- VersionAdded: '0.68'
231
- VersionChanged: '0.77'
232
- # Alignment of arguments in multi-line method calls.
233
- #
234
- # The `with_first_argument` style aligns the following lines along the same
235
- # column as the first parameter.
236
- #
237
- # method_call(a,
238
- # b)
239
- #
240
- # The `with_fixed_indentation` style aligns the following lines with one
241
- # level of indentation relative to the start of the line with the method call.
242
- #
243
- # method_call(a,
244
- # b)
245
- EnforcedStyle: with_first_argument
246
- SupportedStyles:
247
- - with_first_argument
248
- - with_fixed_indentation
249
- # By default, the indentation width from Layout/IndentationWidth is used
250
- # But it can be overridden by setting this parameter
251
- IndentationWidth: ~
252
-
253
- Layout/ArrayAlignment:
254
- Description: >-
255
- Align the elements of an array literal if they span more than
256
- one line.
257
- StyleGuide: '#align-multiline-arrays'
258
- Enabled: true
259
- VersionAdded: '0.49'
260
- VersionChanged: '0.77'
261
-
262
- Layout/AssignmentIndentation:
263
- Description: >-
264
- Checks the indentation of the first line of the
265
- right-hand-side of a multi-line assignment.
266
- Enabled: true
267
- VersionAdded: '0.49'
268
- VersionChanged: '0.77'
269
- # By default, the indentation width from `Layout/IndentationWidth` is used
270
- # But it can be overridden by setting this parameter
271
- IndentationWidth: ~
272
-
273
- Layout/BlockAlignment:
274
- Description: 'Align block ends correctly.'
275
- Enabled: true
276
- VersionAdded: '0.53'
277
- # The value `start_of_block` means that the `end` should be aligned with line
278
- # where the `do` keyword appears.
279
- # The value `start_of_line` means it should be aligned with the whole
280
- # expression's starting line.
281
- # The value `either` means both are allowed.
282
- EnforcedStyleAlignWith: either
283
- SupportedStylesAlignWith:
284
- - either
285
- - start_of_block
286
- - start_of_line
287
-
288
- Layout/BlockEndNewline:
289
- Description: 'Put end statement of multiline block on its own line.'
290
- Enabled: true
291
- VersionAdded: '0.49'
292
-
293
- Layout/CaseIndentation:
294
- Description: 'Indentation of when in a case/when/[else/]end.'
295
- StyleGuide: '#indent-when-to-case'
296
- Enabled: true
297
- VersionAdded: '0.49'
298
- EnforcedStyle: case
299
- SupportedStyles:
300
- - case
301
- - end
302
- IndentOneStep: false
303
- # By default, the indentation width from `Layout/IndentationWidth` is used.
304
- # But it can be overridden by setting this parameter.
305
- # This only matters if `IndentOneStep` is `true`
306
- IndentationWidth: ~
307
-
308
- Layout/ClassStructure:
309
- Description: 'Enforces a configured order of definitions within a class body.'
310
- StyleGuide: '#consistent-classes'
311
- Enabled: false
312
- VersionAdded: '0.52'
313
- Categories:
314
- module_inclusion:
315
- - include
316
- - prepend
317
- - extend
318
- ExpectedOrder:
319
- - module_inclusion
320
- - constants
321
- - public_class_methods
322
- - initializer
323
- - public_methods
324
- - protected_methods
325
- - private_methods
326
-
327
- Layout/ClosingHeredocIndentation:
328
- Description: 'Checks the indentation of here document closings.'
329
- Enabled: true
330
- VersionAdded: '0.57'
331
-
332
- Layout/ClosingParenthesisIndentation:
333
- Description: 'Checks the indentation of hanging closing parentheses.'
334
- Enabled: true
335
- VersionAdded: '0.49'
336
-
337
- Layout/CommentIndentation:
338
- Description: 'Indentation of comments.'
339
- Enabled: true
340
- VersionAdded: '0.49'
341
-
342
- Layout/ConditionPosition:
343
- Description: >-
344
- Checks for condition placed in a confusing position relative to
345
- the keyword.
346
- StyleGuide: '#same-line-condition'
347
- Enabled: true
348
- VersionAdded: '0.53'
349
-
350
- Layout/DefEndAlignment:
351
- Description: 'Align ends corresponding to defs correctly.'
352
- Enabled: true
353
- VersionAdded: '0.53'
354
- # The value `def` means that `end` should be aligned with the def keyword.
355
- # The value `start_of_line` means that `end` should be aligned with method
356
- # calls like `private`, `public`, etc, if present in front of the `def`
357
- # keyword on the same line.
358
- EnforcedStyleAlignWith: start_of_line
359
- SupportedStylesAlignWith:
360
- - start_of_line
361
- - def
362
- AutoCorrect: false
363
- Severity: warning
364
-
365
- Layout/DotPosition:
366
- Description: 'Checks the position of the dot in multi-line method calls.'
367
- StyleGuide: '#consistent-multi-line-chains'
368
- Enabled: true
369
- VersionAdded: '0.49'
370
- EnforcedStyle: leading
371
- SupportedStyles:
372
- - leading
373
- - trailing
374
-
375
- Layout/ElseAlignment:
376
- Description: 'Align elses and elsifs correctly.'
377
- Enabled: true
378
- VersionAdded: '0.49'
379
-
380
- Layout/EmptyComment:
381
- Description: 'Checks empty comment.'
382
- Enabled: true
383
- VersionAdded: '0.53'
384
- AllowBorderComment: true
385
- AllowMarginComment: true
386
-
387
- Layout/EmptyLineAfterGuardClause:
388
- Description: 'Add empty line after guard clause.'
389
- Enabled: true
390
- VersionAdded: '0.56'
391
- VersionChanged: '0.59'
392
-
393
- Layout/EmptyLineAfterMagicComment:
394
- Description: 'Add an empty line after magic comments to separate them from code.'
395
- StyleGuide: '#separate-magic-comments-from-code'
396
- Enabled: true
397
- VersionAdded: '0.49'
398
-
399
- Layout/EmptyLineBetweenDefs:
400
- Description: 'Use empty lines between defs.'
401
- StyleGuide: '#empty-lines-between-methods'
402
- Enabled: true
403
- VersionAdded: '0.49'
404
- # If `true`, this parameter means that single line method definitions don't
405
- # need an empty line between them.
406
- AllowAdjacentOneLineDefs: false
407
- # Can be array to specify minimum and maximum number of empty lines, e.g. [1, 2]
408
- NumberOfEmptyLines: 1
409
-
410
- Layout/EmptyLines:
411
- Description: "Don't use several empty lines in a row."
412
- StyleGuide: '#two-or-more-empty-lines'
413
- Enabled: true
414
- VersionAdded: '0.49'
415
-
416
- Layout/EmptyLinesAroundAccessModifier:
417
- Description: "Keep blank lines around access modifiers."
418
- StyleGuide: '#empty-lines-around-access-modifier'
419
- Enabled: true
420
- VersionAdded: '0.49'
421
- EnforcedStyle: around
422
- SupportedStyles:
423
- - around
424
- - only_before
425
- Reference:
426
- # A reference to `EnforcedStyle: only_before`.
427
- - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
428
-
429
- Layout/EmptyLinesAroundArguments:
430
- Description: "Keeps track of empty lines around method arguments."
431
- Enabled: true
432
- VersionAdded: '0.52'
433
-
434
- Layout/EmptyLinesAroundBeginBody:
435
- Description: "Keeps track of empty lines around begin-end bodies."
436
- StyleGuide: '#empty-lines-around-bodies'
437
- Enabled: true
438
- VersionAdded: '0.49'
439
-
440
- Layout/EmptyLinesAroundBlockBody:
441
- Description: "Keeps track of empty lines around block bodies."
442
- StyleGuide: '#empty-lines-around-bodies'
443
- Enabled: true
444
- VersionAdded: '0.49'
445
- EnforcedStyle: no_empty_lines
446
- SupportedStyles:
447
- - empty_lines
448
- - no_empty_lines
449
-
450
- Layout/EmptyLinesAroundClassBody:
451
- Description: "Keeps track of empty lines around class bodies."
452
- StyleGuide: '#empty-lines-around-bodies'
453
- Enabled: true
454
- VersionAdded: '0.49'
455
- VersionChanged: '0.53'
456
- EnforcedStyle: no_empty_lines
457
- SupportedStyles:
458
- - empty_lines
459
- - empty_lines_except_namespace
460
- - empty_lines_special
461
- - no_empty_lines
462
- - beginning_only
463
- - ending_only
464
-
465
- Layout/EmptyLinesAroundExceptionHandlingKeywords:
466
- Description: "Keeps track of empty lines around exception handling keywords."
467
- StyleGuide: '#empty-lines-around-bodies'
468
- Enabled: true
469
- VersionAdded: '0.49'
470
-
471
- Layout/EmptyLinesAroundMethodBody:
472
- Description: "Keeps track of empty lines around method bodies."
473
- StyleGuide: '#empty-lines-around-bodies'
474
- Enabled: true
475
- VersionAdded: '0.49'
476
-
477
- Layout/EmptyLinesAroundModuleBody:
478
- Description: "Keeps track of empty lines around module bodies."
479
- StyleGuide: '#empty-lines-around-bodies'
480
- Enabled: true
481
- VersionAdded: '0.49'
482
- EnforcedStyle: no_empty_lines
483
- SupportedStyles:
484
- - empty_lines
485
- - empty_lines_except_namespace
486
- - empty_lines_special
487
- - no_empty_lines
488
-
489
- Layout/EndAlignment:
490
- Description: 'Align ends correctly.'
491
- Enabled: true
492
- VersionAdded: '0.53'
493
- # The value `keyword` means that `end` should be aligned with the matching
494
- # keyword (`if`, `while`, etc.).
495
- # The value `variable` means that in assignments, `end` should be aligned
496
- # with the start of the variable on the left hand side of `=`. In all other
497
- # situations, `end` should still be aligned with the keyword.
498
- # The value `start_of_line` means that `end` should be aligned with the start
499
- # of the line which the matching keyword appears on.
500
- EnforcedStyleAlignWith: keyword
501
- SupportedStylesAlignWith:
502
- - keyword
503
- - variable
504
- - start_of_line
505
- AutoCorrect: false
506
- Severity: warning
507
-
508
- Layout/EndOfLine:
509
- Description: 'Use Unix-style line endings.'
510
- StyleGuide: '#crlf'
511
- Enabled: true
512
- VersionAdded: '0.49'
513
- # The `native` style means that CR+LF (Carriage Return + Line Feed) is
514
- # enforced on Windows, and LF is enforced on other platforms. The other styles
515
- # mean LF and CR+LF, respectively.
516
- EnforcedStyle: native
517
- SupportedStyles:
518
- - native
519
- - lf
520
- - crlf
521
-
522
- Layout/ExtraSpacing:
523
- Description: 'Do not use unnecessary spacing.'
524
- Enabled: true
525
- VersionAdded: '0.49'
526
- # When true, allows most uses of extra spacing if the intent is to align
527
- # things with the previous or next line, not counting empty lines or comment
528
- # lines.
529
- AllowForAlignment: true
530
- # When true, allows things like 'obj.meth(arg) # comment',
531
- # rather than insisting on 'obj.meth(arg) # comment'.
532
- # If done for alignment, either this OR AllowForAlignment will allow it.
533
- AllowBeforeTrailingComments: false
534
- # When true, forces the alignment of `=` in assignments on consecutive lines.
535
- ForceEqualSignAlignment: false
536
-
537
- Layout/FirstArgumentIndentation:
538
- Description: 'Checks the indentation of the first argument in a method call.'
539
- Enabled: true
540
- VersionAdded: '0.68'
541
- VersionChanged: '0.77'
542
- EnforcedStyle: special_for_inner_method_call_in_parentheses
543
- SupportedStyles:
544
- # The first parameter should always be indented one step more than the
545
- # preceding line.
546
- - consistent
547
- # The first parameter should always be indented one level relative to the
548
- # parent that is receiving the parameter
549
- - consistent_relative_to_receiver
550
- # The first parameter should normally be indented one step more than the
551
- # preceding line, but if it's a parameter for a method call that is itself
552
- # a parameter in a method call, then the inner parameter should be indented
553
- # relative to the inner method.
554
- - special_for_inner_method_call
555
- # Same as `special_for_inner_method_call` except that the special rule only
556
- # applies if the outer method call encloses its arguments in parentheses.
557
- - special_for_inner_method_call_in_parentheses
558
- # By default, the indentation width from `Layout/IndentationWidth` is used
559
- # But it can be overridden by setting this parameter
560
- IndentationWidth: ~
561
-
562
- Layout/FirstArrayElementIndentation:
563
- Description: >-
564
- Checks the indentation of the first element in an array
565
- literal.
566
- Enabled: true
567
- VersionAdded: '0.68'
568
- VersionChanged: '0.77'
569
- # The value `special_inside_parentheses` means that array literals with
570
- # brackets that have their opening bracket on the same line as a surrounding
571
- # opening round parenthesis, shall have their first element indented relative
572
- # to the first position inside the parenthesis.
573
- #
574
- # The value `consistent` means that the indentation of the first element shall
575
- # always be relative to the first position of the line where the opening
576
- # bracket is.
577
- #
578
- # The value `align_brackets` means that the indentation of the first element
579
- # shall always be relative to the position of the opening bracket.
580
- EnforcedStyle: special_inside_parentheses
581
- SupportedStyles:
582
- - special_inside_parentheses
583
- - consistent
584
- - align_brackets
585
- # By default, the indentation width from `Layout/IndentationWidth` is used
586
- # But it can be overridden by setting this parameter
587
- IndentationWidth: ~
588
-
589
- Layout/FirstArrayElementLineBreak:
590
- Description: >-
591
- Checks for a line break before the first element in a
592
- multi-line array.
593
- Enabled: false
594
- VersionAdded: '0.49'
595
-
596
- Layout/FirstHashElementIndentation:
597
- Description: 'Checks the indentation of the first key in a hash literal.'
598
- Enabled: true
599
- VersionAdded: '0.68'
600
- VersionChanged: '0.77'
601
- # The value `special_inside_parentheses` means that hash literals with braces
602
- # that have their opening brace on the same line as a surrounding opening
603
- # round parenthesis, shall have their first key indented relative to the
604
- # first position inside the parenthesis.
605
- #
606
- # The value `consistent` means that the indentation of the first key shall
607
- # always be relative to the first position of the line where the opening
608
- # brace is.
609
- #
610
- # The value `align_braces` means that the indentation of the first key shall
611
- # always be relative to the position of the opening brace.
612
- EnforcedStyle: special_inside_parentheses
613
- SupportedStyles:
614
- - special_inside_parentheses
615
- - consistent
616
- - align_braces
617
- # By default, the indentation width from `Layout/IndentationWidth` is used
618
- # But it can be overridden by setting this parameter
619
- IndentationWidth: ~
620
-
621
- Layout/FirstHashElementLineBreak:
622
- Description: >-
623
- Checks for a line break before the first element in a
624
- multi-line hash.
625
- Enabled: false
626
- VersionAdded: '0.49'
627
-
628
- Layout/FirstMethodArgumentLineBreak:
629
- Description: >-
630
- Checks for a line break before the first argument in a
631
- multi-line method call.
632
- Enabled: false
633
- VersionAdded: '0.49'
634
-
635
- Layout/FirstMethodParameterLineBreak:
636
- Description: >-
637
- Checks for a line break before the first parameter in a
638
- multi-line method parameter definition.
639
- Enabled: false
640
- VersionAdded: '0.49'
641
-
642
- Layout/FirstParameterIndentation:
643
- Description: >-
644
- Checks the indentation of the first parameter in a
645
- method definition.
646
- Enabled: true
647
- VersionAdded: '0.49'
648
- VersionChanged: '0.77'
649
- EnforcedStyle: consistent
650
- SupportedStyles:
651
- - consistent
652
- - align_parentheses
653
- # By default, the indentation width from `Layout/IndentationWidth` is used
654
- # But it can be overridden by setting this parameter
655
- IndentationWidth: ~
656
-
657
- Layout/HashAlignment:
658
- Description: >-
659
- Align the elements of a hash literal if they span more than
660
- one line.
661
- Enabled: true
662
- AllowMultipleStyles: true
663
- VersionAdded: '0.49'
664
- VersionChanged: '0.77'
665
- # Alignment of entries using hash rocket as separator. Valid values are:
666
- #
667
- # key - left alignment of keys
668
- # 'a' => 2
669
- # 'bb' => 3
670
- # separator - alignment of hash rockets, keys are right aligned
671
- # 'a' => 2
672
- # 'bb' => 3
673
- # table - left alignment of keys, hash rockets, and values
674
- # 'a' => 2
675
- # 'bb' => 3
676
- EnforcedHashRocketStyle: key
677
- SupportedHashRocketStyles:
678
- - key
679
- - separator
680
- - table
681
- # Alignment of entries using colon as separator. Valid values are:
682
- #
683
- # key - left alignment of keys
684
- # a: 0
685
- # bb: 1
686
- # separator - alignment of colons, keys are right aligned
687
- # a: 0
688
- # bb: 1
689
- # table - left alignment of keys and values
690
- # a: 0
691
- # bb: 1
692
- EnforcedColonStyle: key
693
- SupportedColonStyles:
694
- - key
695
- - separator
696
- - table
697
- # Select whether hashes that are the last argument in a method call should be
698
- # inspected? Valid values are:
699
- #
700
- # always_inspect - Inspect both implicit and explicit hashes.
701
- # Registers an offense for:
702
- # function(a: 1,
703
- # b: 2)
704
- # Registers an offense for:
705
- # function({a: 1,
706
- # b: 2})
707
- # always_ignore - Ignore both implicit and explicit hashes.
708
- # Accepts:
709
- # function(a: 1,
710
- # b: 2)
711
- # Accepts:
712
- # function({a: 1,
713
- # b: 2})
714
- # ignore_implicit - Ignore only implicit hashes.
715
- # Accepts:
716
- # function(a: 1,
717
- # b: 2)
718
- # Registers an offense for:
719
- # function({a: 1,
720
- # b: 2})
721
- # ignore_explicit - Ignore only explicit hashes.
722
- # Accepts:
723
- # function({a: 1,
724
- # b: 2})
725
- # Registers an offense for:
726
- # function(a: 1,
727
- # b: 2)
728
- EnforcedLastArgumentHashStyle: always_inspect
729
- SupportedLastArgumentHashStyles:
730
- - always_inspect
731
- - always_ignore
732
- - ignore_implicit
733
- - ignore_explicit
734
-
735
- Layout/HeredocArgumentClosingParenthesis:
736
- Description: >-
737
- Checks for the placement of the closing parenthesis in a
738
- method call that passes a HEREDOC string as an argument.
739
- Enabled: false
740
- StyleGuide: '#heredoc-argument-closing-parentheses'
741
- VersionAdded: '0.68'
742
-
743
- Layout/HeredocIndentation:
744
- Description: 'This cop checks the indentation of the here document bodies.'
745
- StyleGuide: '#squiggly-heredocs'
746
- Enabled: true
747
- VersionAdded: '0.49'
748
- VersionChanged: '0.77'
749
- EnforcedStyle: squiggly
750
- SupportedStyles:
751
- - squiggly
752
- - active_support
753
- - powerpack
754
- - unindent
755
-
756
- Layout/IndentationConsistency:
757
- Description: 'Keep indentation straight.'
758
- StyleGuide: '#spaces-indentation'
759
- Enabled: true
760
- VersionAdded: '0.49'
761
- # The difference between `indented` and `normal` is that the `indented_internal_methods`
762
- # style prescribes that in classes and modules the `protected` and `private`
763
- # modifier keywords shall be indented the same as public methods and that
764
- # protected and private members shall be indented one step more than the
765
- # modifiers. Other than that, both styles mean that entities on the same
766
- # logical depth shall have the same indentation.
767
- EnforcedStyle: normal
768
- SupportedStyles:
769
- - normal
770
- - indented_internal_methods
771
- Reference:
772
- # A reference to `EnforcedStyle: indented_internal_methods`.
773
- - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
774
-
775
- Layout/IndentationWidth:
776
- Description: 'Use 2 spaces for indentation.'
777
- StyleGuide: '#spaces-indentation'
778
- Enabled: true
779
- VersionAdded: '0.49'
780
- # Number of spaces for each indentation level.
781
- Width: 2
782
- IgnoredPatterns: []
783
-
784
- Layout/InitialIndentation:
785
- Description: >-
786
- Checks the indentation of the first non-blank non-comment line in a file.
787
- Enabled: true
788
- VersionAdded: '0.49'
789
-
790
- Layout/LeadingCommentSpace:
791
- Description: 'Comments should start with a space.'
792
- StyleGuide: '#hash-space'
793
- Enabled: true
794
- VersionAdded: '0.49'
795
- VersionChanged: '0.73'
796
- AllowDoxygenCommentStyle: false
797
-
798
- Layout/LeadingEmptyLines:
799
- Description: Check for unnecessary blank lines at the beginning of a file.
800
- Enabled: true
801
- VersionAdded: '0.57'
802
- VersionChanged: '0.77'
803
-
804
- Layout/LineLength:
805
- Description: 'Limit lines to 80 characters.'
806
- StyleGuide: '#80-character-limits'
807
- Enabled: true
808
- VersionAdded: '0.25'
809
- VersionChanged: '0.78'
810
- AutoCorrect: false
811
- Max: 80
812
- # To make it possible to copy or click on URIs in the code, we allow lines
813
- # containing a URI to be longer than Max.
814
- AllowHeredoc: true
815
- AllowURI: true
816
- URISchemes:
817
- - http
818
- - https
819
- # The IgnoreCopDirectives option causes the LineLength rule to ignore cop
820
- # directives like '# rubocop: enable ...' when calculating a line's length.
821
- IgnoreCopDirectives: true
822
- # The IgnoredPatterns option is a list of !ruby/regexp and/or string
823
- # elements. Strings will be converted to Regexp objects. A line that matches
824
- # any regular expression listed in this option will be ignored by LineLength.
825
- IgnoredPatterns: []
826
-
827
- Layout/MultilineArrayBraceLayout:
828
- Description: >-
829
- Checks that the closing brace in an array literal is
830
- either on the same line as the last array element, or
831
- a new line.
832
- Enabled: true
833
- VersionAdded: '0.49'
834
- EnforcedStyle: symmetrical
835
- SupportedStyles:
836
- # symmetrical: closing brace is positioned in same way as opening brace
837
- # new_line: closing brace is always on a new line
838
- # same_line: closing brace is always on the same line as last element
839
- - symmetrical
840
- - new_line
841
- - same_line
842
-
843
- Layout/MultilineArrayLineBreaks:
844
- Description: >-
845
- Checks that each item in a multi-line array literal
846
- starts on a separate line.
847
- Enabled: false
848
- VersionAdded: '0.67'
849
-
850
- Layout/MultilineAssignmentLayout:
851
- Description: 'Check for a newline after the assignment operator in multi-line assignments.'
852
- StyleGuide: '#indent-conditional-assignment'
853
- Enabled: false
854
- VersionAdded: '0.49'
855
- # The types of assignments which are subject to this rule.
856
- SupportedTypes:
857
- - block
858
- - case
859
- - class
860
- - if
861
- - kwbegin
862
- - module
863
- EnforcedStyle: new_line
864
- SupportedStyles:
865
- # Ensures that the assignment operator and the rhs are on the same line for
866
- # the set of supported types.
867
- - same_line
868
- # Ensures that the assignment operator and the rhs are on separate lines
869
- # for the set of supported types.
870
- - new_line
871
-
872
- Layout/MultilineBlockLayout:
873
- Description: 'Ensures newlines after multiline block do statements.'
874
- Enabled: true
875
- VersionAdded: '0.49'
876
-
877
- Layout/MultilineHashBraceLayout:
878
- Description: >-
879
- Checks that the closing brace in a hash literal is
880
- either on the same line as the last hash element, or
881
- a new line.
882
- Enabled: true
883
- VersionAdded: '0.49'
884
- EnforcedStyle: symmetrical
885
- SupportedStyles:
886
- # symmetrical: closing brace is positioned in same way as opening brace
887
- # new_line: closing brace is always on a new line
888
- # same_line: closing brace is always on same line as last element
889
- - symmetrical
890
- - new_line
891
- - same_line
892
-
893
- Layout/MultilineHashKeyLineBreaks:
894
- Description: >-
895
- Checks that each item in a multi-line hash literal
896
- starts on a separate line.
897
- Enabled: false
898
- VersionAdded: '0.67'
899
-
900
- Layout/MultilineMethodArgumentLineBreaks:
901
- Description: >-
902
- Checks that each argument in a multi-line method call
903
- starts on a separate line.
904
- Enabled: false
905
- VersionAdded: '0.67'
906
-
907
- Layout/MultilineMethodCallBraceLayout:
908
- Description: >-
909
- Checks that the closing brace in a method call is
910
- either on the same line as the last method argument, or
911
- a new line.
912
- Enabled: true
913
- VersionAdded: '0.49'
914
- EnforcedStyle: symmetrical
915
- SupportedStyles:
916
- # symmetrical: closing brace is positioned in same way as opening brace
917
- # new_line: closing brace is always on a new line
918
- # same_line: closing brace is always on the same line as last argument
919
- - symmetrical
920
- - new_line
921
- - same_line
922
-
923
- Layout/MultilineMethodCallIndentation:
924
- Description: >-
925
- Checks indentation of method calls with the dot operator
926
- that span more than one line.
927
- Enabled: true
928
- VersionAdded: '0.49'
929
- EnforcedStyle: aligned
930
- SupportedStyles:
931
- - aligned
932
- - indented
933
- - indented_relative_to_receiver
934
- # By default, the indentation width from Layout/IndentationWidth is used
935
- # But it can be overridden by setting this parameter
936
- IndentationWidth: ~
937
-
938
- Layout/MultilineMethodDefinitionBraceLayout:
939
- Description: >-
940
- Checks that the closing brace in a method definition is
941
- either on the same line as the last method parameter, or
942
- a new line.
943
- Enabled: true
944
- VersionAdded: '0.49'
945
- EnforcedStyle: symmetrical
946
- SupportedStyles:
947
- # symmetrical: closing brace is positioned in same way as opening brace
948
- # new_line: closing brace is always on a new line
949
- # same_line: closing brace is always on the same line as last parameter
950
- - symmetrical
951
- - new_line
952
- - same_line
953
-
954
- Layout/MultilineOperationIndentation:
955
- Description: >-
956
- Checks indentation of binary operations that span more than
957
- one line.
958
- Enabled: true
959
- VersionAdded: '0.49'
960
- EnforcedStyle: aligned
961
- SupportedStyles:
962
- - aligned
963
- - indented
964
- # By default, the indentation width from `Layout/IndentationWidth` is used
965
- # But it can be overridden by setting this parameter
966
- IndentationWidth: ~
967
-
968
- Layout/ParameterAlignment:
969
- Description: >-
970
- Align the parameters of a method definition if they span more
971
- than one line.
972
- StyleGuide: '#no-double-indent'
973
- Enabled: true
974
- VersionAdded: '0.49'
975
- VersionChanged: '0.77'
976
- # Alignment of parameters in multi-line method calls.
977
- #
978
- # The `with_first_parameter` style aligns the following lines along the same
979
- # column as the first parameter.
980
- #
981
- # def method_foo(a,
982
- # b)
983
- #
984
- # The `with_fixed_indentation` style aligns the following lines with one
985
- # level of indentation relative to the start of the line with the method call.
986
- #
987
- # def method_foo(a,
988
- # b)
989
- EnforcedStyle: with_first_parameter
990
- SupportedStyles:
991
- - with_first_parameter
992
- - with_fixed_indentation
993
- # By default, the indentation width from Layout/IndentationWidth is used
994
- # But it can be overridden by setting this parameter
995
- IndentationWidth: ~
996
-
997
- Layout/RescueEnsureAlignment:
998
- Description: 'Align rescues and ensures correctly.'
999
- Enabled: true
1000
- VersionAdded: '0.49'
1001
-
1002
- Layout/SpaceAfterColon:
1003
- Description: 'Use spaces after colons.'
1004
- StyleGuide: '#spaces-operators'
1005
- Enabled: true
1006
- VersionAdded: '0.49'
1007
-
1008
- Layout/SpaceAfterComma:
1009
- Description: 'Use spaces after commas.'
1010
- StyleGuide: '#spaces-operators'
1011
- Enabled: true
1012
- VersionAdded: '0.49'
1013
-
1014
- Layout/SpaceAfterMethodName:
1015
- Description: >-
1016
- Do not put a space between a method name and the opening
1017
- parenthesis in a method definition.
1018
- StyleGuide: '#parens-no-spaces'
1019
- Enabled: true
1020
- VersionAdded: '0.49'
1021
-
1022
- Layout/SpaceAfterNot:
1023
- Description: Tracks redundant space after the ! operator.
1024
- StyleGuide: '#no-space-bang'
1025
- Enabled: true
1026
- VersionAdded: '0.49'
1027
-
1028
- Layout/SpaceAfterSemicolon:
1029
- Description: 'Use spaces after semicolons.'
1030
- StyleGuide: '#spaces-operators'
1031
- Enabled: true
1032
- VersionAdded: '0.49'
1033
-
1034
- Layout/SpaceAroundBlockParameters:
1035
- Description: 'Checks the spacing inside and after block parameters pipes.'
1036
- Enabled: true
1037
- VersionAdded: '0.49'
1038
- EnforcedStyleInsidePipes: no_space
1039
- SupportedStylesInsidePipes:
1040
- - space
1041
- - no_space
1042
-
1043
- Layout/SpaceAroundEqualsInParameterDefault:
1044
- Description: >-
1045
- Checks that the equals signs in parameter default assignments
1046
- have or don't have surrounding space depending on
1047
- configuration.
1048
- StyleGuide: '#spaces-around-equals'
1049
- Enabled: true
1050
- VersionAdded: '0.49'
1051
- EnforcedStyle: space
1052
- SupportedStyles:
1053
- - space
1054
- - no_space
1055
-
1056
- Layout/SpaceAroundKeyword:
1057
- Description: 'Use a space around keywords if appropriate.'
1058
- Enabled: true
1059
- VersionAdded: '0.49'
1060
-
1061
- Layout/SpaceAroundOperators:
1062
- Description: 'Use a single space around operators.'
1063
- StyleGuide: '#spaces-operators'
1064
- Enabled: true
1065
- VersionAdded: '0.49'
1066
- # When `true`, allows most uses of extra spacing if the intent is to align
1067
- # with an operator on the previous or next line, not counting empty lines
1068
- # or comment lines.
1069
- AllowForAlignment: true
1070
- EnforcedStyleForExponentOperator: no_space
1071
- SupportedStylesForExponentOperator:
1072
- - space
1073
- - no_space
1074
-
1075
- Layout/SpaceBeforeBlockBraces:
1076
- Description: >-
1077
- Checks that the left block brace has or doesn't have space
1078
- before it.
1079
- Enabled: true
1080
- VersionAdded: '0.49'
1081
- EnforcedStyle: space
1082
- SupportedStyles:
1083
- - space
1084
- - no_space
1085
- EnforcedStyleForEmptyBraces: space
1086
- SupportedStylesForEmptyBraces:
1087
- - space
1088
- - no_space
1089
- VersionChanged: '0.52.1'
1090
-
1091
- Layout/SpaceBeforeComma:
1092
- Description: 'No spaces before commas.'
1093
- Enabled: true
1094
- VersionAdded: '0.49'
1095
-
1096
- Layout/SpaceBeforeComment:
1097
- Description: >-
1098
- Checks for missing space between code and a comment on the
1099
- same line.
1100
- Enabled: true
1101
- VersionAdded: '0.49'
1102
-
1103
- Layout/SpaceBeforeFirstArg:
1104
- Description: >-
1105
- Checks that exactly one space is used between a method name
1106
- and the first argument for method calls without parentheses.
1107
- Enabled: true
1108
- VersionAdded: '0.49'
1109
- # When `true`, allows most uses of extra spacing if the intent is to align
1110
- # things with the previous or next line, not counting empty lines or comment
1111
- # lines.
1112
- AllowForAlignment: true
1113
-
1114
- Layout/SpaceBeforeSemicolon:
1115
- Description: 'No spaces before semicolons.'
1116
- Enabled: true
1117
- VersionAdded: '0.49'
1118
-
1119
- Layout/SpaceInLambdaLiteral:
1120
- Description: 'Checks for spaces in lambda literals.'
1121
- Enabled: true
1122
- VersionAdded: '0.49'
1123
- EnforcedStyle: require_no_space
1124
- SupportedStyles:
1125
- - require_no_space
1126
- - require_space
1127
-
1128
- Layout/SpaceInsideArrayLiteralBrackets:
1129
- Description: 'Checks the spacing inside array literal brackets.'
1130
- Enabled: true
1131
- VersionAdded: '0.52'
1132
- EnforcedStyle: no_space
1133
- SupportedStyles:
1134
- - space
1135
- - no_space
1136
- # 'compact' normally requires a space inside the brackets, with the exception
1137
- # that successive left brackets or right brackets are collapsed together
1138
- - compact
1139
- EnforcedStyleForEmptyBrackets: no_space
1140
- SupportedStylesForEmptyBrackets:
1141
- - space
1142
- - no_space
1143
-
1144
- Layout/SpaceInsideArrayPercentLiteral:
1145
- Description: 'No unnecessary additional spaces between elements in %i/%w literals.'
1146
- Enabled: true
1147
- VersionAdded: '0.49'
1148
-
1149
- Layout/SpaceInsideBlockBraces:
1150
- Description: >-
1151
- Checks that block braces have or don't have surrounding space.
1152
- For blocks taking parameters, checks that the left brace has
1153
- or doesn't have trailing space.
1154
- Enabled: true
1155
- VersionAdded: '0.49'
1156
- EnforcedStyle: space
1157
- SupportedStyles:
1158
- - space
1159
- - no_space
1160
- EnforcedStyleForEmptyBraces: no_space
1161
- SupportedStylesForEmptyBraces:
1162
- - space
1163
- - no_space
1164
- # Space between `{` and `|`. Overrides `EnforcedStyle` if there is a conflict.
1165
- SpaceBeforeBlockParameters: true
1166
-
1167
- Layout/SpaceInsideHashLiteralBraces:
1168
- Description: "Use spaces inside hash literal braces - or don't."
1169
- StyleGuide: '#spaces-operators'
1170
- Enabled: true
1171
- VersionAdded: '0.49'
1172
- EnforcedStyle: space
1173
- SupportedStyles:
1174
- - space
1175
- - no_space
1176
- # 'compact' normally requires a space inside hash braces, with the exception
1177
- # that successive left braces or right braces are collapsed together
1178
- - compact
1179
- EnforcedStyleForEmptyBraces: no_space
1180
- SupportedStylesForEmptyBraces:
1181
- - space
1182
- - no_space
1183
-
1184
-
1185
- Layout/SpaceInsideParens:
1186
- Description: 'No spaces after ( or before ).'
1187
- StyleGuide: '#spaces-braces'
1188
- Enabled: true
1189
- VersionAdded: '0.49'
1190
- VersionChanged: '0.55'
1191
- EnforcedStyle: no_space
1192
- SupportedStyles:
1193
- - space
1194
- - no_space
1195
-
1196
- Layout/SpaceInsidePercentLiteralDelimiters:
1197
- Description: 'No unnecessary spaces inside delimiters of %i/%w/%x literals.'
1198
- Enabled: true
1199
- VersionAdded: '0.49'
1200
-
1201
- Layout/SpaceInsideRangeLiteral:
1202
- Description: 'No spaces inside range literals.'
1203
- StyleGuide: '#no-space-inside-range-literals'
1204
- Enabled: true
1205
- VersionAdded: '0.49'
1206
-
1207
- Layout/SpaceInsideReferenceBrackets:
1208
- Description: 'Checks the spacing inside referential brackets.'
1209
- Enabled: true
1210
- VersionAdded: '0.52'
1211
- VersionChanged: '0.53'
1212
- EnforcedStyle: no_space
1213
- SupportedStyles:
1214
- - space
1215
- - no_space
1216
- EnforcedStyleForEmptyBrackets: no_space
1217
- SupportedStylesForEmptyBrackets:
1218
- - space
1219
- - no_space
1220
-
1221
- Layout/SpaceInsideStringInterpolation:
1222
- Description: 'Checks for padding/surrounding spaces inside string interpolation.'
1223
- StyleGuide: '#string-interpolation'
1224
- Enabled: true
1225
- VersionAdded: '0.49'
1226
- EnforcedStyle: no_space
1227
- SupportedStyles:
1228
- - space
1229
- - no_space
1230
-
1231
- Layout/Tab:
1232
- Description: 'No hard tabs.'
1233
- StyleGuide: '#spaces-indentation'
1234
- Enabled: true
1235
- VersionAdded: '0.49'
1236
- VersionChanged: '0.51'
1237
- # By default, the indentation width from Layout/IndentationWidth is used
1238
- # But it can be overridden by setting this parameter
1239
- # It is used during auto-correction to determine how many spaces should
1240
- # replace each tab.
1241
- IndentationWidth: ~
1242
-
1243
- Layout/TrailingEmptyLines:
1244
- Description: 'Checks trailing blank lines and final newline.'
1245
- StyleGuide: '#newline-eof'
1246
- Enabled: true
1247
- VersionAdded: '0.49'
1248
- VersionChanged: '0.77'
1249
- EnforcedStyle: final_newline
1250
- SupportedStyles:
1251
- - final_newline
1252
- - final_blank_line
1253
-
1254
- Layout/TrailingWhitespace:
1255
- Description: 'Avoid trailing whitespace.'
1256
- StyleGuide: '#no-trailing-whitespace'
1257
- Enabled: true
1258
- VersionAdded: '0.49'
1259
- VersionChanged: '0.55'
1260
- AllowInHeredoc: false
1261
-
1262
- #################### Lint ##################################
1263
- ### Warnings
1264
-
1265
- Lint/AmbiguousBlockAssociation:
1266
- Description: >-
1267
- Checks for ambiguous block association with method when param passed without
1268
- parentheses.
1269
- StyleGuide: '#syntax'
1270
- Enabled: true
1271
- VersionAdded: '0.48'
1272
-
1273
- Lint/AmbiguousOperator:
1274
- Description: >-
1275
- Checks for ambiguous operators in the first argument of a
1276
- method invocation without parentheses.
1277
- StyleGuide: '#method-invocation-parens'
1278
- Enabled: true
1279
- VersionAdded: '0.17'
1280
-
1281
- Lint/AmbiguousRegexpLiteral:
1282
- Description: >-
1283
- Checks for ambiguous regexp literals in the first argument of
1284
- a method invocation without parentheses.
1285
- Enabled: true
1286
- VersionAdded: '0.17'
1287
-
1288
- Lint/AssignmentInCondition:
1289
- Description: "Don't use assignment in conditions."
1290
- StyleGuide: '#safe-assignment-in-condition'
1291
- Enabled: true
1292
- VersionAdded: '0.9'
1293
- AllowSafeAssignment: true
1294
-
1295
- Lint/BigDecimalNew:
1296
- Description: '`BigDecimal.new()` is deprecated. Use `BigDecimal()` instead.'
1297
- Enabled: true
1298
- VersionAdded: '0.53'
1299
-
1300
- Lint/BooleanSymbol:
1301
- Description: 'Check for `:true` and `:false` symbols.'
1302
- Enabled: true
1303
- VersionAdded: '0.50'
1304
-
1305
- Lint/CircularArgumentReference:
1306
- Description: "Default values in optional keyword arguments and optional ordinal arguments should not refer back to the name of the argument."
1307
- Enabled: true
1308
- VersionAdded: '0.33'
1309
-
1310
- Lint/Debugger:
1311
- Description: 'Check for debugger calls.'
1312
- Enabled: true
1313
- VersionAdded: '0.14'
1314
- VersionChanged: '0.49'
1315
-
1316
- Lint/DeprecatedClassMethods:
1317
- Description: 'Check for deprecated class method calls.'
1318
- Enabled: true
1319
- VersionAdded: '0.19'
1320
-
1321
- Lint/DisjunctiveAssignmentInConstructor:
1322
- Description: 'In constructor, plain assignment is preferred over disjunctive.'
1323
- Enabled: true
1324
- Safe: false
1325
- VersionAdded: '0.62'
1326
-
1327
- Lint/DuplicateCaseCondition:
1328
- Description: 'Do not repeat values in case conditionals.'
1329
- Enabled: true
1330
- VersionAdded: '0.45'
1331
-
1332
- Lint/DuplicateHashKey:
1333
- Description: 'Check for duplicate keys in hash literals.'
1334
- Enabled: true
1335
- VersionAdded: '0.34'
1336
- VersionChanged: '0.77'
1337
-
1338
- Lint/DuplicateMethods:
1339
- Description: 'Check for duplicate method definitions.'
1340
- Enabled: true
1341
- VersionAdded: '0.29'
1342
-
1343
- Lint/EachWithObjectArgument:
1344
- Description: 'Check for immutable argument given to each_with_object.'
1345
- Enabled: true
1346
- VersionAdded: '0.31'
1347
-
1348
- Lint/ElseLayout:
1349
- Description: 'Check for odd code arrangement in an else block.'
1350
- Enabled: true
1351
- VersionAdded: '0.17'
1352
-
1353
- Lint/EmptyEnsure:
1354
- Description: 'Checks for empty ensure block.'
1355
- Enabled: true
1356
- VersionAdded: '0.10'
1357
- VersionChanged: '0.48'
1358
- AutoCorrect: false
1359
-
1360
- Lint/EmptyExpression:
1361
- Description: 'Checks for empty expressions.'
1362
- Enabled: true
1363
- VersionAdded: '0.45'
1364
-
1365
- Lint/EmptyInterpolation:
1366
- Description: 'Checks for empty string interpolation.'
1367
- Enabled: true
1368
- VersionAdded: '0.20'
1369
- VersionChanged: '0.45'
1370
-
1371
- Lint/EmptyWhen:
1372
- Description: 'Checks for `when` branches with empty bodies.'
1373
- Enabled: true
1374
- VersionAdded: '0.45'
1375
-
1376
- Lint/EndInMethod:
1377
- Description: 'END blocks should not be placed inside method definitions.'
1378
- Enabled: true
1379
- VersionAdded: '0.9'
1380
-
1381
- Lint/EnsureReturn:
1382
- Description: 'Do not use return in an ensure block.'
1383
- StyleGuide: '#no-return-ensure'
1384
- Enabled: true
1385
- VersionAdded: '0.9'
1386
-
1387
- Lint/ErbNewArguments:
1388
- Description: 'Use `:trim_mode` and `:eoutvar` keyword arguments to `ERB.new`.'
1389
- Enabled: true
1390
- VersionAdded: '0.56'
1391
-
1392
- Lint/FlipFlop:
1393
- Description: 'Checks for flip-flops.'
1394
- StyleGuide: '#no-flip-flops'
1395
- Enabled: true
1396
- VersionAdded: '0.16'
1397
-
1398
- Lint/FloatOutOfRange:
1399
- Description: >-
1400
- Catches floating-point literals too large or small for Ruby to
1401
- represent.
1402
- Enabled: true
1403
- VersionAdded: '0.36'
1404
-
1405
- Lint/FormatParameterMismatch:
1406
- Description: 'The number of parameters to format/sprint must match the fields.'
1407
- Enabled: true
1408
- VersionAdded: '0.33'
1409
-
1410
- Lint/HeredocMethodCallPosition:
1411
- Description: >-
1412
- Checks for the ordering of a method call where
1413
- the receiver of the call is a HEREDOC.
1414
- Enabled: false
1415
- StyleGuide: '#heredoc-method-calls'
1416
- VersionAdded: '0.68'
1417
-
1418
- Lint/ImplicitStringConcatenation:
1419
- Description: >-
1420
- Checks for adjacent string literals on the same line, which
1421
- could better be represented as a single string literal.
1422
- Enabled: true
1423
- VersionAdded: '0.36'
1424
-
1425
- Lint/IneffectiveAccessModifier:
1426
- Description: >-
1427
- Checks for attempts to use `private` or `protected` to set
1428
- the visibility of a class method, which does not work.
1429
- Enabled: true
1430
- VersionAdded: '0.36'
1431
-
1432
- Lint/InheritException:
1433
- Description: 'Avoid inheriting from the `Exception` class.'
1434
- Enabled: true
1435
- VersionAdded: '0.41'
1436
- # The default base class in favour of `Exception`.
1437
- EnforcedStyle: runtime_error
1438
- SupportedStyles:
1439
- - runtime_error
1440
- - standard_error
1441
-
1442
- Lint/InterpolationCheck:
1443
- Description: 'Raise warning for interpolation in single q strs.'
1444
- Enabled: true
1445
- VersionAdded: '0.50'
1446
-
1447
- Lint/LiteralAsCondition:
1448
- Description: 'Checks of literals used in conditions.'
1449
- Enabled: true
1450
- VersionAdded: '0.51'
1451
-
1452
- Lint/LiteralInInterpolation:
1453
- Description: 'Checks for literals used in interpolation.'
1454
- Enabled: true
1455
- VersionAdded: '0.19'
1456
- VersionChanged: '0.32'
1457
-
1458
- Lint/Loop:
1459
- Description: >-
1460
- Use Kernel#loop with break rather than begin/end/until or
1461
- begin/end/while for post-loop tests.
1462
- StyleGuide: '#loop-with-break'
1463
- Enabled: true
1464
- VersionAdded: '0.9'
1465
-
1466
- Lint/MissingCopEnableDirective:
1467
- Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.'
1468
- Enabled: true
1469
- VersionAdded: '0.52'
1470
- # Maximum number of consecutive lines the cop can be disabled for.
1471
- # 0 allows only single-line disables
1472
- # 1 would mean the maximum allowed is the following:
1473
- # # rubocop:disable SomeCop
1474
- # a = 1
1475
- # # rubocop:enable SomeCop
1476
- # .inf for any size
1477
- MaximumRangeSize: .inf
1478
-
1479
- Lint/MultipleComparison:
1480
- Description: "Use `&&` operator to compare multiple values."
1481
- Enabled: true
1482
- VersionAdded: '0.47'
1483
- VersionChanged: '0.77'
1484
-
1485
- Lint/NestedMethodDefinition:
1486
- Description: 'Do not use nested method definitions.'
1487
- StyleGuide: '#no-nested-methods'
1488
- Enabled: true
1489
- VersionAdded: '0.32'
1490
-
1491
- Lint/NestedPercentLiteral:
1492
- Description: 'Checks for nested percent literals.'
1493
- Enabled: true
1494
- VersionAdded: '0.52'
1495
-
1496
- Lint/NextWithoutAccumulator:
1497
- Description: >-
1498
- Do not omit the accumulator when calling `next`
1499
- in a `reduce`/`inject` block.
1500
- Enabled: true
1501
- VersionAdded: '0.36'
1502
-
1503
- Lint/NonDeterministicRequireOrder:
1504
- Description: 'Always sort arrays returned by Dir.glob when requiring files.'
1505
- Enabled: true
1506
- VersionAdded: '0.78'
1507
- Safe: false
1508
-
1509
- Lint/NonLocalExitFromIterator:
1510
- Description: 'Do not use return in iterator to cause non-local exit.'
1511
- Enabled: true
1512
- VersionAdded: '0.30'
1513
-
1514
- Lint/NumberConversion:
1515
- Description: 'Checks unsafe usage of number conversion methods.'
1516
- Enabled: false
1517
- VersionAdded: '0.53'
1518
- VersionChanged: '0.70'
1519
- SafeAutoCorrect: false
1520
-
1521
- Lint/OrderedMagicComments:
1522
- Description: 'Checks the proper ordering of magic comments and whether a magic comment is not placed before a shebang.'
1523
- Enabled: true
1524
- VersionAdded: '0.53'
1525
-
1526
- Lint/ParenthesesAsGroupedExpression:
1527
- Description: >-
1528
- Checks for method calls with a space before the opening
1529
- parenthesis.
1530
- StyleGuide: '#parens-no-spaces'
1531
- Enabled: true
1532
- VersionAdded: '0.12'
1533
-
1534
- Lint/PercentStringArray:
1535
- Description: >-
1536
- Checks for unwanted commas and quotes in %w/%W literals.
1537
- Enabled: true
1538
- Safe: false
1539
- VersionAdded: '0.41'
1540
-
1541
- Lint/PercentSymbolArray:
1542
- Description: >-
1543
- Checks for unwanted commas and colons in %i/%I literals.
1544
- Enabled: true
1545
- VersionAdded: '0.41'
1546
-
1547
- Lint/RandOne:
1548
- Description: >-
1549
- Checks for `rand(1)` calls. Such calls always return `0`
1550
- and most likely a mistake.
1551
- Enabled: true
1552
- VersionAdded: '0.36'
1553
-
1554
- Lint/RedundantCopDisableDirective:
1555
- Description: >-
1556
- Checks for rubocop:disable comments that can be removed.
1557
- Note: this cop is not disabled when disabling all cops.
1558
- It must be explicitly disabled.
1559
- Enabled: true
1560
- VersionAdded: '0.76'
1561
-
1562
- Lint/RedundantCopEnableDirective:
1563
- Description: Checks for rubocop:enable comments that can be removed.
1564
- Enabled: true
1565
- VersionAdded: '0.76'
1566
-
1567
- Lint/RedundantRequireStatement:
1568
- Description: 'Checks for unnecessary `require` statement.'
1569
- Enabled: true
1570
- VersionAdded: '0.76'
1571
-
1572
- Lint/RedundantSplatExpansion:
1573
- Description: 'Checks for splat unnecessarily being called on literals.'
1574
- Enabled: true
1575
- VersionChanged: '0.76'
1576
-
1577
- Lint/RedundantStringCoercion:
1578
- Description: 'Checks for Object#to_s usage in string interpolation.'
1579
- StyleGuide: '#no-to-s'
1580
- Enabled: true
1581
- VersionAdded: '0.19'
1582
- VersionChanged: '0.77'
1583
-
1584
- Lint/RedundantWithIndex:
1585
- Description: 'Checks for redundant `with_index`.'
1586
- Enabled: true
1587
- VersionAdded: '0.50'
1588
-
1589
- Lint/RedundantWithObject:
1590
- Description: 'Checks for redundant `with_object`.'
1591
- Enabled: true
1592
- VersionAdded: '0.51'
1593
-
1594
- Lint/RegexpAsCondition:
1595
- Description: >-
1596
- Do not use regexp literal as a condition.
1597
- The regexp literal matches `$_` implicitly.
1598
- Enabled: true
1599
- VersionAdded: '0.51'
1600
-
1601
- Lint/RequireParentheses:
1602
- Description: >-
1603
- Use parentheses in the method call to avoid confusion
1604
- about precedence.
1605
- Enabled: true
1606
- VersionAdded: '0.18'
1607
-
1608
- Lint/RescueException:
1609
- Description: 'Avoid rescuing the Exception class.'
1610
- StyleGuide: '#no-blind-rescues'
1611
- Enabled: true
1612
- VersionAdded: '0.9'
1613
- VersionChanged: '0.27.1'
1614
-
1615
- Lint/RescueType:
1616
- Description: 'Avoid rescuing from non constants that could result in a `TypeError`.'
1617
- Enabled: true
1618
- VersionAdded: '0.49'
1619
-
1620
- Lint/ReturnInVoidContext:
1621
- Description: 'Checks for return in void context.'
1622
- Enabled: true
1623
- VersionAdded: '0.50'
1624
-
1625
- Lint/SafeNavigationChain:
1626
- Description: 'Do not chain ordinary method call after safe navigation operator.'
1627
- Enabled: true
1628
- VersionAdded: '0.47'
1629
- VersionChanged: '0.77'
1630
- AllowedMethods:
1631
- - present?
1632
- - blank?
1633
- - presence
1634
- - try
1635
- - try!
1636
-
1637
- Lint/SafeNavigationConsistency:
1638
- Description: >-
1639
- Check to make sure that if safe navigation is used for a method
1640
- call in an `&&` or `||` condition that safe navigation is used
1641
- for all method calls on that same object.
1642
- Enabled: true
1643
- VersionAdded: '0.55'
1644
- VersionChanged: '0.77'
1645
- AllowedMethods:
1646
- - present?
1647
- - blank?
1648
- - presence
1649
- - try
1650
- - try!
1651
-
1652
- Lint/SafeNavigationWithEmpty:
1653
- Description: 'Avoid `foo&.empty?` in conditionals.'
1654
- Enabled: true
1655
- VersionAdded: '0.62'
1656
-
1657
- Lint/ScriptPermission:
1658
- Description: 'Grant script file execute permission.'
1659
- Enabled: true
1660
- VersionAdded: '0.49'
1661
- VersionChanged: '0.50'
1662
-
1663
- Lint/SendWithMixinArgument:
1664
- Description: 'Checks for `send` method when using mixin.'
1665
- Enabled: true
1666
- VersionAdded: '0.75'
1667
-
1668
- Lint/ShadowedArgument:
1669
- Description: 'Avoid reassigning arguments before they were used.'
1670
- Enabled: true
1671
- VersionAdded: '0.52'
1672
- IgnoreImplicitReferences: false
1673
-
1674
-
1675
- Lint/ShadowedException:
1676
- Description: >-
1677
- Avoid rescuing a higher level exception
1678
- before a lower level exception.
1679
- Enabled: true
1680
- VersionAdded: '0.41'
1681
-
1682
- Lint/ShadowingOuterLocalVariable:
1683
- Description: >-
1684
- Do not use the same name as outer local variable
1685
- for block arguments or block local variables.
1686
- Enabled: true
1687
- VersionAdded: '0.9'
1688
-
1689
- Lint/SuppressedException:
1690
- Description: "Don't suppress exceptions."
1691
- StyleGuide: '#dont-hide-exceptions'
1692
- Enabled: true
1693
- AllowComments: false
1694
- VersionAdded: '0.9'
1695
- VersionChanged: '0.77'
1696
-
1697
- Lint/Syntax:
1698
- Description: 'Checks syntax error.'
1699
- Enabled: true
1700
- VersionAdded: '0.9'
1701
-
1702
-
1703
- Lint/ToJSON:
1704
- Description: 'Ensure #to_json includes an optional argument.'
1705
- Enabled: true
1706
-
1707
- Lint/UnderscorePrefixedVariableName:
1708
- Description: 'Do not use prefix `_` for a variable that is used.'
1709
- Enabled: true
1710
- VersionAdded: '0.21'
1711
- AllowKeywordBlockArguments: false
1712
-
1713
- Lint/UnifiedInteger:
1714
- Description: 'Use Integer instead of Fixnum or Bignum.'
1715
- Enabled: true
1716
- VersionAdded: '0.43'
1717
-
1718
- Lint/UnreachableCode:
1719
- Description: 'Unreachable code.'
1720
- Enabled: true
1721
- VersionAdded: '0.9'
1722
-
1723
- Lint/UnusedBlockArgument:
1724
- Description: 'Checks for unused block arguments.'
1725
- StyleGuide: '#underscore-unused-vars'
1726
- Enabled: true
1727
- VersionAdded: '0.21'
1728
- VersionChanged: '0.22'
1729
- IgnoreEmptyBlocks: true
1730
- AllowUnusedKeywordArguments: false
1731
-
1732
- Lint/UnusedMethodArgument:
1733
- Description: 'Checks for unused method arguments.'
1734
- StyleGuide: '#underscore-unused-vars'
1735
- Enabled: true
1736
- VersionAdded: '0.21'
1737
- VersionChanged: '0.35'
1738
- AllowUnusedKeywordArguments: false
1739
- IgnoreEmptyMethods: true
1740
-
1741
- Lint/UriEscapeUnescape:
1742
- Description: >-
1743
- `URI.escape` method is obsolete and should not be used. Instead, use
1744
- `CGI.escape`, `URI.encode_www_form` or `URI.encode_www_form_component`
1745
- depending on your specific use case.
1746
- Also `URI.unescape` method is obsolete and should not be used. Instead, use
1747
- `CGI.unescape`, `URI.decode_www_form` or `URI.decode_www_form_component`
1748
- depending on your specific use case.
1749
- Enabled: true
1750
- VersionAdded: '0.50'
1751
-
1752
- Lint/UriRegexp:
1753
- Description: 'Use `URI::DEFAULT_PARSER.make_regexp` instead of `URI.regexp`.'
1754
- Enabled: true
1755
- VersionAdded: '0.50'
1756
-
1757
- Lint/UselessAccessModifier:
1758
- Description: 'Checks for useless access modifiers.'
1759
- Enabled: true
1760
- VersionAdded: '0.20'
1761
- VersionChanged: '0.47'
1762
- ContextCreatingMethods: []
1763
- MethodCreatingMethods: []
1764
-
1765
- Lint/UselessAssignment:
1766
- Description: 'Checks for useless assignment to a local variable.'
1767
- StyleGuide: '#underscore-unused-vars'
1768
- Enabled: true
1769
- VersionAdded: '0.11'
1770
-
1771
- Lint/UselessComparison:
1772
- Description: 'Checks for comparison of something with itself.'
1773
- Enabled: true
1774
- VersionAdded: '0.11'
1775
-
1776
- Lint/UselessElseWithoutRescue:
1777
- Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
1778
- Enabled: true
1779
- VersionAdded: '0.17'
1780
-
1781
- Lint/UselessSetterCall:
1782
- Description: 'Checks for useless setter call to a local variable.'
1783
- Enabled: true
1784
- VersionAdded: '0.13'
1785
-
1786
- Lint/Void:
1787
- Description: 'Possible use of operator/literal/variable in void context.'
1788
- Enabled: true
1789
- VersionAdded: '0.9'
1790
- CheckForMethodsWithNoSideEffects: false
1791
-
1792
- #################### Metrics ###############################
1793
-
1794
- Metrics/AbcSize:
1795
- Description: >-
1796
- A calculated magnitude based on number of assignments,
1797
- branches, and conditions.
1798
- Reference:
1799
- - http://c2.com/cgi/wiki?AbcMetric
1800
- - https://en.wikipedia.org/wiki/ABC_Software_Metric
1801
- Enabled: true
1802
- VersionAdded: '0.27'
1803
- VersionChanged: '0.66'
1804
- # The ABC size is a calculated magnitude, so this number can be an Integer or
1805
- # a Float.
1806
- Max: 15
1807
-
1808
- Metrics/BlockLength:
1809
- Description: 'Avoid long blocks with many lines.'
1810
- Enabled: true
1811
- VersionAdded: '0.44'
1812
- VersionChanged: '0.66'
1813
- CountComments: false # count full line comments?
1814
- Max: 25
1815
- ExcludedMethods:
1816
- # By default, exclude the `#refine` method, as it tends to have larger
1817
- # associated blocks.
1818
- - refine
1819
- Exclude:
1820
- - '**/*.gemspec'
1821
-
1822
- Metrics/BlockNesting:
1823
- Description: 'Avoid excessive block nesting.'
1824
- StyleGuide: '#three-is-the-number-thou-shalt-count'
1825
- Enabled: true
1826
- VersionAdded: '0.25'
1827
- VersionChanged: '0.47'
1828
- CountBlocks: false
1829
- Max: 3
1830
-
1831
- Metrics/ClassLength:
1832
- Description: 'Avoid classes longer than 100 lines of code.'
1833
- Enabled: true
1834
- VersionAdded: '0.25'
1835
- CountComments: false # count full line comments?
1836
- Max: 100
1837
-
1838
- # Avoid complex methods.
1839
- Metrics/CyclomaticComplexity:
1840
- Description: >-
1841
- A complexity metric that is strongly correlated to the number
1842
- of test cases needed to validate a method.
1843
- Enabled: true
1844
- VersionAdded: '0.25'
1845
- Max: 6
1846
-
1847
- Metrics/MethodLength:
1848
- Description: 'Avoid methods longer than 10 lines of code.'
1849
- StyleGuide: '#short-methods'
1850
- Enabled: true
1851
- VersionAdded: '0.25'
1852
- VersionChanged: '0.59.2'
1853
- CountComments: false # count full line comments?
1854
- Max: 10
1855
- ExcludedMethods: []
1856
-
1857
- Metrics/ModuleLength:
1858
- Description: 'Avoid modules longer than 100 lines of code.'
1859
- Enabled: true
1860
- VersionAdded: '0.31'
1861
- CountComments: false # count full line comments?
1862
- Max: 100
1863
-
1864
- Metrics/ParameterLists:
1865
- Description: 'Avoid parameter lists longer than three or four parameters.'
1866
- StyleGuide: '#too-many-params'
1867
- Enabled: true
1868
- VersionAdded: '0.25'
1869
- Max: 5
1870
- CountKeywordArgs: true
1871
-
1872
- Metrics/PerceivedComplexity:
1873
- Description: >-
1874
- A complexity metric geared towards measuring complexity for a
1875
- human reader.
1876
- Enabled: true
1877
- VersionAdded: '0.25'
1878
- Max: 7
1879
-
1880
- ################## Migration #############################
1881
-
1882
- Migration/DepartmentName:
1883
- Description: >-
1884
- Check that cop names in rubocop:disable (etc) comments are
1885
- given with department name.
1886
- Enabled: false
1887
-
1888
- #################### Naming ##############################
1889
-
1890
- Naming/AccessorMethodName:
1891
- Description: Check the naming of accessor methods for get_/set_.
1892
- StyleGuide: '#accessor_mutator_method_names'
1893
- Enabled: true
1894
- VersionAdded: '0.50'
1895
-
1896
- Naming/AsciiIdentifiers:
1897
- Description: 'Use only ascii symbols in identifiers.'
1898
- StyleGuide: '#english-identifiers'
1899
- Enabled: true
1900
- VersionAdded: '0.50'
1901
-
1902
- Naming/BinaryOperatorParameterName:
1903
- Description: 'When defining binary operators, name the argument other.'
1904
- StyleGuide: '#other-arg'
1905
- Enabled: true
1906
- VersionAdded: '0.50'
1907
-
1908
- Naming/BlockParameterName:
1909
- Description: >-
1910
- Checks for block parameter names that contain capital letters,
1911
- end in numbers, or do not meet a minimal length.
1912
- Enabled: true
1913
- VersionAdded: '0.53'
1914
- VersionChanged: '0.77'
1915
- # Parameter names may be equal to or greater than this value
1916
- MinNameLength: 1
1917
- AllowNamesEndingInNumbers: true
1918
- # Allowed names that will not register an offense
1919
- AllowedNames: []
1920
- # Forbidden names that will register an offense
1921
- ForbiddenNames: []
1922
-
1923
- Naming/ClassAndModuleCamelCase:
1924
- Description: 'Use CamelCase for classes and modules.'
1925
- StyleGuide: '#camelcase-classes'
1926
- Enabled: true
1927
- VersionAdded: '0.50'
1928
-
1929
- Naming/ConstantName:
1930
- Description: 'Constants should use SCREAMING_SNAKE_CASE.'
1931
- StyleGuide: '#screaming-snake-case'
1932
- Enabled: true
1933
- VersionAdded: '0.50'
1934
-
1935
- Naming/FileName:
1936
- Description: 'Use snake_case for source file names.'
1937
- StyleGuide: '#snake-case-files'
1938
- Enabled: true
1939
- VersionAdded: '0.50'
1940
- # Camel case file names listed in `AllCops:Include` and all file names listed
1941
- # in `AllCops:Exclude` are excluded by default. Add extra excludes here.
1942
- Exclude: []
1943
- # When `true`, requires that each source file should define a class or module
1944
- # with a name which matches the file name (converted to ... case).
1945
- # It further expects it to be nested inside modules which match the names
1946
- # of subdirectories in its path.
1947
- ExpectMatchingDefinition: false
1948
- # If non-`nil`, expect all source file names to match the following regex.
1949
- # Only the file name itself is matched, not the entire file path.
1950
- # Use anchors as necessary if you want to match the entire name rather than
1951
- # just a part of it.
1952
- Regex: ~
1953
- # With `IgnoreExecutableScripts` set to `true`, this cop does not
1954
- # report offending filenames for executable scripts (i.e. source
1955
- # files with a shebang in the first line).
1956
- IgnoreExecutableScripts: true
1957
- AllowedAcronyms:
1958
- - CLI
1959
- - DSL
1960
- - ACL
1961
- - API
1962
- - ASCII
1963
- - CPU
1964
- - CSS
1965
- - DNS
1966
- - EOF
1967
- - GUID
1968
- - HTML
1969
- - HTTP
1970
- - HTTPS
1971
- - ID
1972
- - IP
1973
- - JSON
1974
- - LHS
1975
- - QPS
1976
- - RAM
1977
- - RHS
1978
- - RPC
1979
- - SLA
1980
- - SMTP
1981
- - SQL
1982
- - SSH
1983
- - TCP
1984
- - TLS
1985
- - TTL
1986
- - UDP
1987
- - UI
1988
- - UID
1989
- - UUID
1990
- - URI
1991
- - URL
1992
- - UTF8
1993
- - VM
1994
- - XML
1995
- - XMPP
1996
- - XSRF
1997
- - XSS
1998
-
1999
- Naming/HeredocDelimiterCase:
2000
- Description: 'Use configured case for heredoc delimiters.'
2001
- StyleGuide: '#heredoc-delimiters'
2002
- Enabled: true
2003
- VersionAdded: '0.50'
2004
- EnforcedStyle: uppercase
2005
- SupportedStyles:
2006
- - lowercase
2007
- - uppercase
2008
-
2009
- Naming/HeredocDelimiterNaming:
2010
- Description: 'Use descriptive heredoc delimiters.'
2011
- StyleGuide: '#heredoc-delimiters'
2012
- Enabled: true
2013
- VersionAdded: '0.50'
2014
- ForbiddenDelimiters:
2015
- - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/'
2016
-
2017
- Naming/MemoizedInstanceVariableName:
2018
- Description: >-
2019
- Memoized method name should match memo instance variable name.
2020
- Enabled: true
2021
- VersionAdded: '0.53'
2022
- VersionChanged: '0.58'
2023
- EnforcedStyleForLeadingUnderscores: disallowed
2024
- SupportedStylesForLeadingUnderscores:
2025
- - disallowed
2026
- - required
2027
- - optional
2028
-
2029
- Naming/MethodName:
2030
- Description: 'Use the configured style when naming methods.'
2031
- StyleGuide: '#snake-case-symbols-methods-vars'
2032
- Enabled: true
2033
- VersionAdded: '0.50'
2034
- EnforcedStyle: snake_case
2035
- SupportedStyles:
2036
- - snake_case
2037
- - camelCase
2038
- # Method names matching patterns are always allowed.
2039
- #
2040
- # IgnoredPatterns:
2041
- # - '\A\s*onSelectionBulkChange\s*'
2042
- # - '\A\s*onSelectionCleared\s*'
2043
- #
2044
- IgnoredPatterns: []
2045
-
2046
- Naming/MethodParameterName:
2047
- Description: >-
2048
- Checks for method parameter names that contain capital letters,
2049
- end in numbers, or do not meet a minimal length.
2050
- Enabled: true
2051
- VersionAdded: '0.53'
2052
- VersionChanged: '0.77'
2053
- # Parameter names may be equal to or greater than this value
2054
- MinNameLength: 3
2055
- AllowNamesEndingInNumbers: true
2056
- # Allowed names that will not register an offense
2057
- AllowedNames:
2058
- - io
2059
- - id
2060
- - to
2061
- - by
2062
- - 'on'
2063
- - in
2064
- - at
2065
- - ip
2066
- - db
2067
- - os
2068
- # Forbidden names that will register an offense
2069
- ForbiddenNames: []
2070
-
2071
- Naming/PredicateName:
2072
- Description: 'Check the names of predicate methods.'
2073
- StyleGuide: '#bool-methods-qmark'
2074
- Enabled: true
2075
- VersionAdded: '0.50'
2076
- VersionChanged: '0.77'
2077
- # Predicate name prefixes.
2078
- NamePrefix:
2079
- - is_
2080
- - has_
2081
- - have_
2082
- # Predicate name prefixes that should be removed.
2083
- ForbiddenPrefixes:
2084
- - is_
2085
- - has_
2086
- - have_
2087
- # Predicate names which, despite having a forbidden prefix, or no `?`,
2088
- # should still be accepted
2089
- AllowedMethods:
2090
- - is_a?
2091
- # Method definition macros for dynamically generated methods.
2092
- MethodDefinitionMacros:
2093
- - define_method
2094
- - define_singleton_method
2095
- # Exclude Rspec specs because there is a strong convention to write spec
2096
- # helpers in the form of `have_something` or `be_something`.
2097
- Exclude:
2098
- - 'spec/**/*'
2099
-
2100
- Naming/RescuedExceptionsVariableName:
2101
- Description: 'Use consistent rescued exceptions variables naming.'
2102
- Enabled: true
2103
- VersionAdded: '0.67'
2104
- VersionChanged: '0.68'
2105
- PreferredName: e
2106
-
2107
- Naming/VariableName:
2108
- Description: 'Use the configured style when naming variables.'
2109
- StyleGuide: '#snake-case-symbols-methods-vars'
2110
- Enabled: true
2111
- VersionAdded: '0.50'
2112
- EnforcedStyle: snake_case
2113
- SupportedStyles:
2114
- - snake_case
2115
- - camelCase
2116
-
2117
- Naming/VariableNumber:
2118
- Description: 'Use the configured style when numbering variables.'
2119
- Enabled: true
2120
- VersionAdded: '0.50'
2121
- EnforcedStyle: normalcase
2122
- SupportedStyles:
2123
- - snake_case
2124
- - normalcase
2125
- - non_integer
2126
-
2127
- #################### Security ##############################
2128
-
2129
- Security/Eval:
2130
- Description: 'The use of eval represents a serious security risk.'
2131
- Enabled: true
2132
- VersionAdded: '0.47'
2133
-
2134
- Security/JSONLoad:
2135
- Description: >-
2136
- Prefer usage of `JSON.parse` over `JSON.load` due to potential
2137
- security issues. See reference for more information.
2138
- Reference: 'https://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load'
2139
- Enabled: true
2140
- VersionAdded: '0.43'
2141
- VersionChanged: '0.44'
2142
- # Autocorrect here will change to a method that may cause crashes depending
2143
- # on the value of the argument.
2144
- AutoCorrect: false
2145
- SafeAutoCorrect: false
2146
-
2147
- Security/MarshalLoad:
2148
- Description: >-
2149
- Avoid using of `Marshal.load` or `Marshal.restore` due to potential
2150
- security issues. See reference for more information.
2151
- Reference: 'https://ruby-doc.org/core-2.3.3/Marshal.html#module-Marshal-label-Security+considerations'
2152
- Enabled: true
2153
- VersionAdded: '0.47'
2154
-
2155
- Security/Open:
2156
- Description: 'The use of Kernel#open represents a serious security risk.'
2157
- Enabled: true
2158
- VersionAdded: '0.53'
2159
- Safe: false
2160
-
2161
- Security/YAMLLoad:
2162
- Description: >-
2163
- Prefer usage of `YAML.safe_load` over `YAML.load` due to potential
2164
- security issues. See reference for more information.
2165
- Reference: 'https://ruby-doc.org/stdlib-2.3.3/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
2166
- Enabled: true
2167
- VersionAdded: '0.47'
2168
- SafeAutoCorrect: false
2169
-
2170
- #################### Style ###############################
2171
-
2172
- Style/AccessModifierDeclarations:
2173
- Description: 'Checks style of how access modifiers are used.'
2174
- Enabled: true
2175
- VersionAdded: '0.57'
2176
- EnforcedStyle: group
2177
- SupportedStyles:
2178
- - inline
2179
- - group
2180
-
2181
- Style/Alias:
2182
- Description: 'Use alias instead of alias_method.'
2183
- StyleGuide: '#alias-method-lexically'
2184
- Enabled: true
2185
- VersionAdded: '0.9'
2186
- VersionChanged: '0.36'
2187
- EnforcedStyle: prefer_alias
2188
- SupportedStyles:
2189
- - prefer_alias
2190
- - prefer_alias_method
2191
-
2192
- Style/AndOr:
2193
- Description: 'Use &&/|| instead of and/or.'
2194
- StyleGuide: '#no-and-or-or'
2195
- Enabled: true
2196
- VersionAdded: '0.9'
2197
- VersionChanged: '0.25'
2198
- # Whether `and` and `or` are banned only in conditionals (conditionals)
2199
- # or completely (always).
2200
- EnforcedStyle: always
2201
- SupportedStyles:
2202
- - always
2203
- - conditionals
2204
-
2205
- Style/ArrayJoin:
2206
- Description: 'Use Array#join instead of Array#*.'
2207
- StyleGuide: '#array-join'
2208
- Enabled: true
2209
- VersionAdded: '0.20'
2210
- VersionChanged: '0.31'
2211
-
2212
- Style/AsciiComments:
2213
- Description: 'Use only ascii symbols in comments.'
2214
- StyleGuide: '#english-comments'
2215
- Enabled: true
2216
- VersionAdded: '0.9'
2217
- VersionChanged: '0.52'
2218
- AllowedChars: []
2219
-
2220
- Style/Attr:
2221
- Description: 'Checks for uses of Module#attr.'
2222
- StyleGuide: '#attr'
2223
- Enabled: true
2224
- VersionAdded: '0.9'
2225
- VersionChanged: '0.12'
2226
-
2227
- Style/AutoResourceCleanup:
2228
- Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
2229
- Enabled: false
2230
- VersionAdded: '0.30'
2231
-
2232
- Style/BarePercentLiterals:
2233
- Description: 'Checks if usage of %() or %Q() matches configuration.'
2234
- StyleGuide: '#percent-q-shorthand'
2235
- Enabled: true
2236
- VersionAdded: '0.25'
2237
- EnforcedStyle: bare_percent
2238
- SupportedStyles:
2239
- - percent_q
2240
- - bare_percent
2241
-
2242
- Style/BeginBlock:
2243
- Description: 'Avoid the use of BEGIN blocks.'
2244
- StyleGuide: '#no-BEGIN-blocks'
2245
- Enabled: true
2246
- VersionAdded: '0.9'
2247
-
2248
- Style/BlockComments:
2249
- Description: 'Do not use block comments.'
2250
- StyleGuide: '#no-block-comments'
2251
- Enabled: true
2252
- VersionAdded: '0.9'
2253
- VersionChanged: '0.23'
2254
-
2255
- Style/BlockDelimiters:
2256
- Description: >-
2257
- Avoid using {...} for multi-line blocks (multiline chaining is
2258
- always ugly).
2259
- Prefer {...} over do...end for single-line blocks.
2260
- StyleGuide: '#single-line-blocks'
2261
- Enabled: true
2262
- VersionAdded: '0.30'
2263
- VersionChanged: '0.35'
2264
- EnforcedStyle: line_count_based
2265
- SupportedStyles:
2266
- # The `line_count_based` style enforces braces around single line blocks and
2267
- # do..end around multi-line blocks.
2268
- - line_count_based
2269
- # The `semantic` style enforces braces around functional blocks, where the
2270
- # primary purpose of the block is to return a value and do..end for
2271
- # multi-line procedural blocks, where the primary purpose of the block is
2272
- # its side-effects. Single-line procedural blocks may only use do-end,
2273
- # unless AllowBracesOnProceduralOneLiners has a truthy value (see below).
2274
- #
2275
- # This looks at the usage of a block's method to determine its type (e.g. is
2276
- # the result of a `map` assigned to a variable or passed to another
2277
- # method) but exceptions are permitted in the `ProceduralMethods`,
2278
- # `FunctionalMethods` and `IgnoredMethods` sections below.
2279
- - semantic
2280
- # The `braces_for_chaining` style enforces braces around single line blocks
2281
- # and do..end around multi-line blocks, except for multi-line blocks whose
2282
- # return value is being chained with another method (in which case braces
2283
- # are enforced).
2284
- - braces_for_chaining
2285
- # The `always_braces` style always enforces braces.
2286
- - always_braces
2287
- ProceduralMethods:
2288
- # Methods that are known to be procedural in nature but look functional from
2289
- # their usage, e.g.
2290
- #
2291
- # time = Benchmark.realtime do
2292
- # foo.bar
2293
- # end
2294
- #
2295
- # Here, the return value of the block is discarded but the return value of
2296
- # `Benchmark.realtime` is used.
2297
- - benchmark
2298
- - bm
2299
- - bmbm
2300
- - create
2301
- - each_with_object
2302
- - measure
2303
- - new
2304
- - realtime
2305
- - tap
2306
- - with_object
2307
- FunctionalMethods:
2308
- # Methods that are known to be functional in nature but look procedural from
2309
- # their usage, e.g.
2310
- #
2311
- # let(:foo) { Foo.new }
2312
- #
2313
- # Here, the return value of `Foo.new` is used to define a `foo` helper but
2314
- # doesn't appear to be used from the return value of `let`.
2315
- - let
2316
- - let!
2317
- - subject
2318
- - watch
2319
- IgnoredMethods:
2320
- # Methods that can be either procedural or functional and cannot be
2321
- # categorised from their usage alone, e.g.
2322
- #
2323
- # foo = lambda do |x|
2324
- # puts "Hello, #{x}"
2325
- # end
2326
- #
2327
- # foo = lambda do |x|
2328
- # x * 100
2329
- # end
2330
- #
2331
- # Here, it is impossible to tell from the return value of `lambda` whether
2332
- # the inner block's return value is significant.
2333
- - lambda
2334
- - proc
2335
- - it
2336
- # The AllowBracesOnProceduralOneLiners option is ignored unless the
2337
- # EnforcedStyle is set to `semantic`. If so:
2338
- #
2339
- # If AllowBracesOnProceduralOneLiners is unspecified, or set to any
2340
- # falsey value, then semantic purity is maintained, so one-line
2341
- # procedural blocks must use do-end, not braces.
2342
- #
2343
- # # bad
2344
- # collection.each { |element| puts element }
2345
- #
2346
- # # good
2347
- # collection.each do |element| puts element end
2348
- #
2349
- # If AllowBracesOnProceduralOneLiners is set to any truthy value,
2350
- # then one-line procedural blocks may use either style.
2351
- #
2352
- # # good
2353
- # collection.each { |element| puts element }
2354
- #
2355
- # # also good
2356
- # collection.each do |element| puts element end
2357
- AllowBracesOnProceduralOneLiners: false
2358
-
2359
- Style/BracesAroundHashParameters:
2360
- Description: 'Enforce braces style around hash parameters.'
2361
- Enabled: true
2362
- VersionAdded: '0.14.1'
2363
- VersionChanged: '0.28'
2364
- EnforcedStyle: no_braces
2365
- SupportedStyles:
2366
- # The `braces` style enforces braces around all method parameters that are
2367
- # hashes.
2368
- - braces
2369
- # The `no_braces` style checks that the last parameter doesn't have braces
2370
- # around it.
2371
- - no_braces
2372
- # The `context_dependent` style checks that the last parameter doesn't have
2373
- # braces around it, but requires braces if the second to last parameter is
2374
- # also a hash literal.
2375
- - context_dependent
2376
-
2377
- Style/CaseEquality:
2378
- Description: 'Avoid explicit use of the case equality operator(===).'
2379
- StyleGuide: '#no-case-equality'
2380
- Enabled: true
2381
- VersionAdded: '0.9'
2382
-
2383
- Style/CharacterLiteral:
2384
- Description: 'Checks for uses of character literals.'
2385
- StyleGuide: '#no-character-literals'
2386
- Enabled: true
2387
- VersionAdded: '0.9'
2388
-
2389
- Style/ClassAndModuleChildren:
2390
- Description: 'Checks style of children classes and modules.'
2391
- StyleGuide: '#namespace-definition'
2392
- # Moving from compact to nested children requires knowledge of whether the
2393
- # outer parent is a module or a class. Moving from nested to compact requires
2394
- # verification that the outer parent is defined elsewhere. Rubocop does not
2395
- # have the knowledge to perform either operation safely and thus requires
2396
- # manual oversight.
2397
- SafeAutoCorrect: false
2398
- AutoCorrect: false
2399
- Enabled: true
2400
- VersionAdded: '0.19'
2401
- #
2402
- # Basically there are two different styles:
2403
- #
2404
- # `nested` - have each child on a separate line
2405
- # class Foo
2406
- # class Bar
2407
- # end
2408
- # end
2409
- #
2410
- # `compact` - combine definitions as much as possible
2411
- # class Foo::Bar
2412
- # end
2413
- #
2414
- # The compact style is only forced, for classes or modules with one child.
2415
- EnforcedStyle: nested
2416
- SupportedStyles:
2417
- - nested
2418
- - compact
2419
-
2420
- Style/ClassCheck:
2421
- Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.'
2422
- Enabled: true
2423
- VersionAdded: '0.24'
2424
- EnforcedStyle: is_a?
2425
- SupportedStyles:
2426
- - is_a?
2427
- - kind_of?
2428
-
2429
- Style/ClassMethods:
2430
- Description: 'Use self when defining module/class methods.'
2431
- StyleGuide: '#def-self-class-methods'
2432
- Enabled: true
2433
- VersionAdded: '0.9'
2434
- VersionChanged: '0.20'
2435
-
2436
- Style/ClassVars:
2437
- Description: 'Avoid the use of class variables.'
2438
- StyleGuide: '#no-class-vars'
2439
- Enabled: true
2440
- VersionAdded: '0.13'
2441
-
2442
- # Align with the style guide.
2443
- Style/CollectionMethods:
2444
- Description: 'Preferred collection methods.'
2445
- StyleGuide: '#map-find-select-reduce-size'
2446
- Enabled: false
2447
- VersionAdded: '0.9'
2448
- VersionChanged: '0.27'
2449
- Safe: false
2450
- # Mapping from undesired method to desired method
2451
- # e.g. to use `detect` over `find`:
2452
- #
2453
- # Style/CollectionMethods:
2454
- # PreferredMethods:
2455
- # find: detect
2456
- PreferredMethods:
2457
- collect: 'map'
2458
- collect!: 'map!'
2459
- inject: 'reduce'
2460
- detect: 'find'
2461
- find_all: 'select'
2462
-
2463
- Style/ColonMethodCall:
2464
- Description: 'Do not use :: for method call.'
2465
- StyleGuide: '#double-colons'
2466
- Enabled: true
2467
- VersionAdded: '0.9'
2468
-
2469
- Style/ColonMethodDefinition:
2470
- Description: 'Do not use :: for defining class methods.'
2471
- StyleGuide: '#colon-method-definition'
2472
- Enabled: true
2473
- VersionAdded: '0.52'
2474
-
2475
- Style/CommandLiteral:
2476
- Description: 'Use `` or %x around command literals.'
2477
- StyleGuide: '#percent-x'
2478
- Enabled: true
2479
- VersionAdded: '0.30'
2480
- EnforcedStyle: backticks
2481
- # backticks: Always use backticks.
2482
- # percent_x: Always use `%x`.
2483
- # mixed: Use backticks on single-line commands, and `%x` on multi-line commands.
2484
- SupportedStyles:
2485
- - backticks
2486
- - percent_x
2487
- - mixed
2488
- # If `false`, the cop will always recommend using `%x` if one or more backticks
2489
- # are found in the command string.
2490
- AllowInnerBackticks: false
2491
-
2492
- # Checks formatting of special comments
2493
- Style/CommentAnnotation:
2494
- Description: >-
2495
- Checks formatting of special comments
2496
- (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
2497
- StyleGuide: '#annotate-keywords'
2498
- Enabled: true
2499
- VersionAdded: '0.10'
2500
- VersionChanged: '0.31'
2501
- Keywords:
2502
- - TODO
2503
- - FIXME
2504
- - OPTIMIZE
2505
- - HACK
2506
- - REVIEW
2507
-
2508
- Style/CommentedKeyword:
2509
- Description: 'Do not place comments on the same line as certain keywords.'
2510
- Enabled: true
2511
- VersionAdded: '0.51'
2512
-
2513
- Style/ConditionalAssignment:
2514
- Description: >-
2515
- Use the return value of `if` and `case` statements for
2516
- assignment to a variable and variable comparison instead
2517
- of assigning that variable inside of each branch.
2518
- Enabled: true
2519
- VersionAdded: '0.36'
2520
- VersionChanged: '0.47'
2521
- EnforcedStyle: assign_to_condition
2522
- SupportedStyles:
2523
- - assign_to_condition
2524
- - assign_inside_condition
2525
- # When configured to `assign_to_condition`, `SingleLineConditionsOnly`
2526
- # will only register an offense when all branches of a condition are
2527
- # a single line.
2528
- # When configured to `assign_inside_condition`, `SingleLineConditionsOnly`
2529
- # will only register an offense for assignment to a condition that has
2530
- # at least one multiline branch.
2531
- SingleLineConditionsOnly: true
2532
- IncludeTernaryExpressions: true
2533
-
2534
- Style/ConstantVisibility:
2535
- Description: >-
2536
- Check that class- and module constants have
2537
- visibility declarations.
2538
- Enabled: false
2539
- VersionAdded: '0.66'
2540
-
2541
- # Checks that you have put a copyright in a comment before any code.
2542
- #
2543
- # You can override the default Notice in your .rubocop.yml file.
2544
- #
2545
- # In order to use autocorrect, you must supply a value for the
2546
- # `AutocorrectNotice` key that matches the regexp Notice. A blank
2547
- # `AutocorrectNotice` will cause an error during autocorrect.
2548
- #
2549
- # Autocorrect will add a copyright notice in a comment at the top
2550
- # of the file immediately after any shebang or encoding comments.
2551
- #
2552
- # Example rubocop.yml:
2553
- #
2554
- # Style/Copyright:
2555
- # Enabled: true
2556
- # Notice: 'Copyright (\(c\) )?2015 Yahoo! Inc'
2557
- # AutocorrectNotice: '# Copyright (c) 2015 Yahoo! Inc.'
2558
- #
2559
- Style/Copyright:
2560
- Description: 'Include a copyright notice in each file before any code.'
2561
- Enabled: false
2562
- VersionAdded: '0.30'
2563
- Notice: '^Copyright (\(c\) )?2[0-9]{3} .+'
2564
- AutocorrectNotice: ''
2565
-
2566
- Style/DateTime:
2567
- Description: 'Use Time over DateTime.'
2568
- StyleGuide: '#date--time'
2569
- Enabled: false
2570
- VersionAdded: '0.51'
2571
- VersionChanged: '0.59'
2572
- AllowCoercion: false
2573
-
2574
- Style/DefWithParentheses:
2575
- Description: 'Use def with parentheses when there are arguments.'
2576
- StyleGuide: '#method-parens'
2577
- Enabled: true
2578
- VersionAdded: '0.9'
2579
- VersionChanged: '0.12'
2580
-
2581
- Style/Dir:
2582
- Description: >-
2583
- Use the `__dir__` method to retrieve the canonicalized
2584
- absolute path to the current file.
2585
- Enabled: true
2586
- VersionAdded: '0.50'
2587
-
2588
- Style/Documentation:
2589
- Description: 'Document classes and non-namespace modules.'
2590
- Enabled: true
2591
- VersionAdded: '0.9'
2592
- Exclude:
2593
- - 'spec/**/*'
2594
- - 'test/**/*'
2595
-
2596
- Style/DocumentationMethod:
2597
- Description: 'Checks for missing documentation comment for public methods.'
2598
- Enabled: false
2599
- VersionAdded: '0.43'
2600
- Exclude:
2601
- - 'spec/**/*'
2602
- - 'test/**/*'
2603
- RequireForNonPublicMethods: false
2604
-
2605
- Style/DoubleCopDisableDirective:
2606
- Description: 'Checks for double rubocop:disable comments on a single line.'
2607
- Enabled: true
2608
- VersionAdded: '0.73'
2609
-
2610
- Style/DoubleNegation:
2611
- Description: 'Checks for uses of double negation (!!).'
2612
- StyleGuide: '#no-bang-bang'
2613
- Enabled: true
2614
- VersionAdded: '0.19'
2615
-
2616
- Style/EachForSimpleLoop:
2617
- Description: >-
2618
- Use `Integer#times` for a simple loop which iterates a fixed
2619
- number of times.
2620
- Enabled: true
2621
- VersionAdded: '0.41'
2622
-
2623
- Style/EachWithObject:
2624
- Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
2625
- Enabled: true
2626
- VersionAdded: '0.22'
2627
- VersionChanged: '0.42'
2628
-
2629
- Style/EmptyBlockParameter:
2630
- Description: 'Omit pipes for empty block parameters.'
2631
- Enabled: true
2632
- VersionAdded: '0.52'
2633
-
2634
- Style/EmptyCaseCondition:
2635
- Description: 'Avoid empty condition in case statements.'
2636
- Enabled: true
2637
- VersionAdded: '0.40'
2638
-
2639
- Style/EmptyElse:
2640
- Description: 'Avoid empty else-clauses.'
2641
- Enabled: true
2642
- VersionAdded: '0.28'
2643
- VersionChanged: '0.32'
2644
- EnforcedStyle: both
2645
- # empty - warn only on empty `else`
2646
- # nil - warn on `else` with nil in it
2647
- # both - warn on empty `else` and `else` with `nil` in it
2648
- SupportedStyles:
2649
- - empty
2650
- - nil
2651
- - both
2652
-
2653
- Style/EmptyLambdaParameter:
2654
- Description: 'Omit parens for empty lambda parameters.'
2655
- Enabled: true
2656
- VersionAdded: '0.52'
2657
-
2658
- Style/EmptyLiteral:
2659
- Description: 'Prefer literals to Array.new/Hash.new/String.new.'
2660
- StyleGuide: '#literal-array-hash'
2661
- Enabled: true
2662
- VersionAdded: '0.9'
2663
- VersionChanged: '0.12'
2664
-
2665
- Style/EmptyMethod:
2666
- Description: 'Checks the formatting of empty method definitions.'
2667
- StyleGuide: '#no-single-line-methods'
2668
- Enabled: true
2669
- VersionAdded: '0.46'
2670
- EnforcedStyle: compact
2671
- SupportedStyles:
2672
- - compact
2673
- - expanded
2674
-
2675
- Style/Encoding:
2676
- Description: 'Use UTF-8 as the source file encoding.'
2677
- StyleGuide: '#utf-8'
2678
- Enabled: true
2679
- VersionAdded: '0.9'
2680
- VersionChanged: '0.50'
2681
-
2682
- Style/EndBlock:
2683
- Description: 'Avoid the use of END blocks.'
2684
- StyleGuide: '#no-END-blocks'
2685
- Enabled: true
2686
- VersionAdded: '0.9'
2687
-
2688
- Style/EvalWithLocation:
2689
- Description: 'Pass `__FILE__` and `__LINE__` to `eval` method, as they are used by backtraces.'
2690
- Enabled: true
2691
- VersionAdded: '0.52'
2692
-
2693
- Style/EvenOdd:
2694
- Description: 'Favor the use of `Integer#even?` && `Integer#odd?`.'
2695
- StyleGuide: '#predicate-methods'
2696
- Enabled: true
2697
- VersionAdded: '0.12'
2698
- VersionChanged: '0.29'
2699
-
2700
- Style/ExpandPathArguments:
2701
- Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
2702
- Enabled: true
2703
- VersionAdded: '0.53'
2704
-
2705
- Style/FloatDivision:
2706
- Description: 'For performing float division, coerce one side only.'
2707
- StyleGuide: '#float-division'
2708
- Reference: 'https://github.com/rubocop-hq/ruby-style-guide/issues/628'
2709
- Enabled: true
2710
- VersionAdded: '0.72'
2711
- EnforcedStyle: single_coerce
2712
- SupportedStyles:
2713
- - left_coerce
2714
- - right_coerce
2715
- - single_coerce
2716
- - fdiv
2717
-
2718
- Style/For:
2719
- Description: 'Checks use of for or each in multiline loops.'
2720
- StyleGuide: '#no-for-loops'
2721
- Enabled: true
2722
- VersionAdded: '0.13'
2723
- VersionChanged: '0.59'
2724
- EnforcedStyle: each
2725
- SupportedStyles:
2726
- - each
2727
- - for
2728
-
2729
- Style/FormatString:
2730
- Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
2731
- StyleGuide: '#sprintf'
2732
- Enabled: true
2733
- VersionAdded: '0.19'
2734
- VersionChanged: '0.49'
2735
- EnforcedStyle: format
2736
- SupportedStyles:
2737
- - format
2738
- - sprintf
2739
- - percent
2740
-
2741
- Style/FormatStringToken:
2742
- Description: 'Use a consistent style for format string tokens.'
2743
- Enabled: true
2744
- EnforcedStyle: annotated
2745
- SupportedStyles:
2746
- # Prefer tokens which contain a sprintf like type annotation like
2747
- # `%<name>s`, `%<age>d`, `%<score>f`
2748
- - annotated
2749
- # Prefer simple looking "template" style tokens like `%{name}`, `%{age}`
2750
- - template
2751
- - unannotated
2752
- VersionAdded: '0.49'
2753
- VersionChanged: '0.75'
2754
-
2755
- Style/FrozenStringLiteralComment:
2756
- Description: >-
2757
- Add the frozen_string_literal comment to the top of files
2758
- to help transition to frozen string literals by default.
2759
- Enabled: true
2760
- VersionAdded: '0.36'
2761
- VersionChanged: '0.69'
2762
- EnforcedStyle: always
2763
- SupportedStyles:
2764
- # `always` will always add the frozen string literal comment to a file
2765
- # regardless of the Ruby version or if `freeze` or `<<` are called on a
2766
- # string literal. If you run code against multiple versions of Ruby, it is
2767
- # possible that this will create errors in Ruby 2.3.0+.
2768
- - always
2769
- # `never` will enforce that the frozen string literal comment does not
2770
- # exist in a file.
2771
- - never
2772
-
2773
- Style/GlobalVars:
2774
- Description: 'Do not introduce global variables.'
2775
- StyleGuide: '#instance-vars'
2776
- Reference: 'https://www.zenspider.com/ruby/quickref.html'
2777
- Enabled: true
2778
- VersionAdded: '0.13'
2779
- # Built-in global variables are allowed by default.
2780
- AllowedVariables: []
2781
-
2782
- Style/GuardClause:
2783
- Description: 'Check for conditionals that can be replaced with guard clauses.'
2784
- StyleGuide: '#no-nested-conditionals'
2785
- Enabled: true
2786
- VersionAdded: '0.20'
2787
- VersionChanged: '0.22'
2788
- # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
2789
- # needs to have to trigger this cop
2790
- MinBodyLength: 1
2791
-
2792
- Style/HashSyntax:
2793
- Description: >-
2794
- Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
2795
- { :a => 1, :b => 2 }.
2796
- StyleGuide: '#hash-literals'
2797
- Enabled: true
2798
- VersionAdded: '0.9'
2799
- VersionChanged: '0.43'
2800
- EnforcedStyle: ruby19
2801
- SupportedStyles:
2802
- # checks for 1.9 syntax (e.g. {a: 1}) for all symbol keys
2803
- - ruby19
2804
- # checks for hash rocket syntax for all hashes
2805
- - hash_rockets
2806
- # forbids mixed key syntaxes (e.g. {a: 1, :b => 2})
2807
- - no_mixed_keys
2808
- # enforces both ruby19 and no_mixed_keys styles
2809
- - ruby19_no_mixed_keys
2810
- # Force hashes that have a symbol value to use hash rockets
2811
- UseHashRocketsWithSymbolValues: false
2812
- # Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
2813
- PreferHashRocketsForNonAlnumEndingSymbols: false
2814
-
2815
- Style/IdenticalConditionalBranches:
2816
- Description: >-
2817
- Checks that conditional statements do not have an identical
2818
- line at the end of each branch, which can validly be moved
2819
- out of the conditional.
2820
- Enabled: true
2821
- VersionAdded: '0.36'
2822
-
2823
- Style/IfInsideElse:
2824
- Description: 'Finds if nodes inside else, which can be converted to elsif.'
2825
- Enabled: true
2826
- AllowIfModifier: false
2827
- VersionAdded: '0.36'
2828
-
2829
- Style/IfUnlessModifier:
2830
- Description: >-
2831
- Favor modifier if/unless usage when you have a
2832
- single-line body.
2833
- StyleGuide: '#if-as-a-modifier'
2834
- Enabled: true
2835
- VersionAdded: '0.9'
2836
- VersionChanged: '0.30'
2837
-
2838
- Style/IfUnlessModifierOfIfUnless:
2839
- Description: >-
2840
- Avoid modifier if/unless usage on conditionals.
2841
- Enabled: true
2842
- VersionAdded: '0.39'
2843
-
2844
- Style/IfWithSemicolon:
2845
- Description: 'Do not use if x; .... Use the ternary operator instead.'
2846
- StyleGuide: '#no-semicolon-ifs'
2847
- Enabled: true
2848
- VersionAdded: '0.9'
2849
-
2850
- Style/ImplicitRuntimeError:
2851
- Description: >-
2852
- Use `raise` or `fail` with an explicit exception class and
2853
- message, rather than just a message.
2854
- Enabled: false
2855
- VersionAdded: '0.41'
2856
-
2857
- Style/InfiniteLoop:
2858
- Description: 'Use Kernel#loop for infinite loops.'
2859
- StyleGuide: '#infinite-loop'
2860
- Enabled: true
2861
- VersionAdded: '0.26'
2862
- VersionChanged: '0.61'
2863
- SafeAutoCorrect: true
2864
-
2865
- Style/InlineComment:
2866
- Description: 'Avoid trailing inline comments.'
2867
- Enabled: false
2868
- VersionAdded: '0.23'
2869
-
2870
- Style/InverseMethods:
2871
- Description: >-
2872
- Use the inverse method instead of `!.method`
2873
- if an inverse method is defined.
2874
- Enabled: true
2875
- Safe: false
2876
- VersionAdded: '0.48'
2877
- # `InverseMethods` are methods that can be inverted by a not (`not` or `!`)
2878
- # The relationship of inverse methods only needs to be defined in one direction.
2879
- # Keys and values both need to be defined as symbols.
2880
- InverseMethods:
2881
- :any?: :none?
2882
- :even?: :odd?
2883
- :==: :!=
2884
- :=~: :!~
2885
- :<: :>=
2886
- :>: :<=
2887
- # `ActiveSupport` defines some common inverse methods. They are listed below,
2888
- # and not enabled by default.
2889
- #:present?: :blank?,
2890
- #:include?: :exclude?
2891
- # `InverseBlocks` are methods that are inverted by inverting the return
2892
- # of the block that is passed to the method
2893
- InverseBlocks:
2894
- :select: :reject
2895
- :select!: :reject!
2896
-
2897
- Style/IpAddresses:
2898
- Description: "Don't include literal IP addresses in code."
2899
- Enabled: false
2900
- VersionAdded: '0.58'
2901
- VersionChanged: '0.77'
2902
- # Allow addresses to be permitted
2903
- AllowedAddresses:
2904
- - "::"
2905
- # :: is a valid IPv6 address, but could potentially be legitimately in code
2906
-
2907
- Style/Lambda:
2908
- Description: 'Use the new lambda literal syntax for single-line blocks.'
2909
- StyleGuide: '#lambda-multi-line'
2910
- Enabled: true
2911
- VersionAdded: '0.9'
2912
- VersionChanged: '0.40'
2913
- EnforcedStyle: line_count_dependent
2914
- SupportedStyles:
2915
- - line_count_dependent
2916
- - lambda
2917
- - literal
2918
-
2919
- Style/LambdaCall:
2920
- Description: 'Use lambda.call(...) instead of lambda.(...).'
2921
- StyleGuide: '#proc-call'
2922
- Enabled: true
2923
- VersionAdded: '0.13.1'
2924
- VersionChanged: '0.14'
2925
- EnforcedStyle: call
2926
- SupportedStyles:
2927
- - call
2928
- - braces
2929
-
2930
- Style/LineEndConcatenation:
2931
- Description: >-
2932
- Use \ instead of + or << to concatenate two string literals at
2933
- line end.
2934
- Enabled: true
2935
- SafeAutoCorrect: false
2936
- VersionAdded: '0.18'
2937
- VersionChanged: '0.64'
2938
-
2939
- Style/MethodCallWithArgsParentheses:
2940
- Description: 'Use parentheses for method calls with arguments.'
2941
- StyleGuide: '#method-invocation-parens'
2942
- Enabled: false
2943
- VersionAdded: '0.47'
2944
- VersionChanged: '0.61'
2945
- IgnoreMacros: true
2946
- IgnoredMethods: []
2947
- IgnoredPatterns: []
2948
- IncludedMacros: []
2949
- AllowParenthesesInMultilineCall: false
2950
- AllowParenthesesInChaining: false
2951
- AllowParenthesesInCamelCaseMethod: false
2952
- EnforcedStyle: require_parentheses
2953
- SupportedStyles:
2954
- - require_parentheses
2955
- - omit_parentheses
2956
-
2957
- Style/MethodCallWithoutArgsParentheses:
2958
- Description: 'Do not use parentheses for method calls with no arguments.'
2959
- StyleGuide: '#method-invocation-parens'
2960
- Enabled: true
2961
- IgnoredMethods: []
2962
- VersionAdded: '0.47'
2963
- VersionChanged: '0.55'
2964
-
2965
- Style/MethodCalledOnDoEndBlock:
2966
- Description: 'Avoid chaining a method call on a do...end block.'
2967
- StyleGuide: '#single-line-blocks'
2968
- Enabled: false
2969
- VersionAdded: '0.14'
2970
-
2971
- Style/MethodDefParentheses:
2972
- Description: >-
2973
- Checks if the method definitions have or don't have
2974
- parentheses.
2975
- StyleGuide: '#method-parens'
2976
- Enabled: true
2977
- VersionAdded: '0.16'
2978
- VersionChanged: '0.35'
2979
- EnforcedStyle: require_parentheses
2980
- SupportedStyles:
2981
- - require_parentheses
2982
- - require_no_parentheses
2983
- - require_no_parentheses_except_multiline
2984
-
2985
- Style/MethodMissingSuper:
2986
- Description: Checks for `method_missing` to call `super`.
2987
- StyleGuide: '#no-method-missing'
2988
- Enabled: true
2989
- VersionAdded: '0.56'
2990
-
2991
- Style/MinMax:
2992
- Description: >-
2993
- Use `Enumerable#minmax` instead of `Enumerable#min`
2994
- and `Enumerable#max` in conjunction.
2995
- Enabled: true
2996
- VersionAdded: '0.50'
2997
-
2998
- Style/MissingElse:
2999
- Description: >-
3000
- Require if/case expressions to have an else branches.
3001
- If enabled, it is recommended that
3002
- Style/UnlessElse and Style/EmptyElse be enabled.
3003
- This will conflict with Style/EmptyElse if
3004
- Style/EmptyElse is configured to style "both".
3005
- Enabled: false
3006
- VersionAdded: '0.30'
3007
- VersionChanged: '0.38'
3008
- EnforcedStyle: both
3009
- SupportedStyles:
3010
- # if - warn when an if expression is missing an else branch
3011
- # case - warn when a case expression is missing an else branch
3012
- # both - warn when an if or case expression is missing an else branch
3013
- - if
3014
- - case
3015
- - both
3016
-
3017
- Style/MissingRespondToMissing:
3018
- Description: >-
3019
- Checks if `method_missing` is implemented
3020
- without implementing `respond_to_missing`.
3021
- StyleGuide: '#no-method-missing'
3022
- Enabled: true
3023
- VersionAdded: '0.56'
3024
-
3025
- Style/MixinGrouping:
3026
- Description: 'Checks for grouping of mixins in `class` and `module` bodies.'
3027
- StyleGuide: '#mixin-grouping'
3028
- Enabled: true
3029
- VersionAdded: '0.48'
3030
- VersionChanged: '0.49'
3031
- EnforcedStyle: separated
3032
- SupportedStyles:
3033
- # separated: each mixed in module goes in a separate statement.
3034
- # grouped: mixed in modules are grouped into a single statement.
3035
- - separated
3036
- - grouped
3037
-
3038
- Style/MixinUsage:
3039
- Description: 'Checks that `include`, `extend` and `prepend` exists at the top level.'
3040
- Enabled: true
3041
- VersionAdded: '0.51'
3042
-
3043
- Style/ModuleFunction:
3044
- Description: 'Checks for usage of `extend self` in modules.'
3045
- StyleGuide: '#module-function'
3046
- Enabled: true
3047
- VersionAdded: '0.11'
3048
- VersionChanged: '0.65'
3049
- EnforcedStyle: module_function
3050
- SupportedStyles:
3051
- - module_function
3052
- - extend_self
3053
- Autocorrect: false
3054
- SafeAutoCorrect: false
3055
-
3056
- Style/MultilineBlockChain:
3057
- Description: 'Avoid multi-line chains of blocks.'
3058
- StyleGuide: '#single-line-blocks'
3059
- Enabled: true
3060
- VersionAdded: '0.13'
3061
-
3062
- Style/MultilineIfModifier:
3063
- Description: 'Only use if/unless modifiers on single line statements.'
3064
- StyleGuide: '#no-multiline-if-modifiers'
3065
- Enabled: true
3066
- VersionAdded: '0.45'
3067
-
3068
- Style/MultilineIfThen:
3069
- Description: 'Do not use then for multi-line if/unless.'
3070
- StyleGuide: '#no-then'
3071
- Enabled: true
3072
- VersionAdded: '0.9'
3073
- VersionChanged: '0.26'
3074
-
3075
- Style/MultilineMemoization:
3076
- Description: 'Wrap multiline memoizations in a `begin` and `end` block.'
3077
- Enabled: true
3078
- VersionAdded: '0.44'
3079
- VersionChanged: '0.48'
3080
- EnforcedStyle: keyword
3081
- SupportedStyles:
3082
- - keyword
3083
- - braces
3084
-
3085
- Style/MultilineMethodSignature:
3086
- Description: 'Avoid multi-line method signatures.'
3087
- Enabled: false
3088
- VersionAdded: '0.59'
3089
-
3090
- Style/MultilineTernaryOperator:
3091
- Description: >-
3092
- Avoid multi-line ?: (the ternary operator);
3093
- use if/unless instead.
3094
- StyleGuide: '#no-multiline-ternary'
3095
- Enabled: true
3096
- VersionAdded: '0.9'
3097
-
3098
- Style/MultilineWhenThen:
3099
- Description: 'Do not use then for multi-line when statement.'
3100
- StyleGuide: '#no-then'
3101
- Enabled: true
3102
- VersionAdded: '0.73'
3103
-
3104
- Style/MultipleComparison:
3105
- Description: >-
3106
- Avoid comparing a variable with multiple items in a conditional,
3107
- use Array#include? instead.
3108
- Enabled: true
3109
- VersionAdded: '0.49'
3110
-
3111
- Style/MutableConstant:
3112
- Description: 'Do not assign mutable objects to constants.'
3113
- Enabled: true
3114
- VersionAdded: '0.34'
3115
- VersionChanged: '0.65'
3116
- EnforcedStyle: literals
3117
- SupportedStyles:
3118
- # literals: freeze literals assigned to constants
3119
- # strict: freeze all constants
3120
- # Strict mode is considered an experimental feature. It has not been updated
3121
- # with an exhaustive list of all methods that will produce frozen objects so
3122
- # there is a decent chance of getting some false positives. Luckily, there is
3123
- # no harm in freezing an already frozen object.
3124
- - literals
3125
- - strict
3126
-
3127
- Style/NegatedIf:
3128
- Description: >-
3129
- Favor unless over if for negative conditions
3130
- (or control flow or).
3131
- StyleGuide: '#unless-for-negatives'
3132
- Enabled: true
3133
- VersionAdded: '0.20'
3134
- VersionChanged: '0.48'
3135
- EnforcedStyle: both
3136
- SupportedStyles:
3137
- # both: prefix and postfix negated `if` should both use `unless`
3138
- # prefix: only use `unless` for negated `if` statements positioned before the body of the statement
3139
- # postfix: only use `unless` for negated `if` statements positioned after the body of the statement
3140
- - both
3141
- - prefix
3142
- - postfix
3143
-
3144
- Style/NegatedUnless:
3145
- Description: 'Favor if over unless for negative conditions.'
3146
- StyleGuide: '#if-for-negatives'
3147
- Enabled: true
3148
- VersionAdded: '0.69'
3149
- EnforcedStyle: both
3150
- SupportedStyles:
3151
- # both: prefix and postfix negated `unless` should both use `if`
3152
- # prefix: only use `if` for negated `unless` statements positioned before the body of the statement
3153
- # postfix: only use `if` for negated `unless` statements positioned after the body of the statement
3154
- - both
3155
- - prefix
3156
- - postfix
3157
-
3158
- Style/NegatedWhile:
3159
- Description: 'Favor until over while for negative conditions.'
3160
- StyleGuide: '#until-for-negatives'
3161
- Enabled: true
3162
- VersionAdded: '0.20'
3163
-
3164
- Style/NestedModifier:
3165
- Description: 'Avoid using nested modifiers.'
3166
- StyleGuide: '#no-nested-modifiers'
3167
- Enabled: true
3168
- VersionAdded: '0.35'
3169
-
3170
- Style/NestedParenthesizedCalls:
3171
- Description: >-
3172
- Parenthesize method calls which are nested inside the
3173
- argument list of another parenthesized method call.
3174
- Enabled: true
3175
- VersionAdded: '0.36'
3176
- VersionChanged: '0.77'
3177
- AllowedMethods:
3178
- - be
3179
- - be_a
3180
- - be_an
3181
- - be_between
3182
- - be_falsey
3183
- - be_kind_of
3184
- - be_instance_of
3185
- - be_truthy
3186
- - be_within
3187
- - eq
3188
- - eql
3189
- - end_with
3190
- - include
3191
- - match
3192
- - raise_error
3193
- - respond_to
3194
- - start_with
3195
-
3196
- Style/NestedTernaryOperator:
3197
- Description: 'Use one expression per branch in a ternary operator.'
3198
- StyleGuide: '#no-nested-ternary'
3199
- Enabled: true
3200
- VersionAdded: '0.9'
3201
-
3202
- Style/Next:
3203
- Description: 'Use `next` to skip iteration instead of a condition at the end.'
3204
- StyleGuide: '#no-nested-conditionals'
3205
- Enabled: true
3206
- VersionAdded: '0.22'
3207
- VersionChanged: '0.35'
3208
- # With `always` all conditions at the end of an iteration needs to be
3209
- # replaced by next - with `skip_modifier_ifs` the modifier if like this one
3210
- # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
3211
- EnforcedStyle: skip_modifier_ifs
3212
- # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
3213
- # needs to have to trigger this cop
3214
- MinBodyLength: 3
3215
- SupportedStyles:
3216
- - skip_modifier_ifs
3217
- - always
3218
-
3219
- Style/NilComparison:
3220
- Description: 'Prefer x.nil? to x == nil.'
3221
- StyleGuide: '#predicate-methods'
3222
- Enabled: true
3223
- VersionAdded: '0.12'
3224
- VersionChanged: '0.59'
3225
- EnforcedStyle: predicate
3226
- SupportedStyles:
3227
- - predicate
3228
- - comparison
3229
-
3230
- Style/NonNilCheck:
3231
- Description: 'Checks for redundant nil checks.'
3232
- StyleGuide: '#no-non-nil-checks'
3233
- Enabled: true
3234
- VersionAdded: '0.20'
3235
- VersionChanged: '0.22'
3236
- # With `IncludeSemanticChanges` set to `true`, this cop reports offenses for
3237
- # `!x.nil?` and autocorrects that and `x != nil` to solely `x`, which is
3238
- # **usually** OK, but might change behavior.
3239
- #
3240
- # With `IncludeSemanticChanges` set to `false`, this cop does not report
3241
- # offenses for `!x.nil?` and does no changes that might change behavior.
3242
- IncludeSemanticChanges: false
3243
-
3244
- Style/Not:
3245
- Description: 'Use ! instead of not.'
3246
- StyleGuide: '#bang-not-not'
3247
- Enabled: true
3248
- VersionAdded: '0.9'
3249
- VersionChanged: '0.20'
3250
-
3251
- Style/NumericLiteralPrefix:
3252
- Description: 'Use smallcase prefixes for numeric literals.'
3253
- StyleGuide: '#numeric-literal-prefixes'
3254
- Enabled: true
3255
- VersionAdded: '0.41'
3256
- EnforcedOctalStyle: zero_with_o
3257
- SupportedOctalStyles:
3258
- - zero_with_o
3259
- - zero_only
3260
-
3261
-
3262
- Style/NumericLiterals:
3263
- Description: >-
3264
- Add underscores to large numeric literals to improve their
3265
- readability.
3266
- StyleGuide: '#underscores-in-numerics'
3267
- Enabled: true
3268
- VersionAdded: '0.9'
3269
- VersionChanged: '0.48'
3270
- MinDigits: 5
3271
- Strict: false
3272
-
3273
- Style/NumericPredicate:
3274
- Description: >-
3275
- Checks for the use of predicate- or comparison methods for
3276
- numeric comparisons.
3277
- StyleGuide: '#predicate-methods'
3278
- Safe: false
3279
- # This will change to a new method call which isn't guaranteed to be on the
3280
- # object. Switching these methods has to be done with knowledge of the types
3281
- # of the variables which rubocop doesn't have.
3282
- SafeAutoCorrect: false
3283
- AutoCorrect: false
3284
- Enabled: true
3285
- VersionAdded: '0.42'
3286
- VersionChanged: '0.59'
3287
- EnforcedStyle: predicate
3288
- SupportedStyles:
3289
- - predicate
3290
- - comparison
3291
- IgnoredMethods: []
3292
- # Exclude RSpec specs because assertions like `expect(1).to be > 0` cause
3293
- # false positives.
3294
- Exclude:
3295
- - 'spec/**/*'
3296
-
3297
- Style/OneLineConditional:
3298
- Description: >-
3299
- Favor the ternary operator(?:) over
3300
- if/then/else/end constructs.
3301
- StyleGuide: '#ternary-operator'
3302
- Enabled: true
3303
- VersionAdded: '0.9'
3304
- VersionChanged: '0.38'
3305
-
3306
- Style/OptionHash:
3307
- Description: "Don't use option hashes when you can use keyword arguments."
3308
- Enabled: false
3309
- VersionAdded: '0.33'
3310
- VersionChanged: '0.34'
3311
- # A list of parameter names that will be flagged by this cop.
3312
- SuspiciousParamNames:
3313
- - options
3314
- - opts
3315
- - args
3316
- - params
3317
- - parameters
3318
-
3319
- Style/OptionalArguments:
3320
- Description: >-
3321
- Checks for optional arguments that do not appear at the end
3322
- of the argument list.
3323
- StyleGuide: '#optional-arguments'
3324
- Enabled: true
3325
- VersionAdded: '0.33'
3326
-
3327
- Style/OrAssignment:
3328
- Description: 'Recommend usage of double pipe equals (||=) where applicable.'
3329
- StyleGuide: '#double-pipe-for-uninit'
3330
- Enabled: true
3331
- VersionAdded: '0.50'
3332
-
3333
- Style/ParallelAssignment:
3334
- Description: >-
3335
- Check for simple usages of parallel assignment.
3336
- It will only warn when the number of variables
3337
- matches on both sides of the assignment.
3338
- StyleGuide: '#parallel-assignment'
3339
- Enabled: true
3340
- VersionAdded: '0.32'
3341
-
3342
- Style/ParenthesesAroundCondition:
3343
- Description: >-
3344
- Don't use parentheses around the condition of an
3345
- if/unless/while.
3346
- StyleGuide: '#no-parens-around-condition'
3347
- Enabled: true
3348
- VersionAdded: '0.9'
3349
- VersionChanged: '0.56'
3350
- AllowSafeAssignment: true
3351
- AllowInMultilineConditions: false
3352
-
3353
- Style/PercentLiteralDelimiters:
3354
- Description: 'Use `%`-literal delimiters consistently.'
3355
- StyleGuide: '#percent-literal-braces'
3356
- Enabled: true
3357
- VersionAdded: '0.19'
3358
- # Specify the default preferred delimiter for all types with the 'default' key
3359
- # Override individual delimiters (even with default specified) by specifying
3360
- # an individual key
3361
- PreferredDelimiters:
3362
- default: ()
3363
- '%i': '[]'
3364
- '%I': '[]'
3365
- '%r': '{}'
3366
- '%w': '[]'
3367
- '%W': '[]'
3368
- VersionChanged: '0.48.1'
3369
-
3370
- Style/PercentQLiterals:
3371
- Description: 'Checks if uses of %Q/%q match the configured preference.'
3372
- Enabled: true
3373
- VersionAdded: '0.25'
3374
- EnforcedStyle: lower_case_q
3375
- SupportedStyles:
3376
- - lower_case_q # Use `%q` when possible, `%Q` when necessary
3377
- - upper_case_q # Always use `%Q`
3378
-
3379
- Style/PerlBackrefs:
3380
- Description: 'Avoid Perl-style regex back references.'
3381
- StyleGuide: '#no-perl-regexp-last-matchers'
3382
- Enabled: true
3383
- VersionAdded: '0.13'
3384
-
3385
- Style/PreferredHashMethods:
3386
- Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
3387
- StyleGuide: '#hash-key'
3388
- Enabled: true
3389
- Safe: false
3390
- VersionAdded: '0.41'
3391
- VersionChanged: '0.70'
3392
- EnforcedStyle: short
3393
- SupportedStyles:
3394
- - short
3395
- - verbose
3396
-
3397
- Style/Proc:
3398
- Description: 'Use proc instead of Proc.new.'
3399
- StyleGuide: '#proc'
3400
- Enabled: true
3401
- VersionAdded: '0.9'
3402
- VersionChanged: '0.18'
3403
-
3404
- Style/RaiseArgs:
3405
- Description: 'Checks the arguments passed to raise/fail.'
3406
- StyleGuide: '#exception-class-messages'
3407
- Enabled: true
3408
- VersionAdded: '0.14'
3409
- VersionChanged: '0.40'
3410
- EnforcedStyle: exploded
3411
- SupportedStyles:
3412
- - compact # raise Exception.new(msg)
3413
- - exploded # raise Exception, msg
3414
-
3415
- Style/RandomWithOffset:
3416
- Description: >-
3417
- Prefer to use ranges when generating random numbers instead of
3418
- integers with offsets.
3419
- StyleGuide: '#random-numbers'
3420
- Enabled: true
3421
- VersionAdded: '0.52'
3422
-
3423
- Style/RedundantBegin:
3424
- Description: "Don't use begin blocks when they are not needed."
3425
- StyleGuide: '#begin-implicit'
3426
- Enabled: true
3427
- VersionAdded: '0.10'
3428
- VersionChanged: '0.21'
3429
-
3430
- Style/RedundantCapitalW:
3431
- Description: 'Checks for %W when interpolation is not needed.'
3432
- Enabled: true
3433
- VersionAdded: '0.76'
3434
-
3435
- Style/RedundantCondition:
3436
- Description: 'Checks for unnecessary conditional expressions.'
3437
- Enabled: true
3438
- VersionAdded: '0.76'
3439
-
3440
- Style/RedundantConditional:
3441
- Description: "Don't return true/false from a conditional."
3442
- Enabled: true
3443
- VersionAdded: '0.50'
3444
-
3445
- Style/RedundantException:
3446
- Description: "Checks for an obsolete RuntimeException argument in raise/fail."
3447
- StyleGuide: '#no-explicit-runtimeerror'
3448
- Enabled: true
3449
- VersionAdded: '0.14'
3450
- VersionChanged: '0.29'
3451
-
3452
- Style/RedundantFreeze:
3453
- Description: "Checks usages of Object#freeze on immutable objects."
3454
- Enabled: true
3455
- VersionAdded: '0.34'
3456
- VersionChanged: '0.66'
3457
-
3458
- Style/RedundantInterpolation:
3459
- Description: 'Checks for strings that are just an interpolated expression.'
3460
- Enabled: true
3461
- VersionAdded: '0.76'
3462
-
3463
- Style/RedundantParentheses:
3464
- Description: "Checks for parentheses that seem not to serve any purpose."
3465
- Enabled: true
3466
- VersionAdded: '0.36'
3467
-
3468
- Style/RedundantPercentQ:
3469
- Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
3470
- StyleGuide: '#percent-q'
3471
- Enabled: true
3472
- VersionAdded: '0.76'
3473
-
3474
- Style/RedundantReturn:
3475
- Description: "Don't use return where it's not required."
3476
- StyleGuide: '#no-explicit-return'
3477
- Enabled: true
3478
- VersionAdded: '0.10'
3479
- VersionChanged: '0.14'
3480
- # When `true` allows code like `return x, y`.
3481
- AllowMultipleReturnValues: false
3482
-
3483
- Style/RedundantSelf:
3484
- Description: "Don't use self where it's not needed."
3485
- StyleGuide: '#no-self-unless-required'
3486
- Enabled: true
3487
- VersionAdded: '0.10'
3488
- VersionChanged: '0.13'
3489
-
3490
- Style/RedundantSort:
3491
- Description: >-
3492
- Use `min` instead of `sort.first`,
3493
- `max_by` instead of `sort_by...last`, etc.
3494
- Enabled: true
3495
- VersionAdded: '0.76'
3496
-
3497
- Style/RedundantSortBy:
3498
- Description: 'Use `sort` instead of `sort_by { |x| x }`.'
3499
- Enabled: true
3500
- VersionAdded: '0.36'
3501
-
3502
- Style/RegexpLiteral:
3503
- Description: 'Use / or %r around regular expressions.'
3504
- StyleGuide: '#percent-r'
3505
- Enabled: true
3506
- VersionAdded: '0.9'
3507
- VersionChanged: '0.30'
3508
- EnforcedStyle: slashes
3509
- # slashes: Always use slashes.
3510
- # percent_r: Always use `%r`.
3511
- # mixed: Use slashes on single-line regexes, and `%r` on multi-line regexes.
3512
- SupportedStyles:
3513
- - slashes
3514
- - percent_r
3515
- - mixed
3516
- # If `false`, the cop will always recommend using `%r` if one or more slashes
3517
- # are found in the regexp string.
3518
- AllowInnerSlashes: false
3519
-
3520
- Style/RescueModifier:
3521
- Description: 'Avoid using rescue in its modifier form.'
3522
- StyleGuide: '#no-rescue-modifiers'
3523
- Enabled: true
3524
- VersionAdded: '0.9'
3525
- VersionChanged: '0.34'
3526
-
3527
- Style/RescueStandardError:
3528
- Description: 'Avoid rescuing without specifying an error class.'
3529
- Enabled: true
3530
- VersionAdded: '0.52'
3531
- EnforcedStyle: explicit
3532
- # implicit: Do not include the error class, `rescue`
3533
- # explicit: Require an error class `rescue StandardError`
3534
- SupportedStyles:
3535
- - implicit
3536
- - explicit
3537
-
3538
- Style/ReturnNil:
3539
- Description: 'Use return instead of return nil.'
3540
- Enabled: false
3541
- EnforcedStyle: return
3542
- SupportedStyles:
3543
- - return
3544
- - return_nil
3545
- VersionAdded: '0.50'
3546
-
3547
- Style/SafeNavigation:
3548
- Description: >-
3549
- This cop transforms usages of a method call safeguarded by
3550
- a check for the existence of the object to
3551
- safe navigation (`&.`).
3552
- Enabled: true
3553
- VersionAdded: '0.43'
3554
- VersionChanged: '0.77'
3555
- # Safe navigation may cause a statement to start returning `nil` in addition
3556
- # to whatever it used to return.
3557
- ConvertCodeThatCanStartToReturnNil: false
3558
- AllowedMethods:
3559
- - present?
3560
- - blank?
3561
- - presence
3562
- - try
3563
- - try!
3564
-
3565
- Style/Sample:
3566
- Description: >-
3567
- Use `sample` instead of `shuffle.first`,
3568
- `shuffle.last`, and `shuffle[Integer]`.
3569
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
3570
- Enabled: true
3571
- VersionAdded: '0.30'
3572
-
3573
- Style/SelfAssignment:
3574
- Description: >-
3575
- Checks for places where self-assignment shorthand should have
3576
- been used.
3577
- StyleGuide: '#self-assignment'
3578
- Enabled: true
3579
- VersionAdded: '0.19'
3580
- VersionChanged: '0.29'
3581
-
3582
- Style/Semicolon:
3583
- Description: "Don't use semicolons to terminate expressions."
3584
- StyleGuide: '#no-semicolon'
3585
- Enabled: true
3586
- VersionAdded: '0.9'
3587
- VersionChanged: '0.19'
3588
- # Allow `;` to separate several expressions on the same line.
3589
- AllowAsExpressionSeparator: false
3590
-
3591
- Style/Send:
3592
- Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.'
3593
- StyleGuide: '#prefer-public-send'
3594
- Enabled: false
3595
- VersionAdded: '0.33'
3596
-
3597
- Style/SignalException:
3598
- Description: 'Checks for proper usage of fail and raise.'
3599
- StyleGuide: '#prefer-raise-over-fail'
3600
- Enabled: true
3601
- VersionAdded: '0.11'
3602
- VersionChanged: '0.37'
3603
- EnforcedStyle: only_raise
3604
- SupportedStyles:
3605
- - only_raise
3606
- - only_fail
3607
- - semantic
3608
-
3609
- Style/SingleLineBlockParams:
3610
- Description: 'Enforces the names of some block params.'
3611
- Enabled: false
3612
- VersionAdded: '0.16'
3613
- VersionChanged: '0.47'
3614
- Methods:
3615
- - reduce:
3616
- - acc
3617
- - elem
3618
- - inject:
3619
- - acc
3620
- - elem
3621
-
3622
- Style/SingleLineMethods:
3623
- Description: 'Avoid single-line methods.'
3624
- StyleGuide: '#no-single-line-methods'
3625
- Enabled: true
3626
- VersionAdded: '0.9'
3627
- VersionChanged: '0.19'
3628
- AllowIfMethodIsEmpty: true
3629
-
3630
- Style/SpecialGlobalVars:
3631
- Description: 'Avoid Perl-style global variables.'
3632
- StyleGuide: '#no-cryptic-perlisms'
3633
- Enabled: true
3634
- VersionAdded: '0.13'
3635
- VersionChanged: '0.36'
3636
- SafeAutoCorrect: false
3637
- EnforcedStyle: use_english_names
3638
- SupportedStyles:
3639
- - use_perl_names
3640
- - use_english_names
3641
-
3642
- Style/StabbyLambdaParentheses:
3643
- Description: 'Check for the usage of parentheses around stabby lambda arguments.'
3644
- StyleGuide: '#stabby-lambda-with-args'
3645
- Enabled: true
3646
- VersionAdded: '0.35'
3647
- EnforcedStyle: require_parentheses
3648
- SupportedStyles:
3649
- - require_parentheses
3650
- - require_no_parentheses
3651
-
3652
- Style/StderrPuts:
3653
- Description: 'Use `warn` instead of `$stderr.puts`.'
3654
- StyleGuide: '#warn'
3655
- Enabled: true
3656
- VersionAdded: '0.51'
3657
-
3658
- Style/StringHashKeys:
3659
- Description: 'Prefer symbols instead of strings as hash keys.'
3660
- StyleGuide: '#symbols-as-keys'
3661
- Enabled: false
3662
- VersionAdded: '0.52'
3663
- VersionChanged: '0.75'
3664
- Safe: false
3665
-
3666
- Style/StringLiterals:
3667
- Description: 'Checks if uses of quotes match the configured preference.'
3668
- StyleGuide: '#consistent-string-literals'
3669
- Enabled: true
3670
- VersionAdded: '0.9'
3671
- VersionChanged: '0.36'
3672
- EnforcedStyle: single_quotes
3673
- SupportedStyles:
3674
- - single_quotes
3675
- - double_quotes
3676
- # If `true`, strings which span multiple lines using `\` for continuation must
3677
- # use the same type of quotes on each line.
3678
- ConsistentQuotesInMultiline: false
3679
-
3680
- Style/StringLiteralsInInterpolation:
3681
- Description: >-
3682
- Checks if uses of quotes inside expressions in interpolated
3683
- strings match the configured preference.
3684
- Enabled: true
3685
- VersionAdded: '0.27'
3686
- EnforcedStyle: single_quotes
3687
- SupportedStyles:
3688
- - single_quotes
3689
- - double_quotes
3690
-
3691
- Style/StringMethods:
3692
- Description: 'Checks if configured preferred methods are used over non-preferred.'
3693
- Enabled: false
3694
- VersionAdded: '0.34'
3695
- VersionChanged: '0.34.2'
3696
- # Mapping from undesired method to desired_method
3697
- # e.g. to use `to_sym` over `intern`:
3698
- #
3699
- # StringMethods:
3700
- # PreferredMethods:
3701
- # intern: to_sym
3702
- PreferredMethods:
3703
- intern: to_sym
3704
-
3705
- Style/Strip:
3706
- Description: 'Use `strip` instead of `lstrip.rstrip`.'
3707
- Enabled: true
3708
- VersionAdded: '0.36'
3709
-
3710
- Style/StructInheritance:
3711
- Description: 'Checks for inheritance from Struct.new.'
3712
- StyleGuide: '#no-extend-struct-new'
3713
- Enabled: true
3714
- VersionAdded: '0.29'
3715
-
3716
- Style/SymbolArray:
3717
- Description: 'Use %i or %I for arrays of symbols.'
3718
- StyleGuide: '#percent-i'
3719
- Enabled: true
3720
- VersionAdded: '0.9'
3721
- VersionChanged: '0.49'
3722
- EnforcedStyle: percent
3723
- MinSize: 2
3724
- SupportedStyles:
3725
- - percent
3726
- - brackets
3727
-
3728
- Style/SymbolLiteral:
3729
- Description: 'Use plain symbols instead of string symbols when possible.'
3730
- Enabled: true
3731
- VersionAdded: '0.30'
3732
-
3733
- Style/SymbolProc:
3734
- Description: 'Use symbols as procs instead of blocks when possible.'
3735
- Enabled: true
3736
- SafeAutoCorrect: false
3737
- VersionAdded: '0.26'
3738
- VersionChanged: '0.64'
3739
- # A list of method names to be ignored by the check.
3740
- # The names should be fairly unique, otherwise you'll end up ignoring lots of code.
3741
- IgnoredMethods:
3742
- - respond_to
3743
- - define_method
3744
-
3745
- Style/TernaryParentheses:
3746
- Description: 'Checks for use of parentheses around ternary conditions.'
3747
- Enabled: true
3748
- VersionAdded: '0.42'
3749
- VersionChanged: '0.46'
3750
- EnforcedStyle: require_no_parentheses
3751
- SupportedStyles:
3752
- - require_parentheses
3753
- - require_no_parentheses
3754
- - require_parentheses_when_complex
3755
- AllowSafeAssignment: true
3756
-
3757
- Style/TrailingBodyOnClass:
3758
- Description: 'Class body goes below class statement.'
3759
- Enabled: true
3760
- VersionAdded: '0.53'
3761
-
3762
- Style/TrailingBodyOnMethodDefinition:
3763
- Description: 'Method body goes below definition.'
3764
- Enabled: true
3765
- VersionAdded: '0.52'
3766
-
3767
- Style/TrailingBodyOnModule:
3768
- Description: 'Module body goes below module statement.'
3769
- Enabled: true
3770
- VersionAdded: '0.53'
3771
-
3772
- Style/TrailingCommaInArguments:
3773
- Description: 'Checks for trailing comma in argument lists.'
3774
- StyleGuide: '#no-trailing-params-comma'
3775
- Enabled: true
3776
- VersionAdded: '0.36'
3777
- # If `comma`, the cop requires a comma after the last argument, but only for
3778
- # parenthesized method calls where each argument is on its own line.
3779
- # If `consistent_comma`, the cop requires a comma after the last argument,
3780
- # for all parenthesized method calls with arguments.
3781
- EnforcedStyleForMultiline: no_comma
3782
- SupportedStylesForMultiline:
3783
- - comma
3784
- - consistent_comma
3785
- - no_comma
3786
-
3787
- Style/TrailingCommaInArrayLiteral:
3788
- Description: 'Checks for trailing comma in array literals.'
3789
- StyleGuide: '#no-trailing-array-commas'
3790
- Enabled: true
3791
- VersionAdded: '0.53'
3792
- # but only when each item is on its own line.
3793
- # If `consistent_comma`, the cop requires a comma after the last item of all
3794
- # non-empty array literals.
3795
- EnforcedStyleForMultiline: no_comma
3796
- SupportedStylesForMultiline:
3797
- - comma
3798
- - consistent_comma
3799
- - no_comma
3800
-
3801
- Style/TrailingCommaInHashLiteral:
3802
- Description: 'Checks for trailing comma in hash literals.'
3803
- Enabled: true
3804
- # If `comma`, the cop requires a comma after the last item in a hash,
3805
- # but only when each item is on its own line.
3806
- # If `consistent_comma`, the cop requires a comma after the last item of all
3807
- # non-empty hash literals.
3808
- EnforcedStyleForMultiline: no_comma
3809
- SupportedStylesForMultiline:
3810
- - comma
3811
- - consistent_comma
3812
- - no_comma
3813
- VersionAdded: '0.53'
3814
-
3815
- Style/TrailingMethodEndStatement:
3816
- Description: 'Checks for trailing end statement on line of method body.'
3817
- Enabled: true
3818
- VersionAdded: '0.52'
3819
-
3820
- Style/TrailingUnderscoreVariable:
3821
- Description: >-
3822
- Checks for the usage of unneeded trailing underscores at the
3823
- end of parallel variable assignment.
3824
- AllowNamedUnderscoreVariables: true
3825
- Enabled: true
3826
- VersionAdded: '0.31'
3827
- VersionChanged: '0.35'
3828
-
3829
- # `TrivialAccessors` requires exact name matches and doesn't allow
3830
- # predicated methods by default.
3831
- Style/TrivialAccessors:
3832
- Description: 'Prefer attr_* methods to trivial readers/writers.'
3833
- StyleGuide: '#attr_family'
3834
- Enabled: true
3835
- VersionAdded: '0.9'
3836
- VersionChanged: '0.77'
3837
- # When set to `false` the cop will suggest the use of accessor methods
3838
- # in situations like:
3839
- #
3840
- # def name
3841
- # @other_name
3842
- # end
3843
- #
3844
- # This way you can uncover "hidden" attributes in your code.
3845
- ExactNameMatch: true
3846
- AllowPredicates: true
3847
- # Allows trivial writers that don't end in an equal sign. e.g.
3848
- #
3849
- # def on_exception(action)
3850
- # @on_exception=action
3851
- # end
3852
- # on_exception :restart
3853
- #
3854
- # Commonly used in DSLs
3855
- AllowDSLWriters: false
3856
- IgnoreClassMethods: false
3857
- AllowedMethods:
3858
- - to_ary
3859
- - to_a
3860
- - to_c
3861
- - to_enum
3862
- - to_h
3863
- - to_hash
3864
- - to_i
3865
- - to_int
3866
- - to_io
3867
- - to_open
3868
- - to_path
3869
- - to_proc
3870
- - to_r
3871
- - to_regexp
3872
- - to_str
3873
- - to_s
3874
- - to_sym
3875
-
3876
- Style/UnlessElse:
3877
- Description: >-
3878
- Do not use unless with else. Rewrite these with the positive
3879
- case first.
3880
- StyleGuide: '#no-else-with-unless'
3881
- Enabled: true
3882
- VersionAdded: '0.9'
3883
-
3884
- Style/UnpackFirst:
3885
- Description: >-
3886
- Checks for accessing the first element of `String#unpack`
3887
- instead of using `unpack1`.
3888
- Enabled: true
3889
- VersionAdded: '0.54'
3890
-
3891
- Style/VariableInterpolation:
3892
- Description: >-
3893
- Don't interpolate global, instance and class variables
3894
- directly in strings.
3895
- StyleGuide: '#curlies-interpolate'
3896
- Enabled: true
3897
- VersionAdded: '0.9'
3898
- VersionChanged: '0.20'
3899
-
3900
- Style/WhenThen:
3901
- Description: 'Use when x then ... for one-line cases.'
3902
- StyleGuide: '#one-line-cases'
3903
- Enabled: true
3904
- VersionAdded: '0.9'
3905
-
3906
- Style/WhileUntilDo:
3907
- Description: 'Checks for redundant do after while or until.'
3908
- StyleGuide: '#no-multiline-while-do'
3909
- Enabled: true
3910
- VersionAdded: '0.9'
3911
-
3912
- Style/WhileUntilModifier:
3913
- Description: >-
3914
- Favor modifier while/until usage when you have a
3915
- single-line body.
3916
- StyleGuide: '#while-as-a-modifier'
3917
- Enabled: true
3918
- VersionAdded: '0.9'
3919
- VersionChanged: '0.30'
3920
-
3921
- Style/WordArray:
3922
- Description: 'Use %w or %W for arrays of words.'
3923
- StyleGuide: '#percent-w'
3924
- Enabled: true
3925
- VersionAdded: '0.9'
3926
- VersionChanged: '0.36'
3927
- EnforcedStyle: percent
3928
- SupportedStyles:
3929
- # percent style: %w(word1 word2)
3930
- - percent
3931
- # bracket style: ['word1', 'word2']
3932
- - brackets
3933
- # The `MinSize` option causes the `WordArray` rule to be ignored for arrays
3934
- # smaller than a certain size. The rule is only applied to arrays
3935
- # whose element count is greater than or equal to `MinSize`.
3936
- MinSize: 2
3937
- # The regular expression `WordRegex` decides what is considered a word.
3938
- WordRegex: !ruby/regexp '/\A(?:\p{Word}|\p{Word}-\p{Word}|\n|\t)+\z/'
3939
-
3940
- Style/YodaCondition:
3941
- Description: 'Forbid or enforce yoda conditions.'
3942
- Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
3943
- Enabled: true
3944
- EnforcedStyle: forbid_for_all_comparison_operators
3945
- SupportedStyles:
3946
- # check all comparison operators
3947
- - forbid_for_all_comparison_operators
3948
- # check only equality operators: `!=` and `==`
3949
- - forbid_for_equality_operators_only
3950
- # enforce yoda for all comparison operators
3951
- - require_for_all_comparison_operators
3952
- # enforce yoda only for equality operators: `!=` and `==`
3953
- - require_for_equality_operators_only
3954
- Safe: false
3955
- VersionAdded: '0.49'
3956
- VersionChanged: '0.75'
3957
-
3958
- Style/ZeroLengthPredicate:
3959
- Description: 'Use #empty? when testing for objects of length 0.'
3960
- Enabled: true
3961
- Safe: false
3962
- VersionAdded: '0.37'
3963
- VersionChanged: '0.39'