Fix rubocop Ruby 1.9.3 compatibility issues

This commit is contained in:
Heng Xiong 2017-07-12 17:11:49 -07:00
parent 374b342ea9
commit 1db30f6db1
8 changed files with 17 additions and 10 deletions

View File

@ -17,3 +17,10 @@ Style/IndentHeredoc:
Enabled: false Enabled: false
Style/FormatString: Style/FormatString:
Enabled: false Enabled: false
Style/GuardClause:
Enabled: false
Style/PercentLiteralDelimiters: # Contradicting rule
Enabled: false
Style/SymbolArray: # Undefined syntax in Ruby 1.9.3
Enabled: false

View File

@ -10,6 +10,6 @@ desc 'Run rake task'
RSpec::Core::RakeTask.new(:spec) RSpec::Core::RakeTask.new(:spec)
desc 'Does rubocop lint and runs the specs' desc 'Does rubocop lint and runs the specs'
task all: %i[rubocop spec] task all: [:rubocop, :spec]
task default: :all task default: :all

View File

@ -75,7 +75,7 @@ module Google
# JSON key. # JSON key.
def self.read_json_key(json_key_io) def self.read_json_key(json_key_io)
json_key = MultiJson.load(json_key_io.read) json_key = MultiJson.load(json_key_io.read)
wanted = %w[client_id client_secret refresh_token] wanted = %w(client_id client_secret refresh_token)
wanted.each do |key| wanted.each do |key|
raise "the json is missing the #{key} field" unless json_key.key?(key) raise "the json is missing the #{key} field" unless json_key.key?(key)
end end

View File

@ -227,7 +227,7 @@ module Google
# @param [Rack::Request] request # @param [Rack::Request] request
# Current request # Current request
def self.validate_callback_state(state, request) def self.validate_callback_state(state, request)
if state[AUTH_CODE_KEY].nil? # rubocop:disable Style/GuardClause if state[AUTH_CODE_KEY].nil?
raise Signet::AuthorizationError, MISSING_AUTH_CODE_ERROR raise Signet::AuthorizationError, MISSING_AUTH_CODE_ERROR
elsif state[ERROR_CODE_KEY] elsif state[ERROR_CODE_KEY]
raise Signet::AuthorizationError, raise Signet::AuthorizationError,

View File

@ -70,7 +70,7 @@ describe Google::Auth::ScopeUtil do
context 'with scope as Array' do context 'with scope as Array' do
let(:source) do let(:source) do
%w[email profile openid https://www.googleapis.com/auth/drive] %w(email profile openid https://www.googleapis.com/auth/drive)
end end
it_behaves_like 'normalizes scopes' it_behaves_like 'normalizes scopes'
end end

View File

@ -41,7 +41,7 @@ describe Google::Auth::UserAuthorizer do
include TestHelpers include TestHelpers
let(:client_id) { Google::Auth::ClientId.new('testclient', 'notasecret') } let(:client_id) { Google::Auth::ClientId.new('testclient', 'notasecret') }
let(:scope) { %w[email profile] } let(:scope) { %w(email profile) }
let(:token_store) { DummyTokenStore.new } let(:token_store) { DummyTokenStore.new }
let(:callback_uri) { 'https://www.example.com/oauth/callback' } let(:callback_uri) { 'https://www.example.com/oauth/callback' }
let(:authorizer) do let(:authorizer) do
@ -173,7 +173,7 @@ describe Google::Auth::UserAuthorizer do
end end
it 'should return credentials with a valid scope' do it 'should return credentials with a valid scope' do
expect(credentials.scope).to eq %w[email profile] expect(credentials.scope).to eq %w(email profile)
end end
it 'should return credentials with a valid expiration time' do it 'should return credentials with a valid expiration time' do

View File

@ -115,7 +115,7 @@ describe Google::Auth::UserRefreshCredentials do
end end
it 'fails if the GOOGLE_APPLICATION_CREDENTIALS path file is invalid' do it 'fails if the GOOGLE_APPLICATION_CREDENTIALS path file is invalid' do
needed = %w[client_id client_secret refresh_token] needed = %w(client_id client_secret refresh_token)
needed.each do |missing| needed.each do |missing|
Dir.mktmpdir do |dir| Dir.mktmpdir do |dir|
key_path = File.join(dir, 'my_cert_file') key_path = File.join(dir, 'my_cert_file')
@ -169,7 +169,7 @@ describe Google::Auth::UserRefreshCredentials do
end end
it 'fails if the file is invalid' do it 'fails if the file is invalid' do
needed = %w[client_id client_secret refresh_token] needed = %w(client_id client_secret refresh_token)
needed.each do |missing| needed.each do |missing|
Dir.mktmpdir do |dir| Dir.mktmpdir do |dir|
key_path = File.join(dir, '.config', @known_path) key_path = File.join(dir, '.config', @known_path)
@ -208,7 +208,7 @@ describe Google::Auth::UserRefreshCredentials do
end end
it 'fails if the file is invalid' do it 'fails if the file is invalid' do
needed = %w[client_id client_secret refresh_token] needed = %w(client_id client_secret refresh_token)
needed.each do |missing| needed.each do |missing|
FakeFS do FakeFS do
FileUtils.mkdir_p(File.dirname(@path)) FileUtils.mkdir_p(File.dirname(@path))

View File

@ -42,7 +42,7 @@ describe Google::Auth::WebUserAuthorizer do
include TestHelpers include TestHelpers
let(:client_id) { Google::Auth::ClientId.new('testclient', 'notasecret') } let(:client_id) { Google::Auth::ClientId.new('testclient', 'notasecret') }
let(:scope) { %w[email profile] } let(:scope) { %w(email profile) }
let(:token_store) { DummyTokenStore.new } let(:token_store) { DummyTokenStore.new }
let(:authorizer) do let(:authorizer) do
Google::Auth::WebUserAuthorizer.new(client_id, scope, token_store) Google::Auth::WebUserAuthorizer.new(client_id, scope, token_store)