radius-spec 0.9.0 → 0.12.0

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
  SHA256:
3
- metadata.gz: b6b5e94783c4ccbdf8bdf80de184fc19cd52ac9ee9f2a7f92329b261bdb00f59
4
- data.tar.gz: e492ea78f99e146011d2279e74fc1a3b1091aac13f311ef81324df43088ce440
3
+ metadata.gz: 74f0fd0a301ab4e74f86ed4aa183e94c3cbd5c6c795ea67cf24ac76ec2390a76
4
+ data.tar.gz: 43c5ba09b93ff99efb70b05e653dce5e7a7663bcfb567df964a20ee010eca7e9
5
5
  SHA512:
6
- metadata.gz: 83005750c2029b0a2765e176a8d819ed7984376c13ac17b881b442d055956ffd28548c32af56bb7298b1cc60d976c0c3cb25d10bbc2aed5bec0f4b16c72e8324
7
- data.tar.gz: 95d8183b73cfa36c5f3e01680bf6d2212016e2355d0a14ed95b7d38800b4d2e44ce9d08dbcdd0336bf6beb20731bfb3a834258a13b6ad357443918c4ec505ae8
6
+ metadata.gz: 62e586e2fdb6396509465475db8d78af5c0e04ae66e8f07a86a740c2537d403490bc55eae9326d4cf4412668b9fd7fc3d82362798fbe0a2f02b5113fc57f62f4
7
+ data.tar.gz: 5194070d9b33c0771224abcfb58f7e63a4869680df3bef1e606fb04d6720a8ed44f5cbba8c5d7aad973e8ebb3b5815486c6e6b62ac3b8cceac83d140d3a73b51
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "11:00"
8
+ open-pull-requests-limit: 10
9
+ # allow:
10
+ # - dependency-type: direct
data/.rubocop.yml CHANGED
@@ -1,11 +1,11 @@
1
1
  inherit_mode:
2
2
  merge:
3
3
  - Exclude
4
- - IgnoredPatterns
4
+ - AllowedPatterns
5
5
 
6
6
  inherit_from: common_rubocop_rails.yml
7
7
 
8
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
8
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
9
9
  # URISchemes: http, https
10
10
  Layout/LineLength:
11
11
  Exclude:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,102 @@
1
+ ## Development
2
+
3
+ [Full Changelog](https://github.com/RadiusNetworks/radius-spec/compare/v0.9.0...main)
4
+
5
+ ### Enhancements
6
+
7
+ - TODO
8
+
9
+ ### Bug Fixes
10
+
11
+ - TODO
12
+
13
+ ## 0.12.0 (August 3, 2022)
14
+
15
+ [Full Changelog](https://github.com/RadiusNetworks/radius-spec/compare/v0.12.0...0.12.0)
16
+
17
+ ### Enhancements
18
+
19
+ - Added Dependabot
20
+ - Upgraded VCR to 6.0
21
+ - Upgrade Rubocop Rails to 2.16
22
+ - Upgrade Rubocop to 1.33
23
+
24
+ ### Bug Fixes
25
+
26
+ None
27
+ ## 0.11.0 (January 21, 2022)
28
+
29
+ [Full Changelog](https://github.com/RadiusNetworks/radius-spec/compare/v0.10.0...0.11.0)
30
+
31
+ ### Enhancements
32
+
33
+ - Adjust common Rubocop configuration (Aaron Hill, Aaron Kromer, Ben Reynolds, James Nebeker, JC Avena, Sam Kim)
34
+ - Enable `Lint/NoReturnInBeginEndBlocks` by default
35
+ - Set `AllowHttpProtocol: false` for `Bundler/InsecureProtocolSource` cop
36
+ - Set `AllowNil: false` for `Lint/SuppressedException` cop
37
+ - Enable `Naming/BlockForwarding` cop for future Ruby 3.1 usage
38
+ - Disallow Ruby 3 `Style/NumberedParameters`
39
+ - Enable `Style/StringChars` by default
40
+ - Set `AllowMethodsWithArguments: true` for `Style/SymbolProc` cop
41
+ - Disallow combined `&&` and `||` in single `unless` clauses
42
+ - Enable `Naming/InclusiveLanguage` by default
43
+ - Adjust common Rubocop-Rails configuration (Alex Stone, James Nebeker, Aaron Kromer, Ben Reynolds, Sam Kim)
44
+ - Enable `Rails/EnvironmentVariableAccess` (`AllowReads` to `true`)
45
+ - Changed `Rails/FindBy`:`IgnoreWhereFirst` to `false`
46
+ - Enable `Rails/ReversibleMigrationMethodDefinition`
47
+ - Upgrade to Rubocop Rails 2.12.x (Alex Stone, James Nebeker, Aaron Kromer, Ben Reynolds, Sam Kim)
48
+ - Upgrade to Rubocop Rails 2.13.x (Alex Stone, James Nebeker, Aaron Kromer, Ben Reynolds, Sam Kim)
49
+ - Upgrade to Rubocop 1.25.x (Alex Stone, James Nebeker, Aaron Kromer, Ben Reynolds, Sam Kim, JC Avena, Eric Ouellette, Aaron Hill)
50
+ - Include model factory helpers in helper specs by default (Alex Stone, James Nebeker, Aaron Kromer, Ben Reynolds, JC Avena, Eric Ouellette)
51
+
52
+ ### Bug Fixes
53
+
54
+ None
55
+
56
+ ## 0.10.0 (October 18, 2021)
57
+
58
+ [Full Changelog](https://github.com/RadiusNetworks/radius-spec/compare/v0.9.0...v0.10.0)
59
+
60
+ ### Enhancements
61
+
62
+ - Upgrade to Rubocop Rails 2.8.x (Aaron Hill, Aaron Kromer, Ben Reynolds, James Nebeker, JC Avena, Sam Kim, Alex
63
+ Stone #30, #32)
64
+ - Adjust common Rubocop Rails configuration (Aaron Hill, Aaron Kromer, Ben Reynolds, James Nebeker, JC Avena,
65
+ Sam Kim, Alex Stone #30, #32)
66
+ - Enable `Rails/AttributeDefaultBlockValue` by default
67
+ - Enable `Rails/ArelStar` by default
68
+ - Enable `Rails/DefaultScope` by default
69
+ - Enable `Rails/FindById` by default
70
+ - Enable `Rails/PluckId` by default
71
+ - Enable `Rails/WhereEquals` by default
72
+ - Use the more aggressive `aggressive` check for `Rails/PluckInWhere`
73
+ - Use the more aggressive `aggressive` check for `Rails/ShortI18n`
74
+ - Switch to new `AllowedMethods` attribute name for `Rails/SkipsModelValidations`
75
+ - Disable `Rails/SquishedSQLHeredocs` by default
76
+ - Adjust common Rubocop configuration (Aaron Hill, Aaron Kromer, JC Avena, Sam
77
+ Kim #32, #34)
78
+ - Enable `Style/ClassMethodsDefinitions` by default
79
+ - Enable `Style/CombinableLoops` by default
80
+ - Enable `Style/KeywordParametersOrder` by default
81
+ - Enable `Style/RedundantSelfAssignment` by default
82
+ - Enable `Style/SoleNestedConditional` by default
83
+ - Enable `Lint/DuplicateRequire` by default
84
+ - Enable `Lint/EmptyFile` by default
85
+ - Enable `Lint/TrailingCommaInAttributeDeclaration` by default
86
+ - Enable `Lint/UselessMethodDefinition` by default
87
+ - Exclude the following testing methods from `Metrics/BlockLength`
88
+ - 'describe'
89
+ - 'shared_context'
90
+ - 'shared_examples'
91
+ - 'RSpec.describe'
92
+ - 'RSpec.shared_context'
93
+ - 'RSpec.shared_examples'
94
+
95
+ ### Bug Fixes
96
+
97
+ None
98
+
99
+
1
100
  ## 0.9.0 (September 30, 2021)
2
101
 
3
102
  [Full Changelog](https://github.com/RadiusNetworks/radius-spec/compare/v0.8.0...v0.9.0)
data/Gemfile CHANGED
@@ -23,6 +23,6 @@ group :documentation do
23
23
  end
24
24
 
25
25
  group :plugins do
26
- gem "vcr", "~> 4.0", require: false
26
+ gem "vcr", "~> 6.0", require: false
27
27
  gem "webmock", "~> 3.3", require: false
28
28
  end
data/README.md CHANGED
@@ -94,7 +94,7 @@ end
94
94
  Projects can inherit from the [base Rubocop config](.rubocop.yml). This can be
95
95
  accomplished by using either the remote raw URL or dependency gem formats. With
96
96
  either method we also strongly suggest setting the `inherit_mode` to `merge`
97
- for both `Exclude` and `IgnoredPatterns`. This way you can append additional
97
+ for both `Exclude` and `AllowedPatterns`. This way you can append additional
98
98
  exceptions without overwriting the defaults.
99
99
 
100
100
  #### Inherit from Gem (Recommended Method)
@@ -103,7 +103,7 @@ exceptions without overwriting the defaults.
103
103
  inherit_mode:
104
104
  merge:
105
105
  - Exclude
106
- - IgnoredPatterns
106
+ - AllowedPatterns
107
107
 
108
108
  inherit_gem:
109
109
  radius-spec:
@@ -118,7 +118,7 @@ inherit_gem:
118
118
  inherit_mode:
119
119
  merge:
120
120
  - Exclude
121
- - IgnoredPatterns
121
+ - AllowedPatterns
122
122
 
123
123
  # Available for projects which cannot include this gem (i.e. Ruby < 2.5)
124
124
  inherit_from:
@@ -154,7 +154,7 @@ inherit_from: .rubocop_todo.yml
154
154
  inherit_mode:
155
155
  merge:
156
156
  - Exclude
157
- - IgnoredPatterns
157
+ - AllowedPatterns
158
158
 
159
159
  Style/For:
160
160
  inherit_mode:
@@ -67,4 +67,4 @@ def display_benchmark_header
67
67
  puts "### Test Cases"
68
68
  end
69
69
 
70
- GC_DISABLED = as_boolean(ENV['GC_DISABLED'], default: false)
70
+ GC_DISABLED = as_boolean(ENV.fetch('GC_DISABLED', nil), default: false)
@@ -15,15 +15,15 @@ MULTI_TOKEN_HASH = {
15
15
  # rubocop:disable Style/FormatString
16
16
  section "Format String" do |bench|
17
17
  bench.report("String#%") do
18
- '%10s' % 'hoge' # rubocop:disable Style/FormatStringToken
18
+ '%10s' % 'hoge'
19
19
  end
20
20
 
21
21
  bench.report("format") do
22
- format '%10s', 'hoge' # rubocop:disable Style/FormatStringToken
22
+ format '%10s', 'hoge'
23
23
  end
24
24
 
25
25
  bench.report("sprintf") do
26
- sprintf '%10s', 'hoge' # rubocop:disable Style/FormatStringToken
26
+ sprintf '%10s', 'hoge'
27
27
  end
28
28
  end
29
29
  # rubocop:enable Style/FormatString
@@ -13,12 +13,12 @@ end
13
13
 
14
14
  # Bad per Rubocop
15
15
  def hash_transform_key_hash_collect(hash)
16
- Hash[hash.collect { |k, v| [k + 100, v] }]
16
+ Hash[hash.collect { |k, v| [k + 100, v] }] # rubocop:disable Style/HashConversion
17
17
  end
18
18
 
19
19
  # Bad per Rubocop
20
20
  def hash_transform_key_map_to_h(hash)
21
- hash.map { |k, v| [k + 100, v] }.to_h
21
+ hash.map { |k, v| [k + 100, v] }.to_h # rubocop:disable Style/MapToHash
22
22
  end
23
23
 
24
24
  # Bad per Rubocop
@@ -73,12 +73,12 @@ end
73
73
 
74
74
  # Bad per Rubocop
75
75
  def hash_transform_value_hash_collect(hash)
76
- Hash[hash.collect { |k, v| [k, v + 100] }]
76
+ Hash[hash.collect { |k, v| [k, v + 100] }] # rubocop:disable Style/HashConversion
77
77
  end
78
78
 
79
79
  # Bad per Rubocop
80
80
  def hash_transform_value_map_to_h(hash)
81
- hash.map { |k, v| [k, v + 100] }.to_h
81
+ hash.map { |k, v| [k, v + 100] }.to_h # rubocop:disable Style/MapToHash
82
82
  end
83
83
 
84
84
  # Bad per Rubocop
data/bin/bundle ADDED
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||=
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version
67
+ end
68
+
69
+ def bundler_requirement
70
+ return "#{Gem::Requirement.default}.a" unless bundler_version
71
+
72
+ bundler_gem_version = Gem::Version.new(bundler_version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
+
78
+ requirement += ".a" if bundler_gem_version.prerelease?
79
+
80
+ requirement
81
+ end
82
+
83
+ def load_bundler!
84
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
85
+
86
+ activate_bundler
87
+ end
88
+
89
+ def activate_bundler
90
+ gem_error = activation_error_handling do
91
+ gem "bundler", bundler_requirement
92
+ end
93
+ return if gem_error.nil?
94
+ require_error = activation_error_handling do
95
+ require "bundler/version"
96
+ end
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99
+ exit 42
100
+ end
101
+
102
+ def activation_error_handling
103
+ yield
104
+ nil
105
+ rescue StandardError, LoadError => e
106
+ e
107
+ end
108
+ end
109
+
110
+ m.load_bundler!
111
+
112
+ if m.invoked_as_script?
113
+ load Gem.bin_path("bundler", "bundle")
114
+ end
data/common_rubocop.yml CHANGED
@@ -4,7 +4,7 @@ AllCops:
4
4
  # version by version without having to worry about adding an entry for each
5
5
  # new "enabled by default" check. If we want to jump multiple versions and
6
6
  # wish to be notified of all the enw check, then we'll need to change
7
- # `NewCops` to `pending.
7
+ # `NewCops` to `pending`.
8
8
  NewCops: enable
9
9
  Exclude:
10
10
  # Exclude generated binstubs
@@ -24,6 +24,11 @@ AllCops:
24
24
  # Exclude vendored content
25
25
  - 'vendor/**/*'
26
26
 
27
+ # We would like to disallow http for bundler sources and enforce https
28
+ # as it is more secure.
29
+ Bundler/InsecureProtocolSource:
30
+ AllowHttpProtocol: false
31
+
27
32
  # We prefer outdented access modifiers as we feel they provide demarcation of
28
33
  # the class similar to `rescue` and `ensure` in a method.
29
34
  #
@@ -36,6 +41,18 @@ Layout/AccessModifierIndentation:
36
41
  similar to `rescue` and `ensure` in a method.
37
42
  EnforcedStyle: outdent
38
43
 
44
+ # This cop checks whether the end keyword of begin is aligned properly.
45
+ #
46
+ # Two modes are supported through the EnforcedStyleAlignWith configuration parameter. If it’s set to
47
+ # begin, the end shall be aligned with the begin keyword. We chose this to be consistent with our if
48
+ # statement styles, if you want the end to be aligned with the start of the line just put the begin
49
+ # on the next line.
50
+ #
51
+ # Configuration parameters: EnforcedStyleAlignWith
52
+ # SupportedStyles: start_of_line, begin
53
+ Layout/BeginEndAlignment:
54
+ EnforcedStyleAlignWith: begin
55
+
39
56
  # Rubocop 0.60.0 changed how it handled value alignments in this cop. This
40
57
  # breaks our preference for wanting keys to be aligned, but allowing values to
41
58
  # either use the `key` or `table` style:
@@ -113,11 +130,11 @@ Layout/FirstArgumentIndentation:
113
130
  # this for a node pattern matcher in the future.
114
131
  #
115
132
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes,
116
- # IgnoreCopDirectives, IgnoredPatterns.
133
+ # IgnoreCopDirectives, AllowedPatterns.
117
134
  # URISchemes: http, https
118
135
  Layout/LineLength:
119
136
  IgnoreCopDirectives: true
120
- IgnoredPatterns:
137
+ AllowedPatterns:
121
138
  # Leading comments
122
139
  - '\A\s*#'
123
140
  # Attempt at trailing comments
@@ -155,6 +172,18 @@ Layout/MultilineOperationIndentation:
155
172
  # }.to change {
156
173
  # object.state
157
174
  # }
175
+ #
176
+ # WARNING TO FUTURE READERS (future being after 2021-12-10):
177
+ # We tried to allowlist certain methods using the IgnoredMethods option (introduced 1.13.0),
178
+ # and Rubocop successfully ignored `change` and `not_change` constructions, but it flag false
179
+ # positives against code like
180
+ #
181
+ # expect { something }
182
+ # .to enqueue_job(SomeJobClass)
183
+ # .with { custom expectations about the enqueued payload }
184
+ #
185
+ # no matter what combination of `enqueue_job` and `with` we tried to add to the IgnoredMethods
186
+ # array. We suspect the AST matching is somewhat half-baked.
158
187
  Lint/AmbiguousBlockAssociation:
159
188
  Exclude:
160
189
  - 'spec/**/*_spec.rb'
@@ -184,6 +213,10 @@ Lint/HeredocMethodCallPosition:
184
213
  Lint/InheritException:
185
214
  EnforcedStyle: standard_error
186
215
 
216
+ # Make developers explain themselves in a comment if they want their rescue block to do nothing.
217
+ Lint/SuppressedException:
218
+ AllowNil: false
219
+
187
220
  # Often with benchmarking we don't explicitly "use" a variable or return value.
188
221
  # We simply need to perform the operation which generates said value for the
189
222
  # benchmark.
@@ -194,16 +227,11 @@ Lint/Void:
194
227
  - 'benchmarks/**/*'
195
228
 
196
229
  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
230
+ CountRepeatedAttributes: false
203
231
  Max: 17
204
232
 
205
- # Configuration parameters: CountComments, ExcludedMethods, Max.
206
- # ExcludedMethods: refine
233
+ # Configuration parameters: CountComments, IgnoredMethods, Max.
234
+ # IgnoredMethods: refine
207
235
  Metrics/BlockLength:
208
236
  CountAsOne:
209
237
  - 'array'
@@ -215,11 +243,17 @@ Metrics/BlockLength:
215
243
  - 'spec/spec_helper.rb'
216
244
  - 'spec/**/*_spec.rb'
217
245
  - 'spec/support/model_factories.rb'
218
- ExcludedMethods:
246
+ IgnoredMethods:
219
247
  - 'chdir'
248
+ - 'describe'
220
249
  - 'refine'
250
+ - 'shared_context'
251
+ - 'shared_examples'
221
252
  - 'Capybara.register_driver'
222
253
  - 'RSpec.configure'
254
+ - 'RSpec.describe'
255
+ - 'RSpec.shared_context'
256
+ - 'RSpec.shared_examples'
223
257
  - 'VCR.configure'
224
258
 
225
259
  # We want length related code metrics to count Hashs, Arrays, and
@@ -250,6 +284,21 @@ Metrics/MethodLength:
250
284
  Naming/BinaryOperatorParameterName:
251
285
  Enabled: false
252
286
 
287
+ # We don't need this configured just yet, because we dont have any applications on
288
+ # Ruby 3.1, but pre-emptively, we want to configure this to prefer the explicit style.
289
+ #
290
+ # bad
291
+ # def foo(&)
292
+ # bar(&)
293
+ # end
294
+
295
+ # good
296
+ # def foo(&block)
297
+ # bar(&block)
298
+ # end
299
+ Naming/BlockForwarding:
300
+ EnforcedStyle: explicit
301
+
253
302
  # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
254
303
  # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
255
304
  Naming/FileName:
@@ -339,6 +388,9 @@ Style/AndOr:
339
388
  # These days most people have editors which support unicode and other
340
389
  # non-ASCII characters.
341
390
  #
391
+ # In version 1.21.0, this is disabled by default. We've chosen to leave
392
+ # it in the config, in case it changes in future versions.
393
+ #
342
394
  # Configuration parameters: AllowedChars.
343
395
  Style/AsciiComments:
344
396
  Enabled: false
@@ -395,6 +447,15 @@ Style/BlockDelimiters:
395
447
  - proc
396
448
  - it
397
449
 
450
+ # As a team we prefer the more explicit `def self.method_name` style. We find
451
+ # the explicitness easier to read and grep for on the CLI.
452
+ #
453
+ # Configuration parameters: EnforcedStyle.
454
+ # SupportedStyles: def_self, self_class
455
+ Style/ClassMethodsDefinitions:
456
+ Enabled: true
457
+ EnforcedStyle: def_self
458
+
398
459
  # Prefer `Time` over `DateTime`.
399
460
  #
400
461
  # While these are not necessarily interchangeable we prefer `Time`. According
@@ -476,6 +537,11 @@ Style/EmptyMethod:
476
537
  Style/FrozenStringLiteralComment:
477
538
  EnforcedStyle: always_true
478
539
 
540
+ # If we're using consecutive conditionals we probably know what we're doing. The good thing is this
541
+ # cop will still flag consecutive conditionals that are identical.
542
+ Style/GuardClause:
543
+ AllowConsecutiveConditionals: true
544
+
479
545
  # Prefer symbol keys using the 1.9 hash syntax. However, when keys are mixed
480
546
  # use a consistent mapping style; which generally means using hash rockets:
481
547
  #
@@ -496,6 +562,7 @@ Style/HashSyntax:
496
562
  Prefer symbol keys using the 1.9 hash syntax. However, when keys are mixed
497
563
  use a consistent mapping style; which generally means using hash rockets.
498
564
  EnforcedStyle: ruby19_no_mixed_keys
565
+ EnforcedShorthandSyntax: either
499
566
 
500
567
  # As part of our semantic style we generally use the literal `-> { }` format to
501
568
  # indicate this is a function with a return value we care about. As this cop
@@ -526,6 +593,11 @@ Style/MethodCalledOnDoEndBlock:
526
593
  Style/MultilineBlockChain:
527
594
  Enabled: false
528
595
 
596
+ # Disallowing numbered parameter usage because we dont prefer this style.
597
+ # We would rather name the paramaters to clearly communicate intent.
598
+ Style/NumberedParameters:
599
+ EnforcedStyle: disallow
600
+
529
601
  # Context for this cop is too dependent.
530
602
  #
531
603
  # Often using the numeric comparison is faster. Also, depending on the context
@@ -542,6 +614,12 @@ Style/MultilineBlockChain:
542
614
  Style/NumericPredicate:
543
615
  Enabled: false
544
616
 
617
+ # As a general rule, we want to be explicit here instead of requiring readers
618
+ # of our code to know what the default arguments to methods like `#join` and
619
+ # and `#split` so we disable this cop here.
620
+ Style/RedundantArgument:
621
+ Enabled: false
622
+
545
623
  # In Ruby every method returns a value. Implicitly this is the value of the
546
624
  # last line of the method. This means using `return` is often redundant.
547
625
  # However, there isn't anything inherently wrong about doing so. In fact, in
@@ -654,6 +732,15 @@ Style/RescueStandardError:
654
732
  Style/SlicingWithRange:
655
733
  Enabled: false
656
734
 
735
+ # We want to turn this cop on so that rubocop can yell at us instead of Aaron
736
+ # yelling at us.
737
+ Style/StaticClass:
738
+ Enabled: true
739
+
740
+ # Enable Style/StringChars
741
+ Style/StringChars:
742
+ Enabled: true
743
+
657
744
  # We generally prefer double quotes but many generators use single quotes. We
658
745
  # don't view the performance difference to be all that much so we don't care
659
746
  # if the style is mixed or double quotes are used for static strings.
@@ -684,6 +771,13 @@ Style/StringLiteralsInInterpolation:
684
771
  Style/SymbolArray:
685
772
  MinSize: 3
686
773
 
774
+ # Allow either
775
+ # something.do_something(foo, &:bar)
776
+ # or
777
+ # something.do_something(foo) { |s| s.bar }
778
+ Style/SymbolProc:
779
+ AllowMethodsWithArguments: true
780
+
687
781
  # When ternaries become complex they can be difficult to read due to increased
688
782
  # cognitive load parsing the expression. Cognitive load can increase further
689
783
  # when assignment is involved.
@@ -746,6 +840,11 @@ Style/TrailingCommaInHashLiteral:
746
840
  simplifies adding, removing, and re-arranging the elements.
747
841
  EnforcedStyleForMultiline: consistent_comma
748
842
 
843
+ # Don't combine && & || inside the same `unless` guard clause.
844
+ Style/UnlessLogicalOperators:
845
+ Enabled: true
846
+ EnforcedStyle: forbid_mixed_logical_operators
847
+
749
848
  # We don't feel too strongly about percent vs bracket array style. We tend to
750
849
  # use the percent style, which also happens to be Rubocop's default. So for
751
850
  # pedantic consistency we'll enforce this.
@@ -765,3 +864,7 @@ Style/WordArray:
765
864
  # SupportedStyles: all_comparison_operators, equality_operators_only
766
865
  Style/YodaCondition:
767
866
  Enabled: false
867
+
868
+ # Disabled in 1.21.0. Radius Networks has chosen to enable it.
869
+ Naming/InclusiveLanguage:
870
+ Enabled: true
@@ -3,7 +3,7 @@ require: rubocop-rails
3
3
  inherit_mode:
4
4
  merge:
5
5
  - Exclude
6
- - IgnoredPatterns
6
+ - AllowedPatterns
7
7
 
8
8
  inherit_from: common_rubocop.yml
9
9
 
@@ -26,10 +26,10 @@ Style/Documentation:
26
26
  # Rails foreign keys and indexes can get long. We want to ignore our annotation
27
27
  # comments which are for these entries.
28
28
  #
29
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
29
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
30
30
  # URISchemes: http, https
31
31
  Layout/LineLength:
32
- IgnoredPatterns:
32
+ AllowedPatterns:
33
33
  - '\A# fk_rails_'
34
34
  - '\A# index_'
35
35
 
@@ -106,19 +106,39 @@ Rails/ApplicationRecord:
106
106
  Rails/CreateTableWithTimestamps:
107
107
  Enabled: false
108
108
 
109
+ # This cop looks for uses of default_scope because named scopes are preferred:
110
+ # https://rails.rubystyle.guide/#named-scopes
111
+ Rails/DefaultScope:
112
+ Enabled: true
113
+
114
+ # We were originally going to disable this, but after much discussion agreed that enabling
115
+ # this cop with AllowReads: true should be relatively painless.
116
+ Rails/EnvironmentVariableAccess:
117
+ Enabled: true
118
+ AllowReads: true
119
+
109
120
  # Usage of `find_by` is more expressive of intent than `where.first`. We should
110
121
  # check all app code, not just the models to improve intent expression.
111
122
  #
112
123
  # Since rake tasks often live in `lib` we also check all of lib as well.
113
124
  #
125
+ # We are also disabling the default IgnoreWhereFirst that was added in version
126
+ # 2.11
127
+ #
114
128
  # Configuration parameters: Include.
115
129
  # Include: app/models/**/*.rb
116
130
  Rails/FindBy:
117
131
  Enabled: true
132
+ IgnoreWhereFirst: false
118
133
  Include:
119
134
  - 'app/**/*.rb'
120
135
  - 'lib/**/*.rb'
121
136
 
137
+ # This cop enforces that ActiveRecord#find is used instead of where.take!, find_by!, and find_by_id!
138
+ # to retrieve a single record by primary key when you expect it to be found.
139
+ Rails/FindById:
140
+ Enabled: true
141
+
122
142
  # Usage of `each` for large datasets can be a performance issue; specially a
123
143
  # drain on system memory. When possible it's better to use `find_each` so that
124
144
  # chunks of data are evaluated at a time.
@@ -174,6 +194,25 @@ Rails/IndexBy:
174
194
  Rails/IndexWith:
175
195
  Enabled: false
176
196
 
197
+ # This would be extremely hard to implement with our app
198
+ Rails/I18nLocaleTexts:
199
+ Enabled: false
200
+
201
+ # This cop enforces the use of ids over pluck(:id) and pluck(primary_key).
202
+ # https://rails.rubystyle.guide/#ids
203
+ Rails/PluckId:
204
+ Enabled: true
205
+
206
+ # This cop identifies places where pluck is used in where query methods and can be replaced with
207
+ # select. Since pluck is an eager method and hits the database immediately, using select helps to
208
+ # avoid additional database queries.
209
+ #
210
+ # When the EnforcedStyle is aggressive then all calls to pluck in the where is used as offenses.
211
+ # This may lead to false positives as the cop cannot replace to select between calls to pluck on an
212
+ # ActiveRecord::Relation instance vs a call to pluck on an Array instance.
213
+ Rails/PluckInWhere:
214
+ EnforcedStyle: aggressive
215
+
177
216
  # The ActiveSupport monkey patches for `present?` are nearly all defined as:
178
217
  #
179
218
  # !blank?
@@ -203,6 +242,10 @@ Rails/Present:
203
242
  Rails/ReadWriteAttribute:
204
243
  Enabled: false
205
244
 
245
+ # Enabling this because it is disabled by default and we want it.
246
+ Rails/ReversibleMigrationMethodDefinition:
247
+ Enabled: true
248
+
206
249
  # This ensures we do not ignore potential validation issues in the code. Doing
207
250
  # so can lead to strange and surprising bugs where records are expected to
208
251
  # be created, or be modified, but are not.
@@ -234,6 +277,13 @@ Rails/ReadWriteAttribute:
234
277
  Rails/SaveBang:
235
278
  Enabled: true
236
279
 
280
+ # This cop enforces that short forms of I18n methods are used: t instead of translate and l instead
281
+ # of localize. We want this because it's a pain to use the full method names over and over in view
282
+ # code. When the EnforcedStyle is aggressive then all translate and localize calls without a
283
+ # receiver are added as offenses.
284
+ Rails/ShortI18n:
285
+ EnforcedStyle: aggressive
286
+
237
287
  # According to the Rails docs while the following methods skip validations they
238
288
  # only update the specified (single) attribute reducing risks. We'd rather not
239
289
  # warn for those cases:
@@ -251,14 +301,19 @@ Rails/SaveBang:
251
301
  # - http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html
252
302
  # - http://api.rubyonrails.org/classes/ActiveRecord/Relation.html
253
303
  #
254
- # Configuration parameters: Blacklist, Whitelist.
255
- # Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters
304
+ # Configuration parameters: ForbiddenMethods, AllowedMethods.
305
+ # ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters
256
306
  Rails/SkipsModelValidations:
257
- Whitelist:
307
+ AllowedMethods:
258
308
  - 'decrement!'
259
309
  - 'increment!'
260
310
  - 'touch'
261
311
 
312
+ # We don't want to be forced to use squish in SQL or JSON heredocs (especially
313
+ # in specs).
314
+ Rails/SquishedSQLHeredocs:
315
+ Enabled: false
316
+
262
317
  # Rails uses compact style by default so we're disabling this with a :hammer:
263
318
  # for things likely to be generated by Rails (i.e. most things in app).
264
319
  #
@@ -109,7 +109,14 @@ module Radius
109
109
  # factory {Radius::Spec::ModelFactory.catalog}.
110
110
  class TemplateNotFound < KeyError; end
111
111
 
112
- class << self
112
+ class << self # rubocop:disable Style/ClassMethodsDefinitions
113
+ # Style Note: We are using this class method style because we need to
114
+ # call `alias_method` within this module's singleton class context.
115
+ # Ruby did not introduce access to `singleton_class` until 2.7. Once we
116
+ # drop support for Ruby < 2.7 we can switch styles and use:
117
+ #
118
+ # singleton_class.alias_method :factory, :define_factory
119
+
113
120
  # Suggested method for defining multiple factory templates at once.
114
121
  #
115
122
  # Most projects end up having many domain models which need factories
@@ -133,6 +133,11 @@ RSpec.configure do |config|
133
133
  config.include Radius::Spec::ModelFactory, type: :feature
134
134
  end
135
135
 
136
+ config.when_first_matching_example_defined(type: :helper) do
137
+ require 'radius/spec/model_factory'
138
+ config.include Radius::Spec::ModelFactory, type: :helper
139
+ end
140
+
136
141
  config.when_first_matching_example_defined(type: :job) do
137
142
  require 'radius/spec/model_factory'
138
143
  config.include Radius::Spec::ModelFactory, type: :job
@@ -10,15 +10,15 @@ VCR.configure do |config|
10
10
  config.ignore_localhost = true
11
11
 
12
12
  record_mode = case
13
+ when ENV.fetch('CI', false)
14
+ # Never let CI record
15
+ :none
13
16
  when RSpec.configuration.files_to_run.one?
14
17
  # When developing new features we often run new specs in
15
18
  # isolation as we write the code. This is the time to allow
16
19
  # creating the cassettes.
17
20
  :once
18
- when ENV['CI']
19
- # Never let CI record
20
- :none
21
- else
21
+ else # rubocop:disable Lint/DuplicateBranch
22
22
  # Default to blocking new requests to catch issues
23
23
  :none
24
24
  end
@@ -42,14 +42,17 @@ VCR.configure do |config|
42
42
  RADIUS_OAUTH_PROVIDER_APP_SECRET
43
43
  RADIUS_OAUTH_PROVIDER_URL
44
44
  ].each do |secret|
45
- config.filter_sensitive_data("<#{secret}>") { ENV[secret] }
45
+ # WARNING: It may seem tempting, but don't try to extract ENV[secret] to a local variable
46
+ # here. `filter_sensitive_data` calls its block instead of exec-ing it, so a local variable
47
+ # set outside the blocks won't be accessible inside them.
48
+ config.filter_sensitive_data("<#{secret}>") { ENV.fetch(secret, nil) }
46
49
 
47
50
  config.filter_sensitive_data("<#{secret}_FORM>") {
48
- URI.encode_www_form_component(ENV[secret]) if ENV[secret]
51
+ URI.encode_www_form_component(ENV.fetch(secret, nil)) if ENV[secret]
49
52
  }
50
53
 
51
54
  config.filter_sensitive_data("<#{secret}_URI>") {
52
- ERB::Util.url_encode(ENV[secret]) if ENV[secret]
55
+ ERB::Util.url_encode(ENV.fetch(secret, nil)) if ENV[secret]
53
56
  }
54
57
 
55
58
  config.filter_sensitive_data('<AUTHORIZATION_HEADER>') { |interaction|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Radius
4
4
  module Spec
5
- VERSION = "0.9.0"
5
+ VERSION = "0.12.0"
6
6
  end
7
7
  end
data/radius-spec.gemspec CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
14
14
  "bug_tracker_uri" => "https://github.com/RadiusNetworks/radius-spec/issues",
15
15
  "changelog_uri" => "https://github.com/RadiusNetworks/radius-spec/blob/v#{Radius::Spec::VERSION}/CHANGELOG.md",
16
16
  "source_code_uri" => "https://github.com/RadiusNetworks/radius-spec/tree/v#{Radius::Spec::VERSION}",
17
+ "rubygems_mfa_required" => "true",
17
18
  }
18
19
  spec.summary = "Radius Networks RSpec setup and plug-ins"
19
20
  spec.description = "Standard RSpec setup and a collection of plug-ins " \
@@ -31,8 +32,8 @@ Gem::Specification.new do |spec|
31
32
  spec.required_ruby_version = ">= 2.5" # rubocop:disable Gemspec/RequiredRubyVersion
32
33
 
33
34
  spec.add_runtime_dependency "rspec", "~> 3.7"
34
- spec.add_runtime_dependency "rubocop", "~> 0.89.0"
35
- spec.add_runtime_dependency "rubocop-rails", "~> 2.6.0"
35
+ spec.add_runtime_dependency "rubocop", ">= 1.25", "< 1.33"
36
+ spec.add_runtime_dependency "rubocop-rails", ">= 2.13", "< 2.16"
36
37
 
37
38
  spec.add_development_dependency "bundler", ">= 2.2.10"
38
39
  spec.add_development_dependency "rake", ">= 12.0", "< 14.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radius-spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radius Networks
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-09-30 00:00:00.000000000 Z
12
+ date: 2022-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -29,30 +29,42 @@ dependencies:
29
29
  name: rubocop
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '1.25'
35
+ - - "<"
33
36
  - !ruby/object:Gem::Version
34
- version: 0.89.0
37
+ version: '1.33'
35
38
  type: :runtime
36
39
  prerelease: false
37
40
  version_requirements: !ruby/object:Gem::Requirement
38
41
  requirements:
39
- - - "~>"
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '1.25'
45
+ - - "<"
40
46
  - !ruby/object:Gem::Version
41
- version: 0.89.0
47
+ version: '1.33'
42
48
  - !ruby/object:Gem::Dependency
43
49
  name: rubocop-rails
44
50
  requirement: !ruby/object:Gem::Requirement
45
51
  requirements:
46
- - - "~>"
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '2.13'
55
+ - - "<"
47
56
  - !ruby/object:Gem::Version
48
- version: 2.6.0
57
+ version: '2.16'
49
58
  type: :runtime
50
59
  prerelease: false
51
60
  version_requirements: !ruby/object:Gem::Requirement
52
61
  requirements:
53
- - - "~>"
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '2.13'
65
+ - - "<"
54
66
  - !ruby/object:Gem::Version
55
- version: 2.6.0
67
+ version: '2.16'
56
68
  - !ruby/object:Gem::Dependency
57
69
  name: bundler
58
70
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +106,7 @@ executables: []
94
106
  extensions: []
95
107
  extra_rdoc_files: []
96
108
  files:
109
+ - ".github/dependabot.yml"
97
110
  - ".github/workflows/ci.yml"
98
111
  - ".github/workflows/reviewdog.yml"
99
112
  - ".gitignore"
@@ -126,6 +139,7 @@ files:
126
139
  - benchmarks/style_hash_like_case.rb
127
140
  - benchmarks/unfreeze_string.rb
128
141
  - benchmarks/unpack_first.rb
142
+ - bin/bundle
129
143
  - bin/ci
130
144
  - bin/console
131
145
  - bin/pry
@@ -150,8 +164,9 @@ licenses:
150
164
  - Apache-2.0
151
165
  metadata:
152
166
  bug_tracker_uri: https://github.com/RadiusNetworks/radius-spec/issues
153
- changelog_uri: https://github.com/RadiusNetworks/radius-spec/blob/v0.9.0/CHANGELOG.md
154
- source_code_uri: https://github.com/RadiusNetworks/radius-spec/tree/v0.9.0
167
+ changelog_uri: https://github.com/RadiusNetworks/radius-spec/blob/v0.12.0/CHANGELOG.md
168
+ source_code_uri: https://github.com/RadiusNetworks/radius-spec/tree/v0.12.0
169
+ rubygems_mfa_required: 'true'
155
170
  post_install_message:
156
171
  rdoc_options: []
157
172
  require_paths:
@@ -167,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
182
  - !ruby/object:Gem::Version
168
183
  version: '0'
169
184
  requirements: []
170
- rubygems_version: 3.1.2
185
+ rubygems_version: 3.1.6
171
186
  signing_key:
172
187
  specification_version: 4
173
188
  summary: Radius Networks RSpec setup and plug-ins