radius-spec 0.5.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +28 -0
- data/.github/workflows/reviewdog.yml +21 -0
- data/.rubocop.yml +9 -5
- data/CHANGELOG.md +98 -0
- data/Gemfile +2 -3
- data/README.md +5 -6
- data/benchmarks/call_vs_yield.rb +33 -2
- data/benchmarks/casecmp_vs_downcase.rb +488 -0
- data/benchmarks/cover_vs_include.rb +2 -2
- data/benchmarks/format_string.rb +3 -3
- data/benchmarks/hash_each.rb +305 -0
- data/benchmarks/hash_merge.rb +1 -1
- data/benchmarks/hash_transform.rb +455 -0
- data/benchmarks/style_hash_like_case.rb +285 -0
- data/benchmarks/unfreeze_string.rb +0 -2
- data/bin/ci +1 -1
- data/common_rubocop.yml +166 -45
- data/common_rubocop_rails.yml +47 -20
- data/lib/radius/spec/model_factory.rb +0 -2
- data/lib/radius/spec/rspec.rb +9 -0
- data/lib/radius/spec/vcr.rb +0 -2
- data/lib/radius/spec/version.rb +1 -1
- data/radius-spec.gemspec +8 -7
- metadata +42 -19
- data/.travis.yml +0 -17
- data/bin/ci-code-review +0 -28
@@ -0,0 +1,285 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Data values are taken from the Rubocop Style/HashLikeCase example
|
4
|
+
#
|
5
|
+
# https://docs.rubocop.org/rubocop/1.21/cops_style.html#styleredundantfileextensioninrequire
|
6
|
+
|
7
|
+
# Run from the command line: bundle exec ruby benchmarks/style_hash_like_case.rb
|
8
|
+
require_relative 'bm_setup'
|
9
|
+
|
10
|
+
display_benchmark_header
|
11
|
+
|
12
|
+
# rubocop:disable Style/HashLikeCase
|
13
|
+
def case_check3(value)
|
14
|
+
case value
|
15
|
+
when 'europe'
|
16
|
+
'http://eu.example.com'
|
17
|
+
when 'america'
|
18
|
+
'http://us.example.com'
|
19
|
+
when 'australia'
|
20
|
+
'http://au.example.com'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
HASH_CASE3 = {
|
25
|
+
'europe' => 'http://eu.example.com',
|
26
|
+
'america' => 'http://us.example.com',
|
27
|
+
'australia' => 'http://au.example.com',
|
28
|
+
}.freeze
|
29
|
+
|
30
|
+
def hash_check3(value)
|
31
|
+
HASH_CASE3[value]
|
32
|
+
end
|
33
|
+
|
34
|
+
section "Style/HashLikeCase(3) - First Match" do |bench|
|
35
|
+
bench.report("case") do |times|
|
36
|
+
i = 0
|
37
|
+
while i < times
|
38
|
+
case_check3('europe')
|
39
|
+
i += 1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
bench.report("hash") do |times|
|
44
|
+
i = 0
|
45
|
+
while i < times
|
46
|
+
hash_check3('europe')
|
47
|
+
i += 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
section "Style/HashLikeCase(3) - Last Match" do |bench|
|
53
|
+
bench.report("case") do |times|
|
54
|
+
i = 0
|
55
|
+
while i < times
|
56
|
+
case_check3('australia')
|
57
|
+
i += 1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
bench.report("hash") do |times|
|
62
|
+
i = 0
|
63
|
+
while i < times
|
64
|
+
hash_check3('australia')
|
65
|
+
i += 1
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
section "Style/HashLikeCase(3) - No Match" do |bench|
|
71
|
+
bench.report("case") do |times|
|
72
|
+
i = 0
|
73
|
+
while i < times
|
74
|
+
case_check3('any other place')
|
75
|
+
i += 1
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
bench.report("hash") do |times|
|
80
|
+
i = 0
|
81
|
+
while i < times
|
82
|
+
hash_check3('any other place')
|
83
|
+
i += 1
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def case_check5(value) # rubocop:disable Metrics/MethodLength
|
89
|
+
case value
|
90
|
+
when 'europe'
|
91
|
+
'http://eu.example.com'
|
92
|
+
when 'america'
|
93
|
+
'http://us.example.com'
|
94
|
+
when 'australia'
|
95
|
+
'http://au.example.com'
|
96
|
+
when 'china'
|
97
|
+
'http://cn.example.com'
|
98
|
+
when 'japan'
|
99
|
+
'http://jp.example.com'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
HASH_CASE5 = {
|
104
|
+
'europe' => 'http://eu.example.com',
|
105
|
+
'america' => 'http://us.example.com',
|
106
|
+
'australia' => 'http://au.example.com',
|
107
|
+
'china' => 'http://cn.example.com',
|
108
|
+
'japan' => 'http://jp.example.com',
|
109
|
+
}.freeze
|
110
|
+
|
111
|
+
def hash_check5(value)
|
112
|
+
HASH_CASE5[value]
|
113
|
+
end
|
114
|
+
|
115
|
+
section "Style/HashLikeCase(5) - First Match" do |bench|
|
116
|
+
bench.report("case") do |times|
|
117
|
+
i = 0
|
118
|
+
while i < times
|
119
|
+
case_check5('europe')
|
120
|
+
i += 1
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
bench.report("hash") do |times|
|
125
|
+
i = 0
|
126
|
+
while i < times
|
127
|
+
hash_check5('europe')
|
128
|
+
i += 1
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
section "Style/HashLikeCase(5) - Last Match" do |bench|
|
134
|
+
bench.report("case") do |times|
|
135
|
+
i = 0
|
136
|
+
while i < times
|
137
|
+
case_check5('japan')
|
138
|
+
i += 1
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
bench.report("hash") do |times|
|
143
|
+
i = 0
|
144
|
+
while i < times
|
145
|
+
hash_check5('japan')
|
146
|
+
i += 1
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
section "Style/HashLikeCase(5) - No Match" do |bench|
|
152
|
+
bench.report("case") do |times|
|
153
|
+
i = 0
|
154
|
+
while i < times
|
155
|
+
case_check5('any other place')
|
156
|
+
i += 1
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
bench.report("hash") do |times|
|
161
|
+
i = 0
|
162
|
+
while i < times
|
163
|
+
hash_check5('any other place')
|
164
|
+
i += 1
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# rubocop:enable Style/HashLikeCase
|
170
|
+
|
171
|
+
__END__
|
172
|
+
|
173
|
+
Usage of `case` appears to be more performant than a hash. However, both are
|
174
|
+
highly performant, so any difference is likely negligible compared to other
|
175
|
+
performance issues.
|
176
|
+
|
177
|
+
### Environment
|
178
|
+
|
179
|
+
Performance-M Dyno
|
180
|
+
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]
|
181
|
+
GC Disabled: true
|
182
|
+
|
183
|
+
### Test Cases
|
184
|
+
|
185
|
+
#### Style/HashLikeCase(3) - First Match
|
186
|
+
|
187
|
+
```
|
188
|
+
Warming up --------------------------------------
|
189
|
+
case 1.768M i/100ms
|
190
|
+
hash 1.710M i/100ms
|
191
|
+
Calculating -------------------------------------
|
192
|
+
case 17.630M (± 0.3%) i/s - 88.418M in 5.016811s
|
193
|
+
hash 17.044M (± 0.2%) i/s - 85.504M in 5.017564s
|
194
|
+
with 95.0% confidence
|
195
|
+
|
196
|
+
Comparison:
|
197
|
+
case: 17630438.8 i/s
|
198
|
+
hash: 17044158.0 i/s - 1.03x (± 0.00) slower
|
199
|
+
with 95.0% confidence
|
200
|
+
```
|
201
|
+
|
202
|
+
#### Style/HashLikeCase(3) - Last Match
|
203
|
+
|
204
|
+
```
|
205
|
+
Warming up --------------------------------------
|
206
|
+
case 1.714M i/100ms
|
207
|
+
hash 1.644M i/100ms
|
208
|
+
Calculating -------------------------------------
|
209
|
+
case 17.066M (± 0.7%) i/s - 85.718M in 5.027638s
|
210
|
+
hash 16.432M (± 0.1%) i/s - 82.205M in 5.002925s
|
211
|
+
with 95.0% confidence
|
212
|
+
|
213
|
+
Comparison:
|
214
|
+
case: 17066448.1 i/s
|
215
|
+
hash: 16432193.1 i/s - 1.04x (± 0.01) slower
|
216
|
+
with 95.0% confidence
|
217
|
+
```
|
218
|
+
|
219
|
+
#### Style/HashLikeCase(3) - No Match
|
220
|
+
|
221
|
+
```
|
222
|
+
Warming up --------------------------------------
|
223
|
+
case 1.706M i/100ms
|
224
|
+
hash 1.529M i/100ms
|
225
|
+
Calculating -------------------------------------
|
226
|
+
case 16.944M (± 0.8%) i/s - 85.300M in 5.041700s
|
227
|
+
hash 15.210M (± 0.5%) i/s - 76.428M in 5.028693s
|
228
|
+
with 95.0% confidence
|
229
|
+
|
230
|
+
Comparison:
|
231
|
+
case: 16944279.7 i/s
|
232
|
+
hash: 15210481.2 i/s - 1.11x (± 0.01) slower
|
233
|
+
with 95.0% confidence
|
234
|
+
```
|
235
|
+
|
236
|
+
#### Style/HashLikeCase(5) - First Match
|
237
|
+
|
238
|
+
```
|
239
|
+
Warming up --------------------------------------
|
240
|
+
case 1.738M i/100ms
|
241
|
+
hash 1.704M i/100ms
|
242
|
+
Calculating -------------------------------------
|
243
|
+
case 17.621M (± 0.5%) i/s - 88.642M in 5.033716s
|
244
|
+
hash 16.963M (± 0.5%) i/s - 85.198M in 5.025691s
|
245
|
+
with 95.0% confidence
|
246
|
+
|
247
|
+
Comparison:
|
248
|
+
case: 17621070.3 i/s
|
249
|
+
hash: 16963331.9 i/s - 1.04x (± 0.01) slower
|
250
|
+
with 95.0% confidence
|
251
|
+
```
|
252
|
+
|
253
|
+
#### Style/HashLikeCase(5) - Last Match
|
254
|
+
|
255
|
+
```
|
256
|
+
Warming up --------------------------------------
|
257
|
+
case 1.718M i/100ms
|
258
|
+
hash 1.634M i/100ms
|
259
|
+
Calculating -------------------------------------
|
260
|
+
case 17.170M (± 0.0%) i/s - 85.898M in 5.002845s
|
261
|
+
hash 16.357M (± 0.3%) i/s - 83.338M in 5.097011s
|
262
|
+
with 95.0% confidence
|
263
|
+
|
264
|
+
Comparison:
|
265
|
+
case: 17170019.6 i/s
|
266
|
+
hash: 16356675.5 i/s - 1.05x (± 0.00) slower
|
267
|
+
with 95.0% confidence
|
268
|
+
```
|
269
|
+
|
270
|
+
#### Style/HashLikeCase(5) - No Match
|
271
|
+
|
272
|
+
```
|
273
|
+
Warming up --------------------------------------
|
274
|
+
case 1.661M i/100ms
|
275
|
+
hash 1.501M i/100ms
|
276
|
+
Calculating -------------------------------------
|
277
|
+
case 16.518M (± 0.6%) i/s - 83.046M in 5.031835s
|
278
|
+
hash 14.963M (± 0.5%) i/s - 75.058M in 5.019838s
|
279
|
+
with 95.0% confidence
|
280
|
+
|
281
|
+
Comparison:
|
282
|
+
case: 16517985.2 i/s
|
283
|
+
hash: 14962803.1 i/s - 1.10x (± 0.01) slower
|
284
|
+
with 95.0% confidence
|
285
|
+
```
|
@@ -5,7 +5,6 @@ require_relative 'bm_setup'
|
|
5
5
|
|
6
6
|
display_benchmark_header
|
7
7
|
|
8
|
-
# rubocop:disable Performance/UnfreezeString
|
9
8
|
section "Unfreezing empty string" do |bench|
|
10
9
|
bench.report("String.new") do
|
11
10
|
String.new
|
@@ -34,7 +33,6 @@ section "Unfreezing string" do |bench|
|
|
34
33
|
STRING.dup
|
35
34
|
end
|
36
35
|
end
|
37
|
-
# rubocop:enable Performance/UnfreezeString
|
38
36
|
|
39
37
|
__END__
|
40
38
|
|
data/bin/ci
CHANGED
@@ -15,7 +15,7 @@ bin/rspec
|
|
15
15
|
# bundle-audit provides patch-level verification for Bundler
|
16
16
|
# https://github.com/rubysec/bundler-audit.
|
17
17
|
echo " ---> Running bundler-audit"
|
18
|
-
gem install --no-
|
18
|
+
gem install --no-document bundler-audit
|
19
19
|
bundle-audit check --update
|
20
20
|
|
21
21
|
# Run style checker
|
data/common_rubocop.yml
CHANGED
@@ -1,15 +1,26 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.7.0
|
3
|
+
# We choose to opt-in to new checks by default. This allows us to update
|
4
|
+
# version by version without having to worry about adding an entry for each
|
5
|
+
# new "enabled by default" check. If we want to jump multiple versions and
|
6
|
+
# wish to be notified of all the enw check, then we'll need to change
|
7
|
+
# `NewCops` to `pending.
|
8
|
+
NewCops: enable
|
3
9
|
Exclude:
|
4
10
|
# Exclude generated binstubs
|
5
11
|
- 'bin/bundle'
|
6
12
|
- 'bin/bundler-travis'
|
13
|
+
- 'bin/pronto'
|
7
14
|
- 'bin/pry'
|
15
|
+
- 'bin/radius-cli'
|
8
16
|
- 'bin/rake'
|
9
17
|
- 'bin/rspec'
|
10
18
|
- 'bin/rubocop'
|
11
19
|
- 'bin/travis'
|
20
|
+
- 'bin/webpack'
|
21
|
+
- 'bin/webpack-dev-server'
|
12
22
|
- 'bin/yard'
|
23
|
+
- 'bin/yarn'
|
13
24
|
# Exclude vendored content
|
14
25
|
- 'vendor/**/*'
|
15
26
|
|
@@ -25,6 +36,37 @@ Layout/AccessModifierIndentation:
|
|
25
36
|
similar to `rescue` and `ensure` in a method.
|
26
37
|
EnforcedStyle: outdent
|
27
38
|
|
39
|
+
# Rubocop 0.60.0 changed how it handled value alignments in this cop. This
|
40
|
+
# breaks our preference for wanting keys to be aligned, but allowing values to
|
41
|
+
# either use the `key` or `table` style:
|
42
|
+
#
|
43
|
+
# key_style = {
|
44
|
+
# key: :value,
|
45
|
+
# another: :value,
|
46
|
+
# yet_another: :value
|
47
|
+
# }
|
48
|
+
# table_style = {
|
49
|
+
# key: :value,
|
50
|
+
# another: :value
|
51
|
+
# yet_another: :value
|
52
|
+
# }
|
53
|
+
#
|
54
|
+
# This is logged with Rubocop: https://github.com/rubocop-hq/rubocop/issues/6410
|
55
|
+
#
|
56
|
+
# Until Rubocop resolves this we've decided to enforce the key style so that we
|
57
|
+
# do not lose all associated formatting checks. Additionally, in response to
|
58
|
+
# the referenced issue the Rubocop disables the alignment check by default. To
|
59
|
+
# continue using it we force enable it here.
|
60
|
+
#
|
61
|
+
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
62
|
+
# SupportedHashRocketStyles: key, separator, table
|
63
|
+
# SupportedColonStyles: key, separator, table
|
64
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
65
|
+
Layout/HashAlignment:
|
66
|
+
Enabled: true
|
67
|
+
EnforcedHashRocketStyle: key
|
68
|
+
EnforcedColonStyle: key
|
69
|
+
|
28
70
|
# Disabling this until it is fixed to support multi-line block chains using the
|
29
71
|
# semantic style.
|
30
72
|
#
|
@@ -43,17 +85,46 @@ Layout/BlockAlignment:
|
|
43
85
|
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
44
86
|
# SupportedStyles: consistent, consistent_relative_to_receiver,
|
45
87
|
# special_for_inner_method_call, special_for_inner_method_call_in_parentheses
|
46
|
-
|
88
|
+
#
|
89
|
+
# TODO: At some point this is split into both Layout/FirstArgumentIndentation
|
90
|
+
# and Layout/FirstParameterIndentation
|
91
|
+
Layout/FirstArgumentIndentation:
|
47
92
|
Enabled: false
|
48
93
|
|
49
|
-
#
|
50
|
-
#
|
51
|
-
# alternatives; even for Rails app.
|
94
|
+
# We generally prefer to use the default line length of 80. Though sometimes
|
95
|
+
# we just need a little extra space because it makes it easier to read.
|
52
96
|
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
|
56
|
-
|
97
|
+
# The only way to disable Rubocop for a single line is either to wrap the line
|
98
|
+
# with two comments or append the disable comment to the end of the line. For
|
99
|
+
# guard clauses, we tend to prefer trailing comments to avoid adding two lines
|
100
|
+
# just to disable a cop on one line.
|
101
|
+
#
|
102
|
+
# Sometimes comments include ASCII diagrams, flow charts, etc. These cannot
|
103
|
+
# always be reformatted to fit within the 80 column limit. Also, we write most
|
104
|
+
# comments in markdown format. Rubocop isn't very good at understanding when
|
105
|
+
# the line is long because of a URL in a markdown link. Instead of requiring
|
106
|
+
# additional comments to turn this cop off for comments we ignore any long
|
107
|
+
# lines which are only comments.
|
108
|
+
#
|
109
|
+
# There are also cases where for one valid reason or another we have a trailing
|
110
|
+
# comment that extends a little too far. We'd like to be able to ignore those
|
111
|
+
# as well. This _attempts_ to do that, however, as this uses simple regular
|
112
|
+
# expressions we can only attempt to match so much. We probably should change
|
113
|
+
# this for a node pattern matcher in the future.
|
114
|
+
#
|
115
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes,
|
116
|
+
# IgnoreCopDirectives, IgnoredPatterns.
|
117
|
+
# URISchemes: http, https
|
118
|
+
Layout/LineLength:
|
119
|
+
IgnoreCopDirectives: true
|
120
|
+
IgnoredPatterns:
|
121
|
+
# Leading comments
|
122
|
+
- '\A\s*#'
|
123
|
+
# Attempt at trailing comments
|
124
|
+
- '\A.{1,78}\s#\s.*\z'
|
125
|
+
Max: 100
|
126
|
+
Exclude:
|
127
|
+
- '**/*.gemspec'
|
57
128
|
|
58
129
|
# We tend to indent multi-line operation statements. I think this is because it
|
59
130
|
# tends to be the default style auto-formatted by VIM (which many of us use).
|
@@ -88,6 +159,31 @@ Lint/AmbiguousBlockAssociation:
|
|
88
159
|
Exclude:
|
89
160
|
- 'spec/**/*_spec.rb'
|
90
161
|
|
162
|
+
# We prefer to enforce a consistent usage for readability
|
163
|
+
#
|
164
|
+
# <<~SQL.strip
|
165
|
+
# bar
|
166
|
+
# SQL
|
167
|
+
#
|
168
|
+
# display(<<~SQL.strip)
|
169
|
+
# bar
|
170
|
+
# SQL
|
171
|
+
#
|
172
|
+
# Alternatively, refactoring the heredoc into a local also improves
|
173
|
+
# readability:
|
174
|
+
#
|
175
|
+
# custom_sql = <<~SQL
|
176
|
+
# bar
|
177
|
+
# SQL
|
178
|
+
# display(custom_sql.strip)
|
179
|
+
Lint/HeredocMethodCallPosition:
|
180
|
+
Enabled: true
|
181
|
+
|
182
|
+
# We prefer people suggesting people subclass `StandardError` for their custom
|
183
|
+
# exceptions as this is a relatively common Ruby idiom.
|
184
|
+
Lint/InheritException:
|
185
|
+
EnforcedStyle: standard_error
|
186
|
+
|
91
187
|
# Often with benchmarking we don't explicitly "use" a variable or return value.
|
92
188
|
# We simply need to perform the operation which generates said value for the
|
93
189
|
# benchmark.
|
@@ -97,9 +193,22 @@ Lint/Void:
|
|
97
193
|
Exclude:
|
98
194
|
- 'benchmarks/**/*'
|
99
195
|
|
196
|
+
Metrics/AbcSize:
|
197
|
+
# TODO: When we are able to upgrade to Rubocop 1.5.0 we want to enable the
|
198
|
+
# following `CountRepeatedAttributes` option. We often find the
|
199
|
+
# multi-references to the same object to be necessary for reability and that
|
200
|
+
# for our team it does not increase complexity.
|
201
|
+
#
|
202
|
+
# CountRepeatedAttributes: false
|
203
|
+
Max: 17
|
204
|
+
|
100
205
|
# Configuration parameters: CountComments, ExcludedMethods, Max.
|
101
206
|
# ExcludedMethods: refine
|
102
207
|
Metrics/BlockLength:
|
208
|
+
CountAsOne:
|
209
|
+
- 'array'
|
210
|
+
- 'hash'
|
211
|
+
- 'heredoc'
|
103
212
|
Exclude:
|
104
213
|
- '**/Rakefile'
|
105
214
|
- '**/*.rake'
|
@@ -107,42 +216,31 @@ Metrics/BlockLength:
|
|
107
216
|
- 'spec/**/*_spec.rb'
|
108
217
|
- 'spec/support/model_factories.rb'
|
109
218
|
ExcludedMethods:
|
219
|
+
- 'chdir'
|
110
220
|
- 'refine'
|
221
|
+
- 'Capybara.register_driver'
|
111
222
|
- 'RSpec.configure'
|
112
223
|
- 'VCR.configure'
|
113
224
|
|
114
|
-
# We
|
115
|
-
#
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
# this for a node pattern matcher in the future.
|
134
|
-
#
|
135
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes,
|
136
|
-
# IgnoreCopDirectives, IgnoredPatterns.
|
137
|
-
# URISchemes: http, https
|
138
|
-
Metrics/LineLength:
|
139
|
-
IgnoreCopDirectives: true
|
140
|
-
IgnoredPatterns:
|
141
|
-
# Leading comments
|
142
|
-
- '\A\s*#'
|
143
|
-
# Attempt at trailing comments
|
144
|
-
- '\A.{1,78}\s#\s.*\z'
|
145
|
-
Max: 100
|
225
|
+
# We want length related code metrics to count Hashs, Arrays, and
|
226
|
+
# Heredocs as one "line"
|
227
|
+
Metrics/ClassLength:
|
228
|
+
CountAsOne:
|
229
|
+
- 'array'
|
230
|
+
- 'hash'
|
231
|
+
- 'heredoc'
|
232
|
+
|
233
|
+
Metrics/ModuleLength:
|
234
|
+
CountAsOne:
|
235
|
+
- 'array'
|
236
|
+
- 'hash'
|
237
|
+
- 'heredoc'
|
238
|
+
|
239
|
+
Metrics/MethodLength:
|
240
|
+
CountAsOne:
|
241
|
+
- 'array'
|
242
|
+
- 'hash'
|
243
|
+
- 'heredoc'
|
146
244
|
|
147
245
|
# This is overly pedantic (only allowing `other` as the parameter name). Ruby
|
148
246
|
# core doesn't follow this consistently either. Looking at several classes
|
@@ -165,14 +263,14 @@ Naming/FileName:
|
|
165
263
|
# `EOF` is a common terminal abbreviate indicating end-of-file. We allow this
|
166
264
|
# for those heredocs which represent "file" text.
|
167
265
|
#
|
168
|
-
# Configuration parameters:
|
169
|
-
#
|
266
|
+
# Configuration parameters: ForbiddenDelimiters.
|
267
|
+
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
|
170
268
|
Naming/HeredocDelimiterNaming:
|
171
269
|
Details: |
|
172
270
|
|
173
271
|
Use meaningful delimiter names to provide context to the text. The only
|
174
272
|
allowed `EO*` variant if `EOF` which has specific meaning for file content.
|
175
|
-
|
273
|
+
ForbiddenDelimiters:
|
176
274
|
- !ruby/regexp '/(^|\s)(EO[A-EG-Z]{1}|END)(\s|$)/'
|
177
275
|
|
178
276
|
# It is generally a good idea to match the instance variable names with their
|
@@ -194,6 +292,13 @@ Naming/MemoizedInstanceVariableName:
|
|
194
292
|
acceptable.
|
195
293
|
EnforcedStyleForLeadingUnderscores: optional
|
196
294
|
|
295
|
+
# We don't really care about this check. Sometimes using something simple such
|
296
|
+
# as `err` is just fine. Other times it may improve readability to have a more
|
297
|
+
# descriptive name. We feel this is a personal judgement call and not something
|
298
|
+
# that needs to be enforced.
|
299
|
+
Naming/RescuedExceptionsVariableName:
|
300
|
+
Enabled: false
|
301
|
+
|
197
302
|
# `alias` behavior changes on scope. In general we expect the behavior to be
|
198
303
|
# that which is defined by `alias_method`.
|
199
304
|
#
|
@@ -243,7 +348,10 @@ Style/AsciiComments:
|
|
243
348
|
# - Prefer `{...}` over `do...end` for functional blocks.
|
244
349
|
#
|
245
350
|
# When the return value of the method receiving the block is important prefer
|
246
|
-
# `{
|
351
|
+
# `{...}` over `do...end`.
|
352
|
+
#
|
353
|
+
# Some people enjoy the compact readability of `{...}` for one-liners so we
|
354
|
+
# allow that style as well.
|
247
355
|
#
|
248
356
|
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
249
357
|
# SupportedStyles: line_count_based, semantic, braces_for_chaining
|
@@ -256,6 +364,7 @@ Style/BlockDelimiters:
|
|
256
364
|
|
257
365
|
When the return value of the method receiving the block is important prefer
|
258
366
|
`{..}` over `do..end`.
|
367
|
+
AllowBracesOnProceduralOneLiners: true
|
259
368
|
Enabled: true
|
260
369
|
EnforcedStyle: semantic
|
261
370
|
ProceduralMethods:
|
@@ -360,6 +469,13 @@ Style/EmptyCaseCondition:
|
|
360
469
|
Style/EmptyMethod:
|
361
470
|
EnforcedStyle: expanded
|
362
471
|
|
472
|
+
# Always require the pragma comment to be true
|
473
|
+
#
|
474
|
+
# Configuration parameters: EnforcedStyle.
|
475
|
+
# SupportedStyles: always, always_true, never
|
476
|
+
Style/FrozenStringLiteralComment:
|
477
|
+
EnforcedStyle: always_true
|
478
|
+
|
363
479
|
# Prefer symbol keys using the 1.9 hash syntax. However, when keys are mixed
|
364
480
|
# use a consistent mapping style; which generally means using hash rockets:
|
365
481
|
#
|
@@ -533,6 +649,11 @@ Style/RescueStandardError:
|
|
533
649
|
Avoid rescuing `Exception` as this may hide system errors.
|
534
650
|
EnforcedStyle: implicit
|
535
651
|
|
652
|
+
# We don't really care which style we use here and would prefer rubocop not
|
653
|
+
# complain about this.
|
654
|
+
Style/SlicingWithRange:
|
655
|
+
Enabled: false
|
656
|
+
|
536
657
|
# We generally prefer double quotes but many generators use single quotes. We
|
537
658
|
# don't view the performance difference to be all that much so we don't care
|
538
659
|
# if the style is mixed or double quotes are used for static strings.
|