rubocop-rubomatic 1.0.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.adoc +10 -0
- data/LICENSE +22 -0
- data/README.adoc +87 -0
- data/config/bundler.yml +80 -0
- data/config/default.yml +16 -0
- data/config/gemspec.yml +2 -0
- data/config/gemspec_on.yml +74 -0
- data/config/layout.yml +1217 -0
- data/config/lint.yml +989 -0
- data/config/metrics.yml +120 -0
- data/config/migration.yml +6 -0
- data/config/naming.yml +316 -0
- data/config/performance.yml +266 -0
- data/config/rubocop.yml +36 -0
- data/config/rubomatic/layout.yml +4 -0
- data/config/rubomatic/rubocop.yml +5 -0
- data/config/rubomatic/style.yml +2 -0
- data/config/security.yml +53 -0
- data/config/style.yml +2545 -0
- data/docs/cops/layout/README.adoc +7 -0
- data/docs/cops/layout/multiline_array_line_breaks/README.adoc +44 -0
- data/docs/cops/style/README.adoc +7 -0
- data/docs/cops/style/disallowed_methods/README.adoc +28 -0
- data/lib/rubocop/cop/rubomatic/generator/cop_readme_injector.rb +51 -0
- data/lib/rubocop/cop/rubomatic/generator/dept_readme_injector.rb +114 -0
- data/lib/rubocop/cop/rubomatic/generator.rb +283 -0
- data/lib/rubocop/cop/rubomatic/layout/multiline_array_line_breaks.rb +28 -0
- data/lib/rubocop/cop/rubomatic/style/disallowed_methods.rb +50 -0
- data/lib/rubocop/cop/rubomatic_cops.rb +4 -0
- data/lib/rubocop/rubomatic/inject.rb +21 -0
- data/lib/rubocop/rubomatic/version.rb +7 -0
- data/lib/rubocop/rubomatic.rb +17 -0
- data/lib/rubocop-rubomatic.rb +12 -0
- metadata +108 -0
data/config/metrics.yml
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
Metrics/AbcSize:
|
2
|
+
Description: >-
|
3
|
+
A calculated magnitude based on number of assignments,
|
4
|
+
branches, and conditions.
|
5
|
+
Reference:
|
6
|
+
- http://c2.com/cgi/wiki?AbcMetric
|
7
|
+
- https://en.wikipedia.org/wiki/ABC_Software_Metric
|
8
|
+
Enabled: true
|
9
|
+
VersionAdded: '0.27'
|
10
|
+
VersionChanged: '1.5'
|
11
|
+
# The ABC size is a calculated magnitude, so this number can be an Integer or
|
12
|
+
# a Float.
|
13
|
+
AllowedMethods: [ ]
|
14
|
+
AllowedPatterns: [ ]
|
15
|
+
CountRepeatedAttributes: false
|
16
|
+
Max: 250
|
17
|
+
|
18
|
+
Metrics/BlockLength:
|
19
|
+
Description: 'Avoid long blocks with many lines.'
|
20
|
+
Enabled: true
|
21
|
+
VersionAdded: '0.44'
|
22
|
+
VersionChanged: '1.5'
|
23
|
+
CountComments: false # count full line comments?
|
24
|
+
Max: 500
|
25
|
+
CountAsOne:
|
26
|
+
- 'array'
|
27
|
+
- 'heredoc'
|
28
|
+
- 'hash'
|
29
|
+
AllowedMethods:
|
30
|
+
# By default, exclude the `#refine` method, as it tends to have larger
|
31
|
+
# associated blocks.
|
32
|
+
- refine
|
33
|
+
AllowedPatterns: [ ]
|
34
|
+
Exclude:
|
35
|
+
- '**/*.gemspec'
|
36
|
+
|
37
|
+
Metrics/BlockNesting:
|
38
|
+
Description: 'Avoid excessive block nesting.'
|
39
|
+
StyleGuide: '#three-is-the-number-thou-shalt-count'
|
40
|
+
Enabled: true
|
41
|
+
VersionAdded: '0.25'
|
42
|
+
VersionChanged: '0.47'
|
43
|
+
CountBlocks: false
|
44
|
+
Max: 10
|
45
|
+
|
46
|
+
Metrics/ClassLength:
|
47
|
+
Description: 'Avoid classes longer than 100 lines of code.'
|
48
|
+
Enabled: false
|
49
|
+
VersionAdded: '0.25'
|
50
|
+
VersionChanged: '0.87'
|
51
|
+
CountComments: false # count full line comments?
|
52
|
+
Max: 100
|
53
|
+
CountAsOne: [ ]
|
54
|
+
|
55
|
+
<% if RuboCop::Version.document_version.to_f >= 1.47 %>
|
56
|
+
Metrics/CollectionLiteralLength:
|
57
|
+
Description: Checks for `Array` or `Hash` literals with many entries.
|
58
|
+
Enabled: true
|
59
|
+
VersionAdded: '1.47'
|
60
|
+
LengthThreshold: 250
|
61
|
+
Exclude:
|
62
|
+
- lib/tasks/seeds
|
63
|
+
<% end %>
|
64
|
+
|
65
|
+
# Avoid complex methods.
|
66
|
+
Metrics/CyclomaticComplexity:
|
67
|
+
Description: >-
|
68
|
+
A complexity metric that is strongly correlated to the number
|
69
|
+
of test cases needed to validate a method.
|
70
|
+
Enabled: true
|
71
|
+
VersionAdded: '0.25'
|
72
|
+
VersionChanged: '0.81'
|
73
|
+
AllowedMethods: [ ]
|
74
|
+
AllowedPatterns: [ ]
|
75
|
+
Max: 150
|
76
|
+
|
77
|
+
Metrics/MethodLength:
|
78
|
+
Description: 'Avoid methods longer than 10 lines of code.'
|
79
|
+
StyleGuide: '#short-methods'
|
80
|
+
Enabled: true
|
81
|
+
VersionAdded: '0.25'
|
82
|
+
VersionChanged: '1.5'
|
83
|
+
CountComments: false # count full line comments?
|
84
|
+
Max: 350
|
85
|
+
CountAsOne:
|
86
|
+
- 'array'
|
87
|
+
- 'hash'
|
88
|
+
- 'heredoc'
|
89
|
+
AllowedMethods: [ ]
|
90
|
+
AllowedPatterns: [ ]
|
91
|
+
|
92
|
+
Metrics/ModuleLength:
|
93
|
+
Description: 'Avoid modules longer than 100 lines of code.'
|
94
|
+
Enabled: false
|
95
|
+
VersionAdded: '0.31'
|
96
|
+
VersionChanged: '0.87'
|
97
|
+
CountComments: false # count full line comments?
|
98
|
+
Max: 100
|
99
|
+
CountAsOne: [ ]
|
100
|
+
|
101
|
+
Metrics/ParameterLists:
|
102
|
+
Description: 'Avoid parameter lists longer than three or four parameters.'
|
103
|
+
StyleGuide: '#too-many-params'
|
104
|
+
Enabled: true
|
105
|
+
VersionAdded: '0.25'
|
106
|
+
VersionChanged: '1.5'
|
107
|
+
Max: 5
|
108
|
+
CountKeywordArgs: false
|
109
|
+
MaxOptionalParameters: 3
|
110
|
+
|
111
|
+
Metrics/PerceivedComplexity:
|
112
|
+
Description: >-
|
113
|
+
A complexity metric geared towards measuring complexity for a
|
114
|
+
human reader.
|
115
|
+
Enabled: true
|
116
|
+
VersionAdded: '0.25'
|
117
|
+
VersionChanged: '0.81'
|
118
|
+
AllowedMethods: [ ]
|
119
|
+
AllowedPatterns: [ ]
|
120
|
+
Max: 75
|
data/config/naming.yml
ADDED
@@ -0,0 +1,316 @@
|
|
1
|
+
Naming/AccessorMethodName:
|
2
|
+
Description: Check the naming of accessor methods for get_/set_.
|
3
|
+
StyleGuide: '#accessor_mutator_method_names'
|
4
|
+
Enabled: true
|
5
|
+
VersionAdded: '0.50'
|
6
|
+
|
7
|
+
Naming/AsciiIdentifiers:
|
8
|
+
Description: 'Use only ascii symbols in identifiers and constants.'
|
9
|
+
StyleGuide: '#english-identifiers'
|
10
|
+
Enabled: true
|
11
|
+
VersionAdded: '0.50'
|
12
|
+
VersionChanged: '0.87'
|
13
|
+
AsciiConstants: true
|
14
|
+
|
15
|
+
Naming/BinaryOperatorParameterName:
|
16
|
+
Description: 'When defining binary operators, name the argument other.'
|
17
|
+
StyleGuide: '#other-arg'
|
18
|
+
Enabled: true
|
19
|
+
VersionAdded: '0.50'
|
20
|
+
VersionChanged: '1.2'
|
21
|
+
|
22
|
+
Naming/BlockForwarding:
|
23
|
+
Description: 'Use anonymous block forwarding.'
|
24
|
+
StyleGuide: '#block-forwarding'
|
25
|
+
Enabled: <%= ENV['RUBY_MAJOR'].to_f >= 3.1 %>
|
26
|
+
VersionAdded: '1.24'
|
27
|
+
EnforcedStyle: anonymous
|
28
|
+
SupportedStyles:
|
29
|
+
- anonymous
|
30
|
+
- explicit
|
31
|
+
BlockForwardingName: block
|
32
|
+
|
33
|
+
Naming/BlockParameterName:
|
34
|
+
Description: >-
|
35
|
+
Checks for block parameter names that contain capital letters,
|
36
|
+
end in numbers, or do not meet a minimal length.
|
37
|
+
Enabled: true
|
38
|
+
VersionAdded: '0.53'
|
39
|
+
VersionChanged: '0.77'
|
40
|
+
# Parameter names may be equal to or greater than this value
|
41
|
+
MinNameLength: 1
|
42
|
+
AllowNamesEndingInNumbers: true
|
43
|
+
# Allowed names that will not register an offense
|
44
|
+
AllowedNames: [ ]
|
45
|
+
# Forbidden names that will register an offense
|
46
|
+
ForbiddenNames: [ ]
|
47
|
+
|
48
|
+
Naming/ClassAndModuleCamelCase:
|
49
|
+
Description: 'Use CamelCase for classes and modules.'
|
50
|
+
StyleGuide: '#camelcase-classes'
|
51
|
+
Enabled: true
|
52
|
+
VersionAdded: '0.50'
|
53
|
+
VersionChanged: '0.85'
|
54
|
+
# Allowed class/module names can be specified here.
|
55
|
+
# These can be full or part of the name.
|
56
|
+
AllowedNames:
|
57
|
+
- module_parent
|
58
|
+
|
59
|
+
Naming/ConstantName:
|
60
|
+
Description: 'Constants should use SCREAMING_SNAKE_CASE.'
|
61
|
+
StyleGuide: '#screaming-snake-case'
|
62
|
+
Enabled: true
|
63
|
+
VersionAdded: '0.50'
|
64
|
+
|
65
|
+
Naming/FileName:
|
66
|
+
Description: 'Use snake_case for source file names.'
|
67
|
+
StyleGuide: '#snake-case-files'
|
68
|
+
Enabled: true
|
69
|
+
VersionAdded: '0.50'
|
70
|
+
VersionChanged: '1.23'
|
71
|
+
# Camel case file names listed in `AllCops:Include` and all file names listed
|
72
|
+
# in `AllCops:Exclude` are excluded by default. Add extra excludes here.
|
73
|
+
Exclude: [ ]
|
74
|
+
# When `true`, requires that each source file should define a class or module
|
75
|
+
# with a name which matches the file name (converted to ... case).
|
76
|
+
# It further expects it to be nested inside modules which match the names
|
77
|
+
# of subdirectories in its path.
|
78
|
+
ExpectMatchingDefinition: false
|
79
|
+
# When `false`, changes the behavior of ExpectMatchingDefinition to match only
|
80
|
+
# whether each source file's class or module name matches the file name --
|
81
|
+
# not whether the nested module hierarchy matches the subdirectory path.
|
82
|
+
CheckDefinitionPathHierarchy: true
|
83
|
+
# paths that are considered root directories, for example "lib" in most ruby projects
|
84
|
+
# or "app/models" in rails projects
|
85
|
+
CheckDefinitionPathHierarchyRoots:
|
86
|
+
- lib
|
87
|
+
- spec
|
88
|
+
- test
|
89
|
+
- src
|
90
|
+
# If non-`nil`, expect all source file names to match the following regex.
|
91
|
+
# Only the file name itself is matched, not the entire file path.
|
92
|
+
# Use anchors as necessary if you want to match the entire name rather than
|
93
|
+
# just a part of it.
|
94
|
+
Regex: ~
|
95
|
+
# With `IgnoreExecutableScripts` set to `true`, this cop does not
|
96
|
+
# report offending filenames for executable scripts (i.e. source
|
97
|
+
# files with a shebang in the first line).
|
98
|
+
IgnoreExecutableScripts: true
|
99
|
+
AllowedAcronyms:
|
100
|
+
- CLI
|
101
|
+
- DSL
|
102
|
+
- ACL
|
103
|
+
- API
|
104
|
+
- ASCII
|
105
|
+
- CPU
|
106
|
+
- CSS
|
107
|
+
- DNS
|
108
|
+
- EOF
|
109
|
+
- GUID
|
110
|
+
- HTML
|
111
|
+
- HTTP
|
112
|
+
- HTTPS
|
113
|
+
- ID
|
114
|
+
- IP
|
115
|
+
- JSON
|
116
|
+
- LHS
|
117
|
+
- QPS
|
118
|
+
- RAM
|
119
|
+
- RHS
|
120
|
+
- RPC
|
121
|
+
- SLA
|
122
|
+
- SMTP
|
123
|
+
- SQL
|
124
|
+
- SSH
|
125
|
+
- TCP
|
126
|
+
- TLS
|
127
|
+
- TTL
|
128
|
+
- UDP
|
129
|
+
- UI
|
130
|
+
- UID
|
131
|
+
- UUID
|
132
|
+
- URI
|
133
|
+
- URL
|
134
|
+
- UTF8
|
135
|
+
- VM
|
136
|
+
- XML
|
137
|
+
- XMPP
|
138
|
+
- XSRF
|
139
|
+
- XSS
|
140
|
+
|
141
|
+
Naming/HeredocDelimiterCase:
|
142
|
+
Description: 'Use configured case for heredoc delimiters.'
|
143
|
+
StyleGuide: '#heredoc-delimiters'
|
144
|
+
Enabled: true
|
145
|
+
VersionAdded: '0.50'
|
146
|
+
VersionChanged: '1.2'
|
147
|
+
EnforcedStyle: uppercase
|
148
|
+
SupportedStyles:
|
149
|
+
- lowercase
|
150
|
+
- uppercase
|
151
|
+
|
152
|
+
Naming/HeredocDelimiterNaming:
|
153
|
+
Description: 'Use descriptive heredoc delimiters.'
|
154
|
+
StyleGuide: '#heredoc-delimiters'
|
155
|
+
Enabled: true
|
156
|
+
VersionAdded: '0.50'
|
157
|
+
ForbiddenDelimiters:
|
158
|
+
- !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/'
|
159
|
+
|
160
|
+
Naming/InclusiveLanguage:
|
161
|
+
Description: 'Recommend the use of inclusive language instead of problematic terms.'
|
162
|
+
Enabled: false
|
163
|
+
VersionAdded: '1.18'
|
164
|
+
VersionChanged: '1.21'
|
165
|
+
CheckIdentifiers: true
|
166
|
+
CheckConstants: true
|
167
|
+
CheckVariables: true
|
168
|
+
CheckStrings: false
|
169
|
+
CheckSymbols: true
|
170
|
+
CheckComments: true
|
171
|
+
CheckFilepaths: true
|
172
|
+
FlaggedTerms:
|
173
|
+
whitelist:
|
174
|
+
Regex: !ruby/regexp '/white[-_\s]?list/'
|
175
|
+
Suggestions:
|
176
|
+
- allowlist
|
177
|
+
- permit
|
178
|
+
blacklist:
|
179
|
+
Regex: !ruby/regexp '/black[-_\s]?list/'
|
180
|
+
Suggestions:
|
181
|
+
- denylist
|
182
|
+
- block
|
183
|
+
slave:
|
184
|
+
WholeWord: true
|
185
|
+
Suggestions: [ 'replica', 'secondary', 'follower' ]
|
186
|
+
|
187
|
+
Naming/MemoizedInstanceVariableName:
|
188
|
+
Description: >-
|
189
|
+
Memoized method name should match memo instance variable name.
|
190
|
+
Enabled: true
|
191
|
+
VersionAdded: '0.53'
|
192
|
+
VersionChanged: '1.2'
|
193
|
+
EnforcedStyleForLeadingUnderscores: disallowed
|
194
|
+
SupportedStylesForLeadingUnderscores:
|
195
|
+
- disallowed
|
196
|
+
- required
|
197
|
+
- optional
|
198
|
+
Safe: false
|
199
|
+
|
200
|
+
Naming/MethodName:
|
201
|
+
Description: 'Use the configured style when naming methods.'
|
202
|
+
StyleGuide: '#snake-case-symbols-methods-vars'
|
203
|
+
Enabled: true
|
204
|
+
VersionAdded: '0.50'
|
205
|
+
EnforcedStyle: snake_case
|
206
|
+
SupportedStyles:
|
207
|
+
- snake_case
|
208
|
+
- camelCase
|
209
|
+
# Method names matching patterns are always allowed.
|
210
|
+
#
|
211
|
+
# AllowedPatterns:
|
212
|
+
# - '\A\s*onSelectionBulkChange\s*'
|
213
|
+
# - '\A\s*onSelectionCleared\s*'
|
214
|
+
#
|
215
|
+
AllowedPatterns: [ ]
|
216
|
+
|
217
|
+
Naming/MethodParameterName:
|
218
|
+
Description: >-
|
219
|
+
Checks for method parameter names that contain capital letters,
|
220
|
+
end in numbers, or do not meet a minimal length.
|
221
|
+
Enabled: true
|
222
|
+
VersionAdded: '0.53'
|
223
|
+
VersionChanged: '0.77'
|
224
|
+
# Parameter names may be equal to or greater than this value
|
225
|
+
MinNameLength: 1
|
226
|
+
AllowNamesEndingInNumbers: true
|
227
|
+
# Allowed names that will not register an offense
|
228
|
+
AllowedNames:
|
229
|
+
- as
|
230
|
+
- at
|
231
|
+
- by
|
232
|
+
- cc
|
233
|
+
- db
|
234
|
+
- id
|
235
|
+
- if
|
236
|
+
- in
|
237
|
+
- io
|
238
|
+
- ip
|
239
|
+
- of
|
240
|
+
- 'on'
|
241
|
+
- os
|
242
|
+
- pp
|
243
|
+
- to
|
244
|
+
# Forbidden names that will register an offense
|
245
|
+
ForbiddenNames: [ ]
|
246
|
+
|
247
|
+
Naming/PredicateName:
|
248
|
+
Description: 'Check the names of predicate methods.'
|
249
|
+
StyleGuide: '#bool-methods-qmark'
|
250
|
+
Enabled: true
|
251
|
+
VersionAdded: '0.50'
|
252
|
+
VersionChanged: '0.77'
|
253
|
+
# Predicate name prefixes.
|
254
|
+
NamePrefix:
|
255
|
+
- is_
|
256
|
+
- has_
|
257
|
+
- have_
|
258
|
+
# Predicate name prefixes that should be removed.
|
259
|
+
ForbiddenPrefixes:
|
260
|
+
- is_
|
261
|
+
- has_
|
262
|
+
- have_
|
263
|
+
# Predicate names which, despite having a forbidden prefix, or no `?`,
|
264
|
+
# should still be accepted
|
265
|
+
AllowedMethods:
|
266
|
+
- is_a?
|
267
|
+
# Method definition macros for dynamically generated methods.
|
268
|
+
MethodDefinitionMacros:
|
269
|
+
- define_method
|
270
|
+
- define_singleton_method
|
271
|
+
# Exclude Rspec specs because there is a strong convention to write spec
|
272
|
+
# helpers in the form of `have_something` or `be_something`.
|
273
|
+
Exclude:
|
274
|
+
- 'spec/**/*'
|
275
|
+
|
276
|
+
Naming/RescuedExceptionsVariableName:
|
277
|
+
Description: 'Use consistent rescued exceptions variables naming.'
|
278
|
+
Enabled: true
|
279
|
+
VersionAdded: '0.67'
|
280
|
+
VersionChanged: '0.68'
|
281
|
+
PreferredName: e
|
282
|
+
|
283
|
+
Naming/VariableName:
|
284
|
+
Description: 'Use the configured style when naming variables.'
|
285
|
+
StyleGuide: '#snake-case-symbols-methods-vars'
|
286
|
+
Enabled: true
|
287
|
+
VersionAdded: '0.50'
|
288
|
+
VersionChanged: '1.8'
|
289
|
+
EnforcedStyle: snake_case
|
290
|
+
SupportedStyles:
|
291
|
+
- snake_case
|
292
|
+
- camelCase
|
293
|
+
AllowedIdentifiers: [ ]
|
294
|
+
AllowedPatterns: [ ]
|
295
|
+
|
296
|
+
Naming/VariableNumber:
|
297
|
+
Description: 'Use the configured style when numbering symbols, methods and variables.'
|
298
|
+
StyleGuide: '#snake-case-symbols-methods-vars-with-numbers'
|
299
|
+
Enabled: true
|
300
|
+
VersionAdded: '0.50'
|
301
|
+
VersionChanged: '1.4'
|
302
|
+
EnforcedStyle: normalcase
|
303
|
+
SupportedStyles:
|
304
|
+
- snake_case
|
305
|
+
- normalcase
|
306
|
+
- non_integer
|
307
|
+
CheckMethodNames: true
|
308
|
+
CheckSymbols: true
|
309
|
+
AllowedIdentifiers:
|
310
|
+
- capture3 # Open3.capture3
|
311
|
+
- iso8601 # Time#iso8601
|
312
|
+
- rfc1123_date # CGI.rfc1123_date
|
313
|
+
- rfc822 # Time#rfc822
|
314
|
+
- rfc2822 # Time#rfc2822
|
315
|
+
- rfc3339 # DateTime.rfc3339
|
316
|
+
AllowedPatterns: [ ]
|
@@ -0,0 +1,266 @@
|
|
1
|
+
require: rubocop-performance
|
2
|
+
|
3
|
+
Performance:
|
4
|
+
Enabled: false
|
5
|
+
|
6
|
+
Performance/BigDecimalWithNumericArgument:
|
7
|
+
Description: Convert numeric literal to string and pass it to `BigDecimal`.
|
8
|
+
Enabled: true
|
9
|
+
VersionAdded: '1.7'
|
10
|
+
|
11
|
+
Performance/ChainArrayAllocation:
|
12
|
+
Description: Instead of chaining array methods that allocate new arrays, mutate an
|
13
|
+
existing array.
|
14
|
+
Reference: https://twitter.com/schneems/status/1034123879978029057
|
15
|
+
Enabled: true
|
16
|
+
VersionAdded: '0.59'
|
17
|
+
|
18
|
+
Performance/CollectionLiteralInLoop:
|
19
|
+
Description: Extract Array and Hash literals outside of loops into local variables
|
20
|
+
or constants.
|
21
|
+
Enabled: true
|
22
|
+
VersionAdded: '1.8'
|
23
|
+
MinSize: 1
|
24
|
+
|
25
|
+
Performance/CompareWithBlock:
|
26
|
+
Description: Use `sort_by(&:foo)` instead of `sort { |a, b| a.foo <=> b.foo }`.
|
27
|
+
Enabled: true
|
28
|
+
VersionAdded: '0.46'
|
29
|
+
|
30
|
+
Performance/ConstantRegexp:
|
31
|
+
Description: Finds regular expressions with dynamic components that are all constants.
|
32
|
+
Enabled: true
|
33
|
+
VersionAdded: '1.9'
|
34
|
+
VersionChanged: '1.10'
|
35
|
+
|
36
|
+
Performance/Count:
|
37
|
+
Description: Use `count` instead of `{select,find_all,filter,reject}...{size,count,length}`.
|
38
|
+
SafeAutoCorrect: false
|
39
|
+
Enabled: true
|
40
|
+
VersionAdded: '0.31'
|
41
|
+
VersionChanged: '1.8'
|
42
|
+
|
43
|
+
Performance/DeletePrefix:
|
44
|
+
Description: Use `delete_prefix` instead of `gsub`.
|
45
|
+
Enabled: true
|
46
|
+
Safe: false
|
47
|
+
SafeMultiline: false
|
48
|
+
VersionAdded: '1.6'
|
49
|
+
VersionChanged: '1.11'
|
50
|
+
|
51
|
+
Performance/DeleteSuffix:
|
52
|
+
Description: Use `delete_suffix` instead of `gsub`.
|
53
|
+
Enabled: true
|
54
|
+
Safe: false
|
55
|
+
SafeMultiline: false
|
56
|
+
VersionAdded: '1.6'
|
57
|
+
VersionChanged: '1.11'
|
58
|
+
|
59
|
+
Performance/Detect:
|
60
|
+
Description: Use `detect` instead of `select.first`, `find_all.first`, `filter.first`,
|
61
|
+
`select.last`, `find_all.last`, and `filter.last`.
|
62
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code
|
63
|
+
SafeAutoCorrect: false
|
64
|
+
Enabled: true
|
65
|
+
VersionAdded: '0.30'
|
66
|
+
VersionChanged: '1.8'
|
67
|
+
|
68
|
+
Performance/DoubleStartEndWith:
|
69
|
+
Description: Use `str.{start,end}_with?(x, ..., y, ...)` instead of `str.{start,end}_with?(x,
|
70
|
+
...) || str.{start,end}_with?(y, ...)`.
|
71
|
+
Enabled: true
|
72
|
+
VersionAdded: '0.36'
|
73
|
+
VersionChanged: '0.48'
|
74
|
+
IncludeActiveSupportAliases: true
|
75
|
+
|
76
|
+
Performance/EndWith:
|
77
|
+
Description: Use `end_with?` instead of a regex match anchored to the end of a string.
|
78
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end
|
79
|
+
SafeAutoCorrect: false
|
80
|
+
Enabled: true
|
81
|
+
SafeMultiline: false
|
82
|
+
VersionAdded: '0.36'
|
83
|
+
VersionChanged: '1.10'
|
84
|
+
|
85
|
+
Performance/FixedSize:
|
86
|
+
Description: Do not compute the size of statically sized objects except in constants.
|
87
|
+
Enabled: true
|
88
|
+
VersionAdded: '0.35'
|
89
|
+
|
90
|
+
Performance/FlatMap:
|
91
|
+
Description: Use `Enumerable#flat_map` instead of `Enumerable#map...Array#flatten(1)`
|
92
|
+
or `Enumerable#collect..Array#flatten(1)`.
|
93
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code
|
94
|
+
Enabled: true
|
95
|
+
VersionAdded: '0.30'
|
96
|
+
EnabledForFlattenWithoutParams: true
|
97
|
+
|
98
|
+
Performance/InefficientHashSearch:
|
99
|
+
Description: Use `key?` or `value?` instead of `keys.include?` or `values.include?`.
|
100
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#hashkey-instead-of-hashkeysinclude-code
|
101
|
+
Enabled: true
|
102
|
+
VersionAdded: '0.56'
|
103
|
+
Safe: false
|
104
|
+
|
105
|
+
Performance/IoReadlines:
|
106
|
+
Description: Use `IO.each_line` (`IO#each_line`) instead of `IO.readlines` (`IO#readlines`).
|
107
|
+
Reference: https://docs.gitlab.com/ee/development/performance.html#reading-from-files-and-other-data-sources
|
108
|
+
Enabled: true
|
109
|
+
VersionAdded: '1.7'
|
110
|
+
|
111
|
+
Performance/MapCompact:
|
112
|
+
Description: Use `filter_map` instead of `collection.map(&:do_something).compact`.
|
113
|
+
Enabled: true
|
114
|
+
SafeAutoCorrect: false
|
115
|
+
VersionAdded: '1.11'
|
116
|
+
|
117
|
+
Performance/MethodObjectAsBlock:
|
118
|
+
Description: Use block explicitly instead of block-passing a method object.
|
119
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#normal-way-to-apply-method-vs-method-code
|
120
|
+
Enabled: true
|
121
|
+
VersionAdded: '1.9'
|
122
|
+
|
123
|
+
Performance/OpenStruct:
|
124
|
+
Description: Use `Struct` instead of `OpenStruct`.
|
125
|
+
Enabled: true
|
126
|
+
VersionAdded: '0.61'
|
127
|
+
Safe: false
|
128
|
+
|
129
|
+
Performance/RangeInclude:
|
130
|
+
Description: Use `Range#cover?` instead of `Range#include?` (or `Range#member?`).
|
131
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#cover-vs-include-code
|
132
|
+
Enabled: true
|
133
|
+
VersionAdded: '0.36'
|
134
|
+
VersionChanged: '1.7'
|
135
|
+
Safe: false
|
136
|
+
|
137
|
+
Performance/RedundantBlockCall:
|
138
|
+
Description: Use `yield` instead of `block.call`.
|
139
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#proccall-and-block-arguments-vs-yieldcode
|
140
|
+
Enabled: true
|
141
|
+
VersionAdded: '0.36'
|
142
|
+
|
143
|
+
Performance/RedundantEqualityComparisonBlock:
|
144
|
+
Description: Checks for uses `Enumerable#all?`, `Enumerable#any?`, `Enumerable#one?`,
|
145
|
+
or `Enumerable#none?` are compared with `===` or similar methods in block.
|
146
|
+
Reference: https://github.com/rails/rails/pull/41363
|
147
|
+
Enabled: true
|
148
|
+
Safe: false
|
149
|
+
VersionAdded: '1.10'
|
150
|
+
|
151
|
+
Performance/RedundantMatch:
|
152
|
+
Description: Use `=~` instead of `String#match` or `Regexp#match` in a context where
|
153
|
+
the returned `MatchData` is not needed.
|
154
|
+
Enabled: true
|
155
|
+
VersionAdded: '0.36'
|
156
|
+
|
157
|
+
Performance/RedundantMerge:
|
158
|
+
Description: Use Hash#[]=, rather than Hash#merge! with a single key-value pair.
|
159
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#hashmerge-vs-hash-code
|
160
|
+
Enabled: true
|
161
|
+
Safe: false
|
162
|
+
VersionAdded: '0.36'
|
163
|
+
VersionChanged: '1.11'
|
164
|
+
MaxKeyValuePairs: 2
|
165
|
+
|
166
|
+
Performance/RedundantSortBlock:
|
167
|
+
Description: Use `sort` instead of `sort { |a, b| a <=> b }`.
|
168
|
+
Enabled: true
|
169
|
+
VersionAdded: '1.7'
|
170
|
+
|
171
|
+
Performance/RedundantSplitRegexpArgument:
|
172
|
+
Description: Identifies places where `split` argument can be replaced from a deterministic
|
173
|
+
regexp to a string.
|
174
|
+
Enabled: true
|
175
|
+
VersionAdded: '1.10'
|
176
|
+
|
177
|
+
Performance/RedundantStringChars:
|
178
|
+
Description: Checks for redundant `String#chars`.
|
179
|
+
Enabled: true
|
180
|
+
VersionAdded: '1.7'
|
181
|
+
|
182
|
+
Performance/RegexpMatch:
|
183
|
+
Description: Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`,
|
184
|
+
`Regexp#===`, or `=~` when `MatchData` is not used.
|
185
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#regexp-vs-stringmatch-vs-string-vs-stringmatch-code-
|
186
|
+
Enabled: true
|
187
|
+
VersionAdded: '0.47'
|
188
|
+
|
189
|
+
Performance/ReverseEach:
|
190
|
+
Description: Use `reverse_each` instead of `reverse.each`.
|
191
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code
|
192
|
+
Enabled: true
|
193
|
+
VersionAdded: '0.30'
|
194
|
+
|
195
|
+
Performance/ReverseFirst:
|
196
|
+
Description: Use `last(n).reverse` instead of `reverse.first(n)`.
|
197
|
+
Enabled: true
|
198
|
+
VersionAdded: '1.7'
|
199
|
+
|
200
|
+
Performance/SelectMap:
|
201
|
+
Description: Use `filter_map` instead of `ary.select(&:foo).map(&:bar)`.
|
202
|
+
Enabled: true
|
203
|
+
VersionAdded: '1.11'
|
204
|
+
|
205
|
+
Performance/Size:
|
206
|
+
Description: Use `size` instead of `count` for counting the number of elements in
|
207
|
+
`Array` and `Hash`.
|
208
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#arraylength-vs-arraysize-vs-arraycount-code
|
209
|
+
Enabled: true
|
210
|
+
VersionAdded: '0.30'
|
211
|
+
|
212
|
+
Performance/SortReverse:
|
213
|
+
Description: Use `sort.reverse` instead of `sort { |a, b| b <=> a }`.
|
214
|
+
Enabled: true
|
215
|
+
VersionAdded: '1.7'
|
216
|
+
|
217
|
+
Performance/Squeeze:
|
218
|
+
Description: Use `squeeze('a')` instead of `gsub(/a+/, 'a')`.
|
219
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#remove-extra-spaces-or-other-contiguous-characters-code
|
220
|
+
Enabled: true
|
221
|
+
VersionAdded: '1.7'
|
222
|
+
|
223
|
+
Performance/StartWith:
|
224
|
+
Description: Use `start_with?` instead of a regex match anchored to the beginning
|
225
|
+
of a string.
|
226
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end
|
227
|
+
SafeAutoCorrect: false
|
228
|
+
Enabled: true
|
229
|
+
SafeMultiline: false
|
230
|
+
VersionAdded: '0.36'
|
231
|
+
VersionChanged: '1.10'
|
232
|
+
|
233
|
+
Performance/StringIdentifierArgument:
|
234
|
+
Description: Use symbol identifier argument instead of string identifier argument.
|
235
|
+
Enabled: true
|
236
|
+
VersionAdded: '1.13'
|
237
|
+
|
238
|
+
Performance/StringInclude:
|
239
|
+
Description: Use `String#include?` instead of a regex match with literal-only pattern.
|
240
|
+
Enabled: true
|
241
|
+
SafeAutoCorrect: false
|
242
|
+
VersionAdded: '1.7'
|
243
|
+
VersionChanged: '1.12'
|
244
|
+
|
245
|
+
Performance/StringReplacement:
|
246
|
+
Description: Use `tr` instead of `gsub` when you are replacing the same number of
|
247
|
+
characters. Use `delete` instead of `gsub` when you are deleting characters.
|
248
|
+
Reference: https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code
|
249
|
+
Enabled: true
|
250
|
+
VersionAdded: '0.33'
|
251
|
+
|
252
|
+
Performance/Sum:
|
253
|
+
Description: Use `sum` instead of a custom array summation.
|
254
|
+
SafeAutoCorrect: false
|
255
|
+
Reference: https://blog.bigbinary.com/2016/11/02/ruby-2-4-introduces-enumerable-sum.html
|
256
|
+
Enabled: true
|
257
|
+
VersionAdded: '1.8'
|
258
|
+
VersionChanged: '1.13'
|
259
|
+
OnlySumOrWithInitialValue: false
|
260
|
+
|
261
|
+
Performance/TimesMap:
|
262
|
+
Description: Checks for .times.map calls.
|
263
|
+
Enabled: true
|
264
|
+
SafeAutoCorrect: false
|
265
|
+
VersionAdded: '0.36'
|
266
|
+
VersionChanged: '1.13'
|