Skip to content

Commit c4f34cd

Browse files
committed
Update to rubocop 1.56
1 parent 0029d0a commit c4f34cd

30 files changed

+76
-79
lines changed

.codeclimate.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ plugins:
55
enabled: true
66
rubocop:
77
enabled: true
8-
channel: rubocop-1-31-0
8+
channel: rubocop-1-56-3

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- gemfiles/standalone.gemfile
4141
- gemfiles/openssl.gemfile
4242
- gemfiles/rbnacl.gemfile
43-
- gemfiles/rbnacl-pre-6.gemfile
43+
- gemfiles/rbnacl_pre_6.gemfile
4444
experimental: [false]
4545
include:
4646
- os: ubuntu-22.04

.rubocop.yml

+3
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,6 @@ Layout/MultilineOperationIndentation:
6363

6464
Style/WordArray:
6565
Enabled: false
66+
67+
Gemspec/DevelopmentDependencies:
68+
EnforcedStyle: gemspec

.simplecov

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require 'simplecov_json_formatter'
66
SimpleCov.start do
77
command_name "Job #{File.basename(ENV['BUNDLE_GEMFILE'])}" if ENV['BUNDLE_GEMFILE']
88
project_name 'Ruby JWT - Ruby JSON Web Token implementation'
9-
coverage_dir "coverage-#{::OpenSSL::Digest::SHA256.hexdigest(ENV['GITHUB_STEP_SUMMARY'])}" if ENV['GITHUB_STEP_SUMMARY']
9+
coverage_dir "coverage-#{OpenSSL::Digest::SHA256.hexdigest(ENV['GITHUB_STEP_SUMMARY'])}" if ENV['GITHUB_STEP_SUMMARY']
1010
add_filter 'spec'
1111
end
1212

Appraisals

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ appraise 'rbnacl' do
1212
gem 'rbnacl', '>= 6'
1313
end
1414

15-
appraise 'rbnacl-pre-6' do
15+
appraise 'rbnacl_pre_6' do
1616
gem 'rbnacl', '< 6'
1717
end

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66

77
**Features:**
88

