Skip to content

Commit 0b1dbb6

Browse files
committed
Merge pull request googleapis#208 from blowmage/fix-warnings
Fix warnings
2 parents fb3fc46 + 3eb18d6 commit 0b1dbb6

File tree

6 files changed

+39
-37
lines changed

6 files changed

+39
-37
lines changed

lib/google/api_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def verify_id_token!
490490
else
491491
check_cached_certs = lambda do
492492
valid = false
493-
for key, cert in @certificates
493+
for _key, cert in @certificates
494494
begin
495495
self.authorization.decoded_id_token(cert.public_key)
496496
valid = true

lib/google/api_client/auth/key_utils.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,44 @@ module KeyUtils
2525
#
2626
# @param [String] keyfile
2727
# Path of the PKCS12 file to load. If not a path to an actual file,
28-
# assumes the string is the content of the file itself.
28+
# assumes the string is the content of the file itself.
2929
# @param [String] passphrase
3030
# Passphrase for unlocking the private key
3131
#
3232
# @return [OpenSSL::PKey] The private key for signing assertions.
3333
def self.load_from_pkcs12(keyfile, passphrase)
34-
load_key(keyfile, passphrase) do |content, passphrase|
35-
OpenSSL::PKCS12.new(content, passphrase).key
34+
load_key(keyfile, passphrase) do |content, pass_phrase|
35+
OpenSSL::PKCS12.new(content, pass_phrase).key
3636
end
3737
end
38-
38+
3939

4040
##
4141
# Loads a key from a PEM file.
4242
#
4343
# @param [String] keyfile
4444
# Path of the PEM file to load. If not a path to an actual file,
45-
# assumes the string is the content of the file itself.
45+
# assumes the string is the content of the file itself.
4646
# @param [String] passphrase
4747
# Passphrase for unlocking the private key
4848
#
4949
# @return [OpenSSL::PKey] The private key for signing assertions.
5050
#
5151
def self.load_from_pem(keyfile, passphrase)
52-
load_key(keyfile, passphrase) do | content, passphrase|
53-
OpenSSL::PKey::RSA.new(content, passphrase)
52+
load_key(keyfile, passphrase) do | content, pass_phrase|
53+
OpenSSL::PKey::RSA.new(content, pass_phrase)
5454
end
5555
end
5656

5757
private
58-
58+
5959
##
6060
# Helper for loading keys from file or memory. Accepts a block
6161
# to handle the specific file format.
6262
#
6363
# @param [String] keyfile
6464
# Path of thefile to load. If not a path to an actual file,
65-
# assumes the string is the content of the file itself.
65+
# assumes the string is the content of the file itself.
6666
# @param [String] passphrase
6767
# Passphrase for unlocking the private key
6868
#
@@ -86,8 +86,8 @@ def self.load_key(keyfile, passphrase, &block)
8686
block.call(content, passphrase)
8787
rescue OpenSSL::OpenSSLError
8888
raise ArgumentError.new("Invalid keyfile or passphrase")
89-
end
90-
end
89+
end
90+
end
9191
end
9292
end
9393
end

lib/google/api_client/auth/storage.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Storage
3838
# @params [Object] Storage object
3939
def initialize(store)
4040
@store= store
41+
@authorization = nil
4142
end
4243

4344
##

lib/google/api_client/batch.rb

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class BatchedCallResponse
3535

3636
##
3737
# Initialize the call response
38-
#
38+
#
3939
# @param [String] call_id
4040
# UUID of the original call
4141
# @param [Fixnum] status
@@ -48,7 +48,7 @@ def initialize(call_id, status = nil, headers = nil, body = nil)
4848
@call_id, @status, @headers, @body = call_id, status, headers, body
4949
end
5050
end
51-
51+
5252
# Wraps multiple API calls into a single over-the-wire HTTP request.
5353
#
5454
# @example
@@ -58,7 +58,7 @@ def initialize(call_id, status = nil, headers = nil, body = nil)
5858
# batch = Google::APIClient::BatchRequest.new do |result|
5959
# puts result.data
6060
# end
61-
#
61+
#
6262
# batch.add(:api_method => urlshortener.url.insert, :body_object => { 'longUrl' => 'http://example.com/foo' })
6363
# batch.add(:api_method => urlshortener.url.insert, :body_object => { 'longUrl' => 'http://example.com/bar' })
6464
#
@@ -80,16 +80,17 @@ class BatchRequest < Request
8080
# Callback for every call's response. Won't be called if a call defined
8181
# a callback of its own.
8282
#
83-
# @return [Google::APIClient::BatchRequest]
83+
# @return [Google::APIClient::BatchRequest]
8484
# The constructed object.
8585
#
8686
# @yield [Google::APIClient::Result]
8787
# block to be called when result ready
8888
def initialize(options = {}, &block)
8989
@calls = []
90+
@global_callback = nil
9091
@global_callback = block if block_given?
9192
@last_auto_id = 0
92-
93+
9394
@base_id = SecureRandom.uuid
9495

9596
options[:uri] ||= 'https://www.googleapis.com/batch'
@@ -104,7 +105,7 @@ def initialize(options = {}, &block)
104105
# automatically be generated, avoiding collisions. If duplicate call IDs
105106
# are provided, an error will be thrown.
106107
#
107-
# @param [Hash, Google::APIClient::Request] call
108+
# @param [Hash, Google::APIClient::Request] call
108109
# the call to be added.
109110
# @param [String] call_id
110111
# the ID to be used for this call. Must be unique
@@ -126,7 +127,7 @@ def add(call, call_id = nil, &block)
126127
'A call with this ID already exists: %s' % call_id
127128
end
128129
callback = block_given? ? block : @global_callback
129-
@calls << [call_id, call, callback]
130+
@calls << [call_id, call, callback]
130131
return self
131132
end
132133

@@ -165,12 +166,12 @@ def to_http_request
165166
if @calls.nil? || @calls.empty?
166167
raise BatchError, 'Cannot make an empty batch request'
167168
end
168-
parts = @calls.map {|(call_id, call, callback)| serialize_call(call_id, call)}
169+
parts = @calls.map {|(call_id, call, _callback)| serialize_call(call_id, call)}
169170
build_multipart(parts, 'multipart/mixed', BATCH_BOUNDARY)
170171
super
171172
end
172-
173-
173+
174+
174175
protected
175176

176177
##
@@ -183,7 +184,7 @@ def to_http_request
183184
# @param [Hash] headers
184185
# the hash of headers and their values.
185186
#
186-
# @return [String]
187+
# @return [String]
187188
# the value of the desired header.
188189
def find_header(name, headers)
189190
_, header = headers.detect do |h, v|
@@ -197,7 +198,7 @@ def find_header(name, headers)
197198
#
198199
# @api private
199200
#
200-
# @return [String]
201+
# @return [String]
201202
# the new, unique ID.
202203
def new_id
203204
@last_auto_id += 1
@@ -216,15 +217,15 @@ def new_id
216217
# @param [String] header
217218
# Content-ID header value.
218219
#
219-
# @return [String]
220+
# @return [String]
220221
# The extracted ID value.
221222
def header_to_id(header)
222223
if !header.start_with?('<') || !header.end_with?('>') ||
223224
!header.include?('+')
224225
raise BatchError, 'Invalid value for Content-ID: "%s"' % header
225226
end
226227

227-
base, call_id = header[1...-1].split('+')
228+
_base, call_id = header[1...-1].split('+')
228229
return Addressable::URI.unencode(call_id)
229230
end
230231

@@ -236,7 +237,7 @@ def header_to_id(header)
236237
# @param [String] response
237238
# the response to parse.
238239
#
239-
# @return [Array<Hash>, String]
240+
# @return [Array<Hash>, String]
240241
# the headers and the body, separately.
241242
def split_headers_and_body(response)
242243
headers = {}
@@ -263,12 +264,12 @@ def split_headers_and_body(response)
263264
# @param [String] call_response
264265
# the request to deserialize.
265266
#
266-
# @return [Google::APIClient::BatchedCallResponse]
267+
# @return [Google::APIClient::BatchedCallResponse]
267268
# the parsed and converted response.
268269
def deserialize_call_response(call_response)
269270
outer_headers, outer_body = split_headers_and_body(call_response)
270271
status_line, payload = outer_body.split("\n", 2)
271-
protocol, status, reason = status_line.split(' ', 3)
272+
_protocol, status, _reason = status_line.split(' ', 3)
272273

273274
headers, body = split_headers_and_body(payload)
274275
content_id = find_header('Content-ID', outer_headers)
@@ -284,7 +285,7 @@ def deserialize_call_response(call_response)
284285
# @param [Google::APIClient::Request] call
285286
# the call to serialize.
286287
#
287-
# @return [Faraday::UploadIO]
288+
# @return [Faraday::UploadIO]
288289
# the serialized request
289290
def serialize_call(call_id, call)
290291
method, uri, headers, body = call.to_http_request
@@ -293,7 +294,7 @@ def serialize_call(call_id, call)
293294
request << "\r\n%s: %s" % [header, value]
294295
end
295296
if body
296-
# TODO - CompositeIO if body is a stream
297+
# TODO - CompositeIO if body is a stream
297298
request << "\r\n\r\n"
298299
if body.respond_to?(:read)
299300
request << body.read
@@ -303,7 +304,7 @@ def serialize_call(call_id, call)
303304
end
304305
Faraday::UploadIO.new(StringIO.new(request), 'application/http', 'ruby-api-request', 'Content-ID' => id_to_header(call_id))
305306
end
306-
307+
307308
##
308309
# Convert an id to a Content-ID header value.
309310
#
@@ -319,7 +320,7 @@ def serialize_call(call_id, call)
319320
def id_to_header(call_id)
320321
return '<%s+%s>' % [@base_id, Addressable::URI.encode(call_id)]
321322
end
322-
323+
323324
end
324325
end
325326
end

lib/google/api_client/request.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class APIClient
2727
# Represents an API request.
2828
class Request
2929
include Google::APIClient::Logging
30-
30+
3131
MULTIPART_BOUNDARY = "-----------RubyApiMultipartPost".freeze
3232

3333
# @return [Hash] Request parameters
@@ -157,7 +157,7 @@ def uri=(new_uri)
157157
# @return [Google::APIClient::Result]
158158
# result of API request
159159
def send(connection, is_retry = false)
160-
self.body.rewind if is_retry && self.body.respond_to?(:rewind)
160+
self.body.rewind if is_retry && self.body.respond_to?(:rewind)
161161
env = self.to_env(connection)
162162
logger.debug { "#{self.class} Sending API request #{env[:method]} #{env[:url].to_s} #{env[:request_headers]}" }
163163
http_response = connection.app.call(env)
@@ -244,7 +244,7 @@ def to_env(connection)
244244
)
245245
end
246246

247-
request_env = http_request.to_env(connection)
247+
http_request.to_env(connection)
248248
end
249249

250250
##

lib/google/api_client/service/simple_file_store.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def delete(name, options = nil)
124124
# Read the entire cache file from disk.
125125
# Will avoid reading if there have been no changes.
126126
def read_file
127-
if !File.exists? @file_path
127+
if !File.exist? @file_path
128128
@cache = nil
129129
else
130130
# Check for changes after our last read or write.

0 commit comments

Comments
 (0)