Skip to content

Commit 5d6653f

Browse files
author
TheRoyalTnetennba
committed
remove needless parenthesis
1 parent a9c40e3 commit 5d6653f

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

lib/googleauth/client_id.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class << self
6464
# & secrets in source. See {#from_file} to load from
6565
# `client_secrets.json` files.
6666
def initialize(id, secret)
67-
CredentialsLoader.warn_if_cloud_sdk_credentials(id)
67+
CredentialsLoader.warn_if_cloud_sdk_credentials id
6868
raise 'Client id can not be nil' if id.nil?
6969
raise 'Client secret can not be nil' if secret.nil?
7070
@id = id
@@ -81,7 +81,7 @@ def self.from_file(file)
8181
raise 'File can not be nil.' if file.nil?
8282
File.open(file.to_s) do |f|
8383
json = f.read
84-
config = MultiJson.load(json)
84+
config = MultiJson.load json
8585
from_hash(config)
8686
end
8787
end

lib/googleauth/credentials.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def initialize(keyfile, options = {})
6868
json['scope'] ||= scope
6969
@client = init_client json
7070
end
71-
CredentialsLoader.warn_if_cloud_sdk_credentials(@client.client_id)
71+
CredentialsLoader.warn_if_cloud_sdk_credentials @client.client_id
7272
@client.fetch_access_token!
7373
end
7474

@@ -79,16 +79,16 @@ def initialize(keyfile, options = {})
7979
def self.default(options = {})
8080
scope = options[:scope]
8181
# First try to find keyfile file from environment variables.
82-
client = from_path_vars(scope)
82+
client = from_path_vars scope
8383

8484
# Second try to find keyfile json from environment variables.
85-
client ||= from_json_vars(scope)
85+
client ||= from_json_vars scope
8686

8787
# Third try to find keyfile file from known file paths.
88-
client ||= from_default_paths(scope)
88+
client ||= from_default_paths scope
8989

9090
# Finally get instantiated client from Google::Auth
91-
client ||= from_application_default(scope)
91+
client ||= from_application_default scope
9292
client
9393
end
9494

lib/googleauth/credentials_loader.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def from_system_default_path(scope = nil)
132132

133133
# Issues warning if cloud sdk client id is used
134134
def warn_if_cloud_sdk_credentials(client_id)
135-
warn(CLOUD_SDK_CREDENTIALS_WARNING) if client_id == CLOUD_SDK_CLIENT_ID
135+
warn CLOUD_SDK_CREDENTIALS_WARNING if client_id == CLOUD_SDK_CLIENT_ID
136136
end
137137

138138
private

lib/googleauth/default_credentials.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ def self.make_creds(options = {})
4949
json_key_io, scope = options.values_at(:json_key_io, :scope)
5050
if json_key_io
5151
json_key, clz = determine_creds_class(json_key_io)
52-
warn_if_cloud_sdk_credentials(json_key['client_id'])
52+
warn_if_cloud_sdk_credentials json_key['client_id']
5353
clz.make_creds(json_key_io: StringIO.new(MultiJson.dump(json_key)),
5454
scope: scope)
5555
else
56-
warn_if_cloud_sdk_credentials(ENV[CLIENT_ID_VAR])
56+
warn_if_cloud_sdk_credentials ENV[CLIENT_ID_VAR]
5757
clz = read_creds
5858
clz.make_creds(scope: scope)
5959
end
@@ -75,7 +75,7 @@ def self.read_creds
7575

7676
# Reads the input json and determines which creds class to use.
7777
def self.determine_creds_class(json_key_io)
78-
json_key = MultiJson.load(json_key_io.read)
78+
json_key = MultiJson.load json_key_io.read
7979
key = 'type'
8080
raise "the json is missing the '#{key}' field" unless json_key.key?(key)
8181
type = json_key[key]

spec/googleauth/client_id_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
shared_examples 'it can successfully load client_id' do
5050
context 'loaded from hash' do
51-
let(:client_id) { Google::Auth::ClientId.from_hash(config) }
51+
let(:client_id) { Google::Auth::ClientId.from_hash config }
5252

5353
it_behaves_like 'it has a valid config'
5454
end
@@ -103,7 +103,7 @@
103103
end
104104

105105
it 'should raise error' do
106-
expect { Google::Auth::ClientId.from_hash(config) }.to raise_error(
106+
expect { Google::Auth::ClientId.from_hash config }.to raise_error(
107107
/Expected top level property/
108108
)
109109
end
@@ -119,7 +119,7 @@
119119
end
120120

121121
it 'should raise error' do
122-
expect { Google::Auth::ClientId.from_hash(config) }.to raise_error(
122+
expect { Google::Auth::ClientId.from_hash config }.to raise_error(
123123
/Client id can not be nil/
124124
)
125125
end
@@ -135,7 +135,7 @@
135135
end
136136

137137
it 'should raise error' do
138-
expect { Google::Auth::ClientId.from_hash(config) }.to raise_error(
138+
expect { Google::Auth::ClientId.from_hash config }.to raise_error(
139139
/Client secret can not be nil/
140140
)
141141
end
@@ -152,7 +152,7 @@
152152
end
153153

154154
it 'should raise warning' do
155-
expect { Google::Auth::ClientId.from_hash(config) }.to output(
155+
expect { Google::Auth::ClientId.from_hash config }.to output(
156156
Google::Auth::CredentialsLoader::CLOUD_SDK_CREDENTIALS_WARNING + "\n"
157157
).to_stderr
158158
end

spec/googleauth/get_application_default_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
Dir.mktmpdir do |dir|
6464
key_path = File.join(dir, 'does-not-exist')
6565
ENV[@var_name] = key_path
66-
expect { Google::Auth.get_application_default(@scope, options) }
66+
expect { Google::Auth.get_application_default @scope, options }
6767
.to raise_error RuntimeError
6868
end
6969
end
@@ -76,7 +76,7 @@
7676
ENV.delete(@var_name) unless ENV[@var_name].nil? # no env var
7777
ENV['HOME'] = dir # no config present in this tmp dir
7878
expect do
79-
Google::Auth.get_application_default(@scope, options)
79+
Google::Auth.get_application_default @scope, options
8080
end.to raise_error RuntimeError
8181
end
8282
expect(stub).to have_been_requested
@@ -90,7 +90,7 @@
9090
FileUtils.mkdir_p(File.dirname(key_path))
9191
File.write(key_path, cred_json_text)
9292
ENV[@var_name] = key_path
93-
expect(Google::Auth.get_application_default(@scope, options))
93+
expect(Google::Auth.get_application_default @scope, options)
9494
.to_not be_nil
9595
end
9696
end
@@ -102,7 +102,7 @@
102102
FileUtils.mkdir_p(File.dirname(key_path))
103103
File.write(key_path, cred_json_text)
104104
ENV['HOME'] = dir
105-
expect(Google::Auth.get_application_default(@scope, options))
105+
expect(Google::Auth.get_application_default @scope, options)
106106
.to_not be_nil
107107
end
108108
end
@@ -114,7 +114,7 @@
114114
FileUtils.mkdir_p(File.dirname(key_path))
115115
File.write(key_path, cred_json_text)
116116
ENV['HOME'] = dir
117-
expect(Google::Auth.get_application_default(nil, options)).to_not be_nil
117+
expect(Google::Auth.get_application_default nil, options).to_not be_nil
118118
end
119119
end
120120

@@ -125,7 +125,7 @@
125125
Dir.mktmpdir do |dir|
126126
ENV.delete(@var_name) unless ENV[@var_name].nil? # no env var
127127
ENV['HOME'] = dir # no config present in this tmp dir
128-
creds = Google::Auth.get_application_default(@scope, options)
128+
creds = Google::Auth.get_application_default @scope, options
129129
expect(creds).to_not be_nil
130130
end
131131
expect(stub).to have_been_requested
@@ -137,7 +137,7 @@
137137
key_path = File.join('/etc/google/auth/', CREDENTIALS_FILE_NAME)
138138
FileUtils.mkdir_p(File.dirname(key_path))
139139
File.write(key_path, cred_json_text)
140-
expect(Google::Auth.get_application_default(@scope, options))
140+
expect(Google::Auth.get_application_default @scope, options)
141141
.to_not be_nil
142142
File.delete(key_path)
143143
end
@@ -151,7 +151,7 @@
151151
ENV[CLIENT_SECRET_VAR] = cred_json[:client_secret]
152152
ENV[REFRESH_TOKEN_VAR] = cred_json[:refresh_token]
153153
ENV[ACCOUNT_TYPE_VAR] = cred_json[:type]
154-
expect(Google::Auth.get_application_default(@scope, options))
154+
expect(Google::Auth.get_application_default @scope, options)
155155
.to_not be_nil
156156
end
157157

@@ -163,7 +163,7 @@
163163
ENV[CLIENT_SECRET_VAR] = cred_json[:client_secret]
164164
ENV[REFRESH_TOKEN_VAR] = cred_json[:refresh_token]
165165
ENV[ACCOUNT_TYPE_VAR] = cred_json[:type]
166-
expect { Google::Auth.get_application_default(@scope, options) }.to output(
166+
expect { Google::Auth.get_application_default @scope, options }.to output(
167167
Google::Auth::CredentialsLoader::CLOUD_SDK_CREDENTIALS_WARNING + "\n"
168168
).to_stderr
169169
end
@@ -229,7 +229,7 @@ def cred_json_text
229229
File.write(key_path, cred_json_text)
230230
ENV[@var_name] = key_path
231231
expect do
232-
Google::Auth.get_application_default(@scope, options)
232+
Google::Auth.get_application_default @scope, options
233233
end.to raise_error RuntimeError
234234
end
235235
end
@@ -242,7 +242,7 @@ def cred_json_text
242242
File.write(key_path, cred_json_text)
243243
ENV['HOME'] = dir
244244
expect do
245-
Google::Auth.get_application_default(@scope, options)
245+
Google::Auth.get_application_default @scope, options
246246
end.to raise_error RuntimeError
247247
end
248248
end
@@ -251,7 +251,7 @@ def cred_json_text
251251
ENV[PRIVATE_KEY_VAR] = cred_json[:private_key]
252252
ENV[CLIENT_EMAIL_VAR] = cred_json[:client_email]
253253
expect do
254-
Google::Auth.get_application_default(@scope, options)
254+
Google::Auth.get_application_default @scope, options
255255
end.to raise_error RuntimeError
256256
end
257257
end

0 commit comments

Comments
 (0)