9+
- Updated rubocop to 1.56 [#573](https://github.com/jwt/ruby-jwt/pull/573) - [@anakinj](https://github.com/anakinj).
910
- Your contribution here
1011

1112
**Fixes and enhancements:**
1213

13-
- Fix signature has expired error if payload is a string [#555](https://github.com/jwt/ruby-jwt/pull/555) - [@GobinathAL](https://github.com/GobinathAL)
14+
- Fix signature has expired error if payload is a string [#555](https://github.com/jwt/ruby-jwt/pull/555) - [@GobinathAL](https://github.com/GobinathAL).
1415
- Your contribution here
1516

1617
## [v2.7.1](https://github.com/jwt/ruby-jwt/tree/v2.8.0) (2023-06-09)

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ source 'https://rubygems.org'
44

55
gemspec
66

7-
gem 'rubocop', '< 1.32' # Keep .codeclimate.yml channel in sync with this one
7+
gem 'rubocop', '~> 1.56.3' # Keep .codeclimate.yml channel in sync with this one

bin/smoke.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
require 'jwt'
55

6-
puts "Running simple encode/decode test for #{::JWT.gem_version}"
6+
puts "Running simple encode/decode test for #{JWT.gem_version}"
77
secret = 'secretkeyforsigning'
8-
token = ::JWT.encode({ con: 'tent' }, secret, 'HS256')
9-
::JWT.decode(token, secret, true, algorithm: 'HS256')
8+
token = JWT.encode({ con: 'tent' }, secret, 'HS256')
9+
JWT.decode(token, secret, true, algorithm: 'HS256')

gemfiles/openssl.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "https://rubygems.org"
44

5-
gem "rubocop", "< 1.32"
5+
gem "rubocop", "~> 1.56.3"
66
gem "openssl", "~> 2.1"
77

88
gemspec path: "../"

gemfiles/rbnacl-pre-6.gemfile

-8
This file was deleted.

gemfiles/rbnacl.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "https://rubygems.org"
44

5-
gem "rubocop", "< 1.32"
5+
gem "rubocop", "~> 1.56.3"
66
gem "rbnacl", ">= 6"
77

88
gemspec path: "../"

gemfiles/rbnacl_pre_6.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "https://rubygems.org"
44

5-
gem "rubocop", "< 1.32"
5+
gem "rubocop", "~> 1.56.3"
66
gem "rbnacl", "< 6"
77

88
gemspec path: "../"

gemfiles/standalone.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
source "https://rubygems.org"
44

5-
gem "rubocop", "< 1.32"
5+
gem "rubocop", "~> 1.56.3"
66

77
gemspec path: "../"

lib/jwt/claims_validator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require_relative './error'
3+
require_relative 'error'
44

55
module JWT
66
class ClaimsValidator

lib/jwt/jwk.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ def generate_mappings
5252
require_relative 'jwk/ec'
5353
require_relative 'jwk/rsa'
5454
require_relative 'jwk/hmac'
55-
require_relative 'jwk/okp_rbnacl' if ::JWT.rbnacl?
55+
require_relative 'jwk/okp_rbnacl' if JWT.rbnacl?

lib/jwt/version.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ module VERSION
2323

2424
def self.openssl_3?
2525
return false if OpenSSL::OPENSSL_VERSION.include?('LibreSSL')
26-
return true if OpenSSL::OPENSSL_VERSION_NUMBER >= 3 * 0x10000000
26+
27+
true if 3 * 0x10000000 <= OpenSSL::OPENSSL_VERSION_NUMBER
2728
end
2829

2930
def self.rbnacl?

spec/configuration/jwk_configuration_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
context 'when valid value is passed' do
1212
it 'sets the generator matching the value' do
1313
subject.kid_generator_type = :rfc7638_thumbprint
14-
expect(subject.kid_generator).to eq(::JWT::JWK::Thumbprint)
14+
expect(subject.kid_generator).to eq(JWT::JWK::Thumbprint)
1515
end
1616
end
1717
end

spec/integration/readme_examples_spec.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
end
3030

3131
it 'decodes with HMAC algorithm without secret key' do
32-
pending 'Different behaviour on OpenSSL 3.0 (https://github.com/openssl/openssl/issues/13089)' if ::JWT.openssl_3_hmac_empty_key_regression?
32+
pending 'Different behaviour on OpenSSL 3.0 (https://github.com/openssl/openssl/issues/13089)' if JWT.openssl_3_hmac_empty_key_regression?
3333
token = JWT.encode payload, nil, 'HS256'
3434
decoded_token = JWT.decode token, nil, false
3535

@@ -80,7 +80,7 @@
8080
end
8181
end
8282

83-
if ::Gem::Version.new(OpenSSL::VERSION) >= ::Gem::Version.new('2.1')
83+
if Gem::Version.new(OpenSSL::VERSION) >= Gem::Version.new('2.1')
8484
it 'RSASSA-PSS' do
8585
rsa_private = OpenSSL::PKey::RSA.generate 2048
8686
rsa_public = rsa_private.public_key
@@ -414,7 +414,7 @@
414414
end
415415

416416
it 'JWK with thumbprint as kid via type' do
417-
JWT.configuration.jwk.kid_generator = ::JWT::JWK::Thumbprint
417+
JWT.configuration.jwk.kid_generator = JWT::JWK::Thumbprint
418418

419419
jwk = JWT::JWK.new(OpenSSL::PKey::RSA.new(2048))
420420

@@ -424,15 +424,15 @@
424424
end
425425

426426
it 'JWK with thumbprint given in the initializer (legacy)' do
427-
jwk = JWT::JWK.new(OpenSSL::PKey::RSA.new(2048), kid_generator: ::JWT::JWK::Thumbprint)
427+
jwk = JWT::JWK.new(OpenSSL::PKey::RSA.new(2048), kid_generator: JWT::JWK::Thumbprint)
428428

429429
jwk_hash = jwk.export
430430

431431
expect(jwk_hash[:kid].size).to eq(43)
432432
end
433433

434434
it 'JWK with thumbprint given in the initializer' do
435-
jwk = JWT::JWK.new(OpenSSL::PKey::RSA.new(2048), nil, kid_generator: ::JWT::JWK::Thumbprint)
435+
jwk = JWT::JWK.new(OpenSSL::PKey::RSA.new(2048), nil, kid_generator: JWT::JWK::Thumbprint)
436436

437437
jwk_hash = jwk.export
438438

@@ -460,8 +460,8 @@ def self.verify(data:, signature:, verification_key:)
460460
end
461461
end
462462

463-
token = ::JWT.encode({ 'pay' => 'load' }, 'secret', custom_hs512_alg)
464-
_payload, _header = ::JWT.decode(token, 'secret', true, algorithm: custom_hs512_alg)
463+
token = JWT.encode({ 'pay' => 'load' }, 'secret', custom_hs512_alg)
464+
_payload, _header = JWT.decode(token, 'secret', true, algorithm: custom_hs512_alg)
465465
end
466466
end
467467
end

spec/jwk/decode_with_jwk_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
if defined?(RbNaCl)
167167
context 'when OKP keys are used' do
168168
before do
169-
skip('Requires the rbnacl gem') unless ::JWT.rbnacl?
169+
skip('Requires the rbnacl gem') unless JWT.rbnacl?
170170
end
171171

172172
let(:keypair) { RbNaCl::Signatures::Ed25519::SigningKey.new(SecureRandom.hex) }

spec/jwk/okp_rbnacl_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
subject(:instance) { described_class.new(key) }
1212

1313
before do
14-
skip('Requires the rbnacl gem') unless ::JWT.rbnacl?
14+
skip('Requires the rbnacl gem') unless JWT.rbnacl?
1515
end
1616

1717
describe '.new' do

spec/jwk/rsa_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
let(:jwk_parameters) { all_jwk_parameters.slice(:e, :n) }
153153

154154
it 'creates a valid RSA object representing a public key' do
155-
expect(subject).to be_a(::OpenSSL::PKey::RSA)
155+
expect(subject).to be_a(OpenSSL::PKey::RSA)
156156
expect(subject.private?).to eq(false)
157157
end
158158
end
@@ -169,7 +169,7 @@
169169
let(:jwk_parameters) { all_jwk_parameters.slice(:n, :e, :d, :p, :q, :dp, :dq, :qi) }
170170

171171
it 'creates a valid RSA object representing a public key' do
172-
expect(subject).to be_a(::OpenSSL::PKey::RSA)
172+
expect(subject).to be_a(OpenSSL::PKey::RSA)
173173
expect(subject.private?).to eq(true)
174174
end
175175
end
@@ -180,11 +180,11 @@
180180
let(:jwk_parameters) { all_jwk_parameters.slice(:e, :n, :d) }
181181

182182
before do
183-
skip 'OpenSSL prior to 2.2 does not seem to support partial parameters' if ::JWT.openssl_version < ::Gem::Version.new('2.2')
183+
skip 'OpenSSL prior to 2.2 does not seem to support partial parameters' if JWT.openssl_version < Gem::Version.new('2.2')
184184
end
185185

186186
it 'creates a valid RSA object representing a private key' do
187-
expect(subject).to be_a(::OpenSSL::PKey::RSA)
187+
expect(subject).to be_a(OpenSSL::PKey::RSA)
188188
expect(subject.private?).to eq(true)
189189
end
190190

@@ -217,7 +217,7 @@
217217
describe '.create_rsa_key_using_sets' do
218218
before do
219219
skip 'OpenSSL without the RSA#set_key method not supported' unless OpenSSL::PKey::RSA.new.respond_to?(:set_key)
220-
skip 'OpenSSL 3.0 does not allow mutating objects anymore' if ::JWT.openssl_3?
220+
skip 'OpenSSL 3.0 does not allow mutating objects anymore' if JWT.openssl_3?
221221
end
222222

223223
subject(:rsa) { described_class.create_rsa_key_using_sets(rsa_parameters) }

spec/jwk_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
subject { described_class.import(params) }
1313

1414
it 'creates a ::JWT::JWK::RSA instance' do
15-
expect(subject).to be_a ::JWT::JWK::RSA
15+
expect(subject).to be_a JWT::JWK::RSA
1616
expect(subject.export).to eq(exported_key)
1717
end
1818

1919
context 'parsed from JSON' do
2020
let(:params) { exported_key }
2121
it 'creates a ::JWT::JWK::RSA instance from JSON parsed JWK' do
22-
expect(subject).to be_a ::JWT::JWK::RSA
22+
expect(subject).to be_a JWT::JWK::RSA
2323
expect(subject.export).to eq(exported_key)
2424
end
2525
end
@@ -53,17 +53,17 @@
5353

5454
context 'when RSA key is given' do
5555
let(:keypair) { rsa_key }
56-
it { is_expected.to be_a ::JWT::JWK::RSA }
56+
it { is_expected.to be_a JWT::JWK::RSA }
5757
end
5858

5959
context 'when secret key is given' do
6060
let(:keypair) { 'secret-key' }
61-
it { is_expected.to be_a ::JWT::JWK::HMAC }
61+
it { is_expected.to be_a JWT::JWK::HMAC }
6262
end
6363

6464
context 'when EC key is given' do
6565
let(:keypair) { ec_key }
66-
it { is_expected.to be_a ::JWT::JWK::EC }
66+
it { is_expected.to be_a JWT::JWK::EC }
6767
end
6868

6969
context 'when kid is given' do

spec/jwt/algos/ecdsa_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe ::JWT::Algos::Ecdsa do
3+
RSpec.describe JWT::Algos::Ecdsa do
44
describe '.curve_by_name' do
55
subject { described_class.curve_by_name(curve_name) }
66

spec/jwt/algos/hmac_rbnacl_fixed_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
skip('Requires rbnacl gem < 6.0') ::JWT.rbnacl?
66
end
77

8-
let(:described_class) { ::JWT::Algos::HmacRbNaClFixed }
8+
let(:described_class) { JWT::Algos::HmacRbNaClFixed }
99

1010
let(:data) { 'this_is_the_string_to_be_signed' }
1111
let(:key) { 'the secret key' }
1212

1313
describe '.verify' do
1414
context 'when signature is generated with OpenSSL' do
15-
let!(:signature) { ::JWT::Algos::Hmac.sign('HS256', data, key) }
15+
let!(:signature) { JWT::Algos::Hmac.sign('HS256', data, key) }
1616
it 'verifies the signature' do
1717
allow(OpenSSL::HMAC).to receive(:digest).and_call_original
1818
expect(described_class.verify('HS256', key, data, signature)).to eq(true)
@@ -22,7 +22,7 @@
2222

2323
context 'when signature is generated with OpenSSL and key is very long' do
2424
let(:key) { 'a' * 100 }
25-
let!(:signature) { ::JWT::Algos::Hmac.sign('HS256', data, key) }
25+
let!(:signature) { JWT::Algos::Hmac.sign('HS256', data, key) }
2626

2727
it 'verifies the signature using OpenSSL features' do
2828
allow(OpenSSL::HMAC).to receive(:digest).and_call_original
@@ -47,7 +47,7 @@
4747
context 'when signature is generated by RbNaCl' do
4848
let!(:signature) { described_class.sign('HS256', data, key) }
4949
it 'can verify the signature with OpenSSL' do
50-
expect(::JWT::Algos::Hmac.verify('HS256', key, data, signature)).to eq(true)
50+
expect(JWT::Algos::Hmac.verify('HS256', key, data, signature)).to eq(true)
5151
end
5252
end
5353
end

spec/jwt/algos/hmac_rbnacl_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
RSpec.describe '::JWT::Algos::HmacRbNaCl' do
44
before do
5-
skip('Requires the rbnacl gem greater than 6.0') unless ::JWT.rbnacl_6_or_greater?
5+
skip('Requires the rbnacl gem greater than 6.0') unless JWT.rbnacl_6_or_greater?
66
end
77

8-
let(:described_class) { ::JWT::Algos::HmacRbNaCl }
8+
let(:described_class) { JWT::Algos::HmacRbNaCl }
99

1010
let(:data) { 'this_is_the_string_to_be_signed' }
1111
let(:key) { 'the secret key' }
1212

1313
describe '.verify' do
1414
context 'when signature is generated with OpenSSL' do
15-
let!(:signature) { ::JWT::Algos::Hmac.sign('HS256', data, key) }
15+
let!(:signature) { JWT::Algos::Hmac.sign('HS256', data, key) }
1616
it 'verifies the signature' do
1717
allow(OpenSSL::HMAC).to receive(:digest).and_call_original
1818
expect(described_class.verify('HS256', key, data, signature)).to eq(true)
@@ -22,7 +22,7 @@
2222

2323
context 'when signature is generated with OpenSSL and key is very long' do
2424
let(:key) { 'a' * 100 }
25-
let!(:signature) { ::JWT::Algos::Hmac.sign('HS256', data, key) }
25+
let!(:signature) { JWT::Algos::Hmac.sign('HS256', data, key) }
2626

2727
it 'verifies the signature using OpenSSL features' do
2828
allow(OpenSSL::HMAC).to receive(:digest).and_call_original
@@ -47,7 +47,7 @@
4747
context 'when signature is generated by RbNaCl' do
4848
let!(:signature) { described_class.sign('HS256', data, key) }
4949
it 'can verify the signature with OpenSSL' do
50-
expect(::JWT::Algos::Hmac.verify('HS256', key, data, signature)).to eq(true)
50+
expect(JWT::Algos::Hmac.verify('HS256', key, data, signature)).to eq(true)
5151
end
5252
end
5353
end

spec/jwt/algos/hmac_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe ::JWT::Algos::Hmac do
3+
RSpec.describe JWT::Algos::Hmac do
44
describe '.sign' do
55
subject { described_class.sign('HS256', 'test', hmac_secret) }
66

spec/jwt/configuration_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe ::JWT do
3+
RSpec.describe JWT do
44
describe 'JWT.configure' do
55
it 'yields the configuration' do
66
expect { |b| described_class.configure(&b) }.to yield_with_args(described_class.configuration)

0 commit comments

Comments
 (0)