Skip to content

Commit a1eb4f1

Browse files
committed
🧪 RuboCop-LTS for Ruby 2.2+
1 parent a1d8891 commit a1eb4f1

File tree

15 files changed

+201
-149
lines changed

15 files changed

+201
-149
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ignore:
2+
- dependency-name: "rubocop-lts"

.rubocop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
inherit_gem:
2+
rubocop-lts: config/rubygem_rspec.yml

.rubocop_gradual.lock

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"lib/omniauth/strategies/jwt.rb:543932255": [
3+
[60, 9, 76, "Lint/RescueException: Avoid rescuing the `Exception` class. Perhaps you meant to rescue `StandardError`?", 967033479]
4+
],
5+
"omniauth-jwt2.gemspec:998952283": [
6+
[18, 16, 16, "Packaging/GemspecGit: Avoid using git to produce lists of files. Downstreams often need to build your package in an environment that does not have git (on purpose). Use some pure Ruby alternative, like `Dir` or `Dir.glob`.", 1973161220]
7+
],
8+
"spec/lib/omniauth/strategies/jwt_spec.rb:2698313308": [
9+
[3, 1, 34, "RSpec/FilePath: Spec path should end with `omni_auth/strategies/jwt*_spec.rb`.", 1935033905],
10+
[3, 1, 34, "RSpec/SpecFilePathFormat: Spec path should end with `omni_auth/strategies/jwt*_spec.rb`.", 1935033905],
11+
[12, 13, 25, "RSpec/DescribedClass: Use `described_class` instead of `OmniAuth::Strategies::JWT`.", 2234488924],
12+
[19, 11, 15, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 391893083],
13+
[20, 5, 42, "RSpec/MultipleExpectations: Example has too many expectations [2/1].", 4106660663],
14+
[29, 11, 16, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1409468707],
15+
[51, 7, 51, "RSpec/MultipleExpectations: Example has too many expectations [2/1].", 4149552871],
16+
[51, 7, 531, "RSpec/ExampleLength: Example has too many lines. [6/5]", 2143440997],
17+
[91, 3, 3512, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 2363831099],
18+
[110, 7, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
19+
[111, 7, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
20+
[116, 9, 6, "RSpec/ExpectInHook: Do not use `expect` in `before` hook", 1179768986],
21+
[116, 9, 20, "RSpec/StubbedMock: Prefer `allow` over `expect` when configuring a response.", 2951559342],
22+
[116, 33, 7, "RSpec/MessageSpies: Prefer `have_received` for setting message expectations. Setup `rack_request` as a spy using `allow` or `instance_spy`.", 1384559950],
23+
[130, 5, 56, "Performance/RedundantMerge: Use `algos[OpenSSL::PKey::EC] = %w[ES256 ES384 ES512]` instead of `algos.merge!(OpenSSL::PKey::EC => %w[ES256 ES384 ES512])`.", 2983772293],
24+
[133, 9, 846, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 3520352246],
25+
[152, 22, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
26+
[160, 5, 310, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 3501674141],
27+
[160, 13, 28, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1877551307],
28+
[170, 18, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
29+
[174, 5, 515, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 1246671601],
30+
[185, 9, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
31+
[189, 18, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
32+
[193, 5, 537, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 3770030886],
33+
[205, 9, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
34+
[209, 18, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441]
35+
],
36+
"spec/support/hash.rb:812296649": [
37+
[2, 3, 110, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3570181400]
38+
]
39+
}

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
source 'https://rubygems.org'
1+
source "https://rubygems.org"
22

33
# Specify your gem's dependencies in omniauth-jwt.gemspec
44
gemspec

Guardfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
guard :rspec do
55
watch(%r{^spec/.+_spec\.rb$})
6-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7-
watch('spec/spec_helper.rb') { "spec" }
8-
end
6+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7+
watch("spec/spec_helper.rb") { "spec" }
8+
end

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Or install it yourself as:
3030
You use OmniAuth::JWT just like you do any other OmniAuth strategy:
3131

3232
```ruby
33-
use OmniAuth::JWT, 'SHAREDSECRET', auth_url: 'http://example.com/login'
33+
use OmniAuth::JWT, "SHAREDSECRET", auth_url: "http://example.com/login"
3434
```
3535

3636
The first parameter is the shared secret that will be used by the external authenticator to verify
@@ -48,30 +48,30 @@ in. Other available options are:
4848
* **valid_within:** integer of how many seconds of time skew you will allow. Defaults to `nil`. If this
4949
is set, the `iat` claim becomes required and must be within the specified number of seconds of the
5050
current time. This helps to prevent replay attacks.
51-
51+
5252
### Authentication Process
5353

5454
When you authenticate through `omniauth-jwt` you can send users to `/auth/jwt` and it will redirect
5555
them to the URL specified in the `auth_url` option. From there, the provider must generate a JWT
5656
and send it to the `/auth/jwt/callback` URL as a "jwt" parameter:
5757

5858
/auth/jwt/callback?jwt=ENCODEDJWTGOESHERE
59-
59+
6060
An example of how to do that in Sinatra:
6161

6262
```ruby
63-
require 'jwt'
63+
require "jwt"
6464

65-
get '/login/sso/other-app' do
65+
get "/login/sso/other-app" do
6666
# assuming the user is already logged in and this is available as current_user
6767
claims = {
6868
id: current_user.id,
6969
name: current_user.name,
7070
email: current_user.email,
71-
iat: Time.now.to_i
71+
iat: Time.now.to_i,
7272
}
73-
74-
payload = JWT.encode(claims, ENV['SSO_SECRET'])
73+
74+
payload = JWT.encode(claims, ENV["SSO_SECRET"])
7575
redirect "http://other-app.com/auth/jwt/callback?jwt=#{payload}"
7676
end
7777
```

Rakefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,11 @@ rescue LoadError
1313
# NOOP
1414
end
1515

16+
begin
17+
require "rubocop/lts"
18+
Rubocop::Lts.install_tasks
19+
rescue LoadError
20+
# NOOP
21+
end
22+
1623
task default: :spec

gemfiles/contexts/debug.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Ancient rubies do not have String#casecmp?
2-
debugging = ENV['CI'].nil? && ENV.fetch('DEBUG', 'false')
2+
debugging = ENV["CI"].nil? && ENV.fetch("DEBUG", "false")
33

44
if debugging && debugging[/true/i]
55
gem "byebug"

gemfiles/contexts/style.gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Style
2-
gem "rubocop-lts", "~> 12.1", ">= 12.1.1" # ruby 2.7 - Lint Support for Ruby 2.4+
2+
gem "rubocop-lts", "~> 8.1", ">= 8.1.1" # ruby 2.7 - Lint Support for Ruby 2.2+
33
gem "rubocop-packaging", "~> 0.5", ">= 0.5.2" # ruby 2.6
44
gem "rubocop-rspec", "~> 2.25" # ruby 2.7
5+
gem "rspec-block_is_expected", "~> 1.0", ">= 1.0.5" # ruby 1.8.7

gemfiles/contexts/testing.gemfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Testing
2-
gem "rack", "~> 3.0", ">= 3.0.8" # ruby 2.4
3-
gem "rack-session", "~> 2.0" # ruby 2.4
2+
gem "ed25519", "~> 1.3" # ruby 2.4
43
gem "json", "~> 2.6", ">= 2.6.3" # ruby 2.3
54
gem "openssl", ">= 2.0" # ruby 2.3, v3.0 is >= 2.6, v3.2 is >= 2.7
65
gem "openssl-signature_algorithm", "~> 1.3" # ruby 2.4
7-
gem "ed25519", "~> 1.3" # ruby 2.4
6+
gem "rack", "~> 3.0", ">= 3.0.8" # ruby 2.4
7+
gem "rack-session", "~> 2.0" # ruby 2.4
8+
gem "rspec-block_is_expected", "~> 1.0", ">= 1.0.5" # ruby 1.8.7

0 commit comments

Comments
 (0)