Skip to content

Commit ff50c13

Browse files
committed
chore: replace rubocop with standardrb
1 parent 4e56a97 commit ff50c13

14 files changed

Lines changed: 236 additions & 265 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
bundle install --jobs 4 --retry 2
4242
4343
- name: Lint
44-
run: bundle exec rake lint
44+
run: bundle exec standardrb
4545

4646
- name: Strategy tests
4747
run: bundle exec rake test_unit

.rubocop.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.standard.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ruby_version: 3.2
2+
3+
plugins:
4+
- rubocop-minitest

Gemfile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# frozen_string_literal: true
22

3-
source 'https://rubygems.org'
3+
source "https://rubygems.org"
44

55
gemspec
66

7-
if ENV['OMNIAUTH_OAUTH2'] == 'head'
8-
gem 'omniauth-oauth2', git: 'https://github.com/omniauth/omniauth-oauth2.git'
9-
elsif ENV['OMNIAUTH_OAUTH2']
10-
gem 'omniauth-oauth2', ENV['OMNIAUTH_OAUTH2']
7+
if ENV["OMNIAUTH_OAUTH2"] == "head"
8+
gem "omniauth-oauth2", git: "https://github.com/omniauth/omniauth-oauth2.git"
9+
elsif ENV["OMNIAUTH_OAUTH2"]
10+
gem "omniauth-oauth2", ENV["OMNIAUTH_OAUTH2"]
1111
end
1212

13-
gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
13+
gem "rails", ENV["RAILS_VERSION"] if ENV["RAILS_VERSION"]
1414

15-
gem 'minitest', '>= 5.20'
16-
gem 'rack-test', '>= 2.1'
17-
gem 'rake', '>= 13.1'
18-
gem 'rubocop', '>= 1.70'
19-
gem 'rubocop-minitest', '>= 0.36'
20-
gem 'webmock', '>= 3.24'
15+
gem "minitest", ">= 5.20"
16+
gem "rack-test", ">= 2.1"
17+
gem "rake", ">= 13.1"
18+
gem "rubocop-minitest", ">= 0.39", require: false
19+
gem "standard", ">= 1.54.0"
20+
gem "webmock", ">= 3.24"

Rakefile

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
# frozen_string_literal: true
22

3-
require 'bundler/gem_tasks'
4-
require 'rake/testtask'
5-
require 'rubocop/rake_task'
3+
require "bundler/gem_tasks"
4+
require "rake/testtask"
5+
require "standard/rake"
66

77
Rake::TestTask.new(:test_unit) do |task|
8-
task.libs << 'lib'
9-
task.libs << 'test'
10-
task.test_files = FileList['test/omniauth_spotify_test.rb']
8+
task.libs << "lib"
9+
task.libs << "test"
10+
task.test_files = FileList["test/omniauth_spotify_test.rb"]
1111
end
1212

1313
Rake::TestTask.new(:test_rails_integration) do |task|
14-
task.libs << 'lib'
15-
task.libs << 'test'
16-
task.test_files = FileList['test/rails_integration_test.rb']
14+
task.libs << "lib"
15+
task.libs << "test"
16+
task.test_files = FileList["test/rails_integration_test.rb"]
1717
end
1818

1919
Rake::TestTask.new(:test) do |task|
20-
task.libs << 'lib'
21-
task.libs << 'test'
22-
task.test_files = FileList['test/**/*_test.rb']
20+
task.libs << "lib"
21+
task.libs << "test"
22+
task.test_files = FileList["test/**/*_test.rb"]
2323
end
2424

25-
RuboCop::RakeTask.new(:lint)
25+
task lint: :standard
2626

27-
task default: %i[lint test_unit]
27+
task default: %i[standard test_unit]

lib/omniauth-spotify.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# frozen_string_literal: true
22

3-
require 'omniauth/spotify'
3+
require "omniauth/spotify"

lib/omniauth-spotify/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'omniauth/spotify/version'
3+
require "omniauth/spotify/version"
44

55
# Backward compatibility for historical constant usage.
66
module Omniauth

lib/omniauth/spotify.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# frozen_string_literal: true
22

3-
require 'omniauth/spotify/version'
4-
require 'omniauth/strategies/spotify'
3+
require "omniauth/spotify/version"
4+
require "omniauth/strategies/spotify"

lib/omniauth/spotify/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module OmniAuth
44
module Spotify
5-
VERSION = '1.0.2'
5+
VERSION = "1.0.2"
66
end
77
end

lib/omniauth/strategies/spotify.rb

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
11
# frozen_string_literal: true
22

3-
require 'date'
4-
require 'omniauth-oauth2'
3+
require "date"
4+
require "omniauth-oauth2"
55

66
module OmniAuth
77
module Strategies
88
# OmniAuth strategy for Spotify OAuth2.
99
class Spotify < OmniAuth::Strategies::OAuth2
10-
option :name, 'spotify'
10+
option :name, "spotify"
1111

12-
FORCE_APPROVAL_KEY = 'omniauth_spotify_force_approval?'
13-
LEGACY_FORCE_APPROVAL_KEY = 'ommiauth_spotify_force_approval?'
12+
FORCE_APPROVAL_KEY = "omniauth_spotify_force_approval?"
13+
LEGACY_FORCE_APPROVAL_KEY = "ommiauth_spotify_force_approval?"
1414

1515
option :client_options,
16-
site: 'https://api.spotify.com',
17-
authorize_url: 'https://accounts.spotify.com/authorize',
18-
token_url: 'https://accounts.spotify.com/api/token',
19-
connection_opts: {
20-
headers: {
21-
user_agent: 'icoretech-omniauth-spotify gem',
22-
accept: 'application/json',
23-
content_type: 'application/json'
24-
}
25-
}
26-
27-
uid { raw_info['id'] }
16+
site: "https://api.spotify.com",
17+
authorize_url: "https://accounts.spotify.com/authorize",
18+
token_url: "https://accounts.spotify.com/api/token",
19+
connection_opts: {
20+
headers: {
21+
user_agent: "icoretech-omniauth-spotify gem",
22+
accept: "application/json",
23+
content_type: "application/json"
24+
}
25+
}
26+
27+
uid { raw_info["id"] }
2828

2929
info do
3030
{
31-
name: raw_info['display_name'] || raw_info['id'],
32-
nickname: raw_info['id'],
33-
email: raw_info['email'],
34-
urls: raw_info['external_urls'],
31+
name: raw_info["display_name"] || raw_info["id"],
32+
nickname: raw_info["id"],
33+
email: raw_info["email"],
34+
urls: raw_info["external_urls"],
3535
image: image_url,
36-
birthdate: parse_birthdate(raw_info['birthdate']),
37-
country_code: raw_info['country'],
38-
product: raw_info['product'],
39-
follower_count: raw_info.dig('followers', 'total')
36+
birthdate: parse_birthdate(raw_info["birthdate"]),
37+
country_code: raw_info["country"],
38+
product: raw_info["product"],
39+
follower_count: raw_info.dig("followers", "total")
4040
}.compact
4141
end
4242

4343
credentials do
4444
{
45-
'token' => access_token.token,
46-
'refresh_token' => access_token.refresh_token,
47-
'expires_at' => access_token.expires_at,
48-
'expires' => access_token.expires?,
49-
'scope' => token_scope
45+
"token" => access_token.token,
46+
"refresh_token" => access_token.refresh_token,
47+
"expires_at" => access_token.expires_at,
48+
"expires" => access_token.expires?,
49+
"scope" => token_scope
5050
}.compact
5151
end
5252

5353
extra do
5454
{
55-
'raw_info' => raw_info
55+
"raw_info" => raw_info
5656
}
5757
end
5858

5959
def raw_info
60-
@raw_info ||= access_token.get('v1/me').parsed
60+
@raw_info ||= access_token.get("v1/me").parsed
6161
end
6262

6363
def image_url
64-
raw_info.fetch('images', []).first&.fetch('url', nil)
64+
raw_info.fetch("images", []).first&.fetch("url", nil)
6565
end
6666

6767
def authorize_params
@@ -71,18 +71,18 @@ def authorize_params
7171
end
7272

7373
def request_phase
74-
options[:authorize_params][:show_dialog] = request.params['show_dialog'] if request.params.key?('show_dialog')
74+
options[:authorize_params][:show_dialog] = request.params["show_dialog"] if request.params.key?("show_dialog")
7575
super
7676
end
7777

7878
def callback_url
79-
return '' if @authorization_code_from_signed_request
79+
return "" if @authorization_code_from_signed_request
8080

8181
options[:callback_url] || super
8282
end
8383

8484
def query_string
85-
return '' if request.params['code']
85+
return "" if request.params["code"]
8686

8787
super
8888
end
@@ -91,7 +91,7 @@ def query_string
9191

9292
def token_scope
9393
token_params = access_token.respond_to?(:params) ? access_token.params : {}
94-
token_params['scope'] || (access_token['scope'] if access_token.respond_to?(:[]))
94+
token_params["scope"] || (access_token["scope"] if access_token.respond_to?(:[]))
9595
end
9696

9797
def force_approval_requested?
@@ -102,7 +102,7 @@ def force_approval_requested?
102102
end
103103

104104
def flash_force_approval?(key)
105-
flashes = session.dig(:flash, 'flashes') || session.dig('flash', 'flashes')
105+
flashes = session.dig(:flash, "flashes") || session.dig("flash", "flashes")
106106
!!flashes&.[](key)
107107
end
108108

0 commit comments

Comments
 (0)