radius-spec 0.10.0 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8cf443a1c6510d208f4c05e3411461e850d11243ddfb8c72403cd6ad5cf42bb
4
- data.tar.gz: b3eb1c7facabda9825bda8fd5d112e61bb9f356dabb0924846e103dda307633b
3
+ metadata.gz: 8866a2f90557e85b2974af975e2461737ee1393031ffa7ab5aeacfcd9b2b2c46
4
+ data.tar.gz: 5f04fb6044c683d90c7cd331423c069fd97b6bd1e2de54a6251051a52b86c23c
5
5
  SHA512:
6
- metadata.gz: 6c9172e6e540bc8826a5ba39084c7a26fbccace68c54445dc9ed67c07228ed83044be16547fd1ec4524fbe649cf000f384a0f430928a79c903a9ba2389ea3f47
7
- data.tar.gz: 7a1903a1749717032feeea5f02c171e48173ea16a5bbc1f6ec5a3e487462aa47be3608906954d10f37d4526768e614c4ea5a023cf1b75fa9ca76e27e902d961d
6
+ metadata.gz: ee3d463a37fee11380d6700ed966068fdf20ac19d1636a9e577959c633bdde2d04657dca074b6e6c53a24f536d637f254340c7c775853a20214691698218f0fd
7
+ data.tar.gz: 014b79fb72b9ef1ecb07e8d6ec01e660755eef2dc484d807e525a62d975e624392ab92f990f2ee80acbaa6b8b3bcd6020a8b27613e0d7a6c67bca94bf6a1476f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,32 @@
1
+ ## 0.11.0 (January 21, 2022)
2
+
3
+ [Full Changelog](https://github.com/RadiusNetworks/radius-spec/compare/v0.10.0...0.11.0)
4
+
5
+ ### Enhancements
6
+
7
+ - Adjust common Rubocop configuration (Aaron Hill, Aaron Kromer, Ben Reynolds, James Nebeker, JC Avena, Sam Kim)
8
+ - Enable `Lint/NoReturnInBeginEndBlocks` by default
9
+ - Set `AllowHttpProtocol: false` for `Bundler/InsecureProtocolSource` cop
10
+ - Set `AllowNil: false` for `Lint/SuppressedException` cop
11
+ - Enable `Naming/BlockForwarding` cop for future Ruby 3.1 usage
12
+ - Disallow Ruby 3 `Style/NumberedParameters`
13
+ - Enable `Style/StringChars` by default
14
+ - Set `AllowMethodsWithArguments: true` for `Style/SymbolProc` cop
15
+ - Disallow combined `&&` and `||` in single `unless` clauses
16
+ - Enable `Naming/InclusiveLanguage` by default
17
+ - Adjust common Rubocop-Rails configuration (Alex Stone, James Nebeker, Aaron Kromer, Ben Reynolds, Sam Kim)
18
+ - Enable `Rails/EnvironmentVariableAccess` (`AllowReads` to `true`)
19
+ - Changed `Rails/FindBy`:`IgnoreWhereFirst` to `false`
20
+ - Enable `Rails/ReversibleMigrationMethodDefinition`
21
+ - Upgrade to Rubocop Rails 2.12.x (Alex Stone, James Nebeker, Aaron Kromer, Ben Reynolds, Sam Kim)
22
+ - Upgrade to Rubocop Rails 2.13.x (Alex Stone, James Nebeker, Aaron Kromer, Ben Reynolds, Sam Kim)
23
+ - Upgrade to Rubocop 1.25.x (Alex Stone, James Nebeker, Aaron Kromer, Ben Reynolds, Sam Kim, JC Avena, Eric Ouellette, Aaron Hill)
24
+ - Include model factory helpers in helper specs by default (Alex Stone, James Nebeker, Aaron Kromer, Ben Reynolds, JC Avena, Eric Ouellette)
25
+
26
+ ### Bug Fixes
27
+
28
+ None
29
+
1
30
  ## 0.10.0 (October 18, 2021)
2
31
 
3
32
  [Full Changelog](https://github.com/RadiusNetworks/radius-spec/compare/v0.9.0...v0.10.0)
@@ -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,7 +13,7 @@ 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
@@ -73,7 +73,7 @@ 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
data/common_rubocop.yml CHANGED
@@ -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:
@@ -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,7 +243,7 @@ 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'
220
248
  - 'describe'
221
249
  - 'refine'
@@ -256,6 +284,21 @@ Metrics/MethodLength:
256
284
  Naming/BinaryOperatorParameterName:
257
285
  Enabled: false
258
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
+
259
302
  # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
260
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
261
304
  Naming/FileName:
@@ -345,6 +388,9 @@ Style/AndOr:
345
388
  # These days most people have editors which support unicode and other
346
389
  # non-ASCII characters.
347
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
+ #
348
394
  # Configuration parameters: AllowedChars.
349
395
  Style/AsciiComments:
350
396
  Enabled: false
@@ -511,6 +557,7 @@ Style/HashSyntax:
511
557
  Prefer symbol keys using the 1.9 hash syntax. However, when keys are mixed
512
558
  use a consistent mapping style; which generally means using hash rockets.
513
559
  EnforcedStyle: ruby19_no_mixed_keys
560
+ EnforcedShorthandSyntax: either
514
561
 
515
562
  # As part of our semantic style we generally use the literal `-> { }` format to
516
563
  # indicate this is a function with a return value we care about. As this cop
@@ -541,6 +588,11 @@ Style/MethodCalledOnDoEndBlock:
541
588
  Style/MultilineBlockChain:
542
589
  Enabled: false
543
590
 
591
+ # Disallowing numbered parameter usage because we dont prefer this style.
592
+ # We would rather name the paramaters to clearly communicate intent.
593
+ Style/NumberedParameters:
594
+ EnforcedStyle: disallow
595
+
544
596
  # Context for this cop is too dependent.
545
597
  #
546
598
  # Often using the numeric comparison is faster. Also, depending on the context
@@ -557,6 +609,12 @@ Style/MultilineBlockChain:
557
609
  Style/NumericPredicate:
558
610
  Enabled: false
559
611
 
612
+ # As a general rule, we want to be explicit here instead of requiring readers
613
+ # of our code to know what the default arguments to methods like `#join` and
614
+ # and `#split` so we disable this cop here.
615
+ Style/RedundantArgument:
616
+ Enabled: false
617
+
560
618
  # In Ruby every method returns a value. Implicitly this is the value of the
561
619
  # last line of the method. This means using `return` is often redundant.
562
620
  # However, there isn't anything inherently wrong about doing so. In fact, in
@@ -669,6 +727,15 @@ Style/RescueStandardError:
669
727
  Style/SlicingWithRange:
670
728
  Enabled: false
671
729
 
730
+ # We want to turn this cop on so that rubocop can yell at us instead of Aaron
731
+ # yelling at us.
732
+ Style/StaticClass:
733
+ Enabled: true
734
+
735
+ # Enable Style/StringChars
736
+ Style/StringChars:
737
+ Enabled: true
738
+
672
739
  # We generally prefer double quotes but many generators use single quotes. We
673
740
  # don't view the performance difference to be all that much so we don't care
674
741
  # if the style is mixed or double quotes are used for static strings.
@@ -699,6 +766,13 @@ Style/StringLiteralsInInterpolation:
699
766
  Style/SymbolArray:
700
767
  MinSize: 3
701
768
 
769
+ # Allow either
770
+ # something.do_something(foo, &:bar)
771
+ # or
772
+ # something.do_something(foo) { |s| s.bar }
773
+ Style/SymbolProc:
774
+ AllowMethodsWithArguments: true
775
+
702
776
  # When ternaries become complex they can be difficult to read due to increased
703
777
  # cognitive load parsing the expression. Cognitive load can increase further
704
778
  # when assignment is involved.
@@ -761,6 +835,11 @@ Style/TrailingCommaInHashLiteral:
761
835
  simplifies adding, removing, and re-arranging the elements.
762
836
  EnforcedStyleForMultiline: consistent_comma
763
837
 
838
+ # Don't combine && & || inside the same `unless` guard clause.
839
+ Style/UnlessLogicalOperators:
840
+ Enabled: true
841
+ EnforcedStyle: forbid_mixed_logical_operators
842
+
764
843
  # We don't feel too strongly about percent vs bracket array style. We tend to
765
844
  # use the percent style, which also happens to be Rubocop's default. So for
766
845
  # pedantic consistency we'll enforce this.
@@ -780,3 +859,7 @@ Style/WordArray:
780
859
  # SupportedStyles: all_comparison_operators, equality_operators_only
781
860
  Style/YodaCondition:
782
861
  Enabled: false
862
+
863
+ # Disabled in 1.21.0. Radius Networks has chosen to enable it.
864
+ Naming/InclusiveLanguage:
865
+ Enabled: true
@@ -111,15 +111,25 @@ Rails/CreateTableWithTimestamps:
111
111
  Rails/DefaultScope:
112
112
  Enabled: true
113
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
+
114
120
  # Usage of `find_by` is more expressive of intent than `where.first`. We should
115
121
  # check all app code, not just the models to improve intent expression.
116
122
  #
117
123
  # Since rake tasks often live in `lib` we also check all of lib as well.
118
124
  #
125
+ # We are also disabling the default IgnoreWhereFirst that was added in version
126
+ # 2.11
127
+ #
119
128
  # Configuration parameters: Include.
120
129
  # Include: app/models/**/*.rb
121
130
  Rails/FindBy:
122
131
  Enabled: true
132
+ IgnoreWhereFirst: false
123
133
  Include:
124
134
  - 'app/**/*.rb'
125
135
  - 'lib/**/*.rb'
@@ -228,6 +238,10 @@ Rails/Present:
228
238
  Rails/ReadWriteAttribute:
229
239
  Enabled: false
230
240
 
241
+ # Enabling this because it is disabled by default and we want it.
242
+ Rails/ReversibleMigrationMethodDefinition:
243
+ Enabled: true
244
+
231
245
  # This ensures we do not ignore potential validation issues in the code. Doing
232
246
  # so can lead to strange and surprising bugs where records are expected to
233
247
  # be created, or be modified, but are not.
@@ -109,8 +109,7 @@ module Radius
109
109
  # factory {Radius::Spec::ModelFactory.catalog}.
110
110
  class TemplateNotFound < KeyError; end
111
111
 
112
- class << self
113
- # rubocop:disable Style/ClassMethodsDefinitions
112
+ class << self # rubocop:disable Style/ClassMethodsDefinitions
114
113
  # Style Note: We are using this class method style because we need to
115
114
  # call `alias_method` within this module's singleton class context.
116
115
  # Ruby did not introduce access to `singleton_class` until 2.7. Once we
@@ -291,7 +290,6 @@ module Radius
291
290
  def templates
292
291
  @templates ||= {}
293
292
  end
294
- # rubocop:enable Style/ClassMethodsDefinitions
295
293
  end
296
294
 
297
295
  module_function
@@ -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['CI']
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Radius
4
4
  module Spec
5
- VERSION = "0.10.0"
5
+ VERSION = "0.11.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.90.0"
35
- spec.add_runtime_dependency "rubocop-rails", "~> 2.9.1"
35
+ spec.add_runtime_dependency "rubocop", "~> 1.25.0"
36
+ spec.add_runtime_dependency "rubocop-rails", "~> 2.13.0"
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.10.0
4
+ version: 0.11.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-10-18 00:00:00.000000000 Z
12
+ date: 2022-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -31,28 +31,28 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 0.90.0
34
+ version: 1.25.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 0.90.0
41
+ version: 1.25.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rubocop-rails
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 2.9.1
48
+ version: 2.13.0
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 2.9.1
55
+ version: 2.13.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: bundler
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -151,8 +151,9 @@ licenses:
151
151
  - Apache-2.0
152
152
  metadata:
153
153
  bug_tracker_uri: https://github.com/RadiusNetworks/radius-spec/issues
154
- changelog_uri: https://github.com/RadiusNetworks/radius-spec/blob/v0.10.0/CHANGELOG.md
155
- source_code_uri: https://github.com/RadiusNetworks/radius-spec/tree/v0.10.0
154
+ changelog_uri: https://github.com/RadiusNetworks/radius-spec/blob/v0.11.0/CHANGELOG.md
155
+ source_code_uri: https://github.com/RadiusNetworks/radius-spec/tree/v0.11.0
156
+ rubygems_mfa_required: 'true'
156
157
  post_install_message:
157
158
  rdoc_options: []
158
159
  require_paths:
@@ -168,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
169
  - !ruby/object:Gem::Version
169
170
  version: '0'
170
171
  requirements: []
171
- rubygems_version: 3.1.6
172
+ rubygems_version: 3.1.2
172
173
  signing_key:
173
174
  specification_version: 4
174
175
  summary: Radius Networks RSpec setup and plug-ins