Skip to content

Commit

Permalink
rubocop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Bakken committed Jun 15, 2016
1 parent 5f81839 commit c0c8815
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 28 deletions.
8 changes: 4 additions & 4 deletions lib/riak/bucket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class Bucket
# @param [Client] client the {Riak::Client} for this bucket
# @param [String] name the name of the bucket
def initialize(client, name)
fail ArgumentError, t('client_type', :client => client.inspect) unless Client === client
fail ArgumentError, t('string_type', :string => name.inspect) unless String === name
fail ArgumentError, t('zero_length_bucket') if name == ''
raise ArgumentError, t('client_type', :client => client.inspect) unless Client === client
raise ArgumentError, t('string_type', :string => name.inspect) unless String === name
raise ArgumentError, t('zero_length_bucket') if name == ''
@client, @name = client, name
end

Expand Down Expand Up @@ -71,7 +71,7 @@ def keys(options = {}, &block)
# @raise [FailedRequest] if the new properties were not accepted by the Riakserver
# @see #n_value, #allow_mult, #r, #w, #dw, #rw
def props=(properties)
fail ArgumentError, t("hash_type", :hash => properties.inspect) unless Hash === properties
raise ArgumentError, t("hash_type", :hash => properties.inspect) unless Hash === properties
props.merge!(properties)
@client.set_bucket_props(self, properties)
props
Expand Down
4 changes: 2 additions & 2 deletions lib/riak/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ def get_many(pairs)

# Get an object. See Bucket#get
def get_object(bucket, key, options = {})
fail ArgumentError, t('zero_length_key') if key == ''
fail ArgumentError, t('string_type', :string => key) unless String === key
raise ArgumentError, t('zero_length_key') if key == ''
raise ArgumentError, t('string_type', :string => key) unless key.is_a? String
backend do |b|
b.fetch_object(bucket, key, options)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/riak/client/beefcake/protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def write(code, message = nil)
#
# @return [Array<Symbol, String>]
def receive
if read_timeout and !IO.select([socket], nil, nil, read_timeout)
if read_timeout && !IO.select([socket], nil, nil, read_timeout)
raise Errno::ETIMEDOUT, 'read timeout'
end
header = socket.read 5
Expand Down
2 changes: 1 addition & 1 deletion lib/riak/client/beefcake/ts_cell_codec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def check_bignum_range(bignum)
end

def timestamp(cell)
return false unless Integer === cell.timestamp_value
return false unless cell.timestamp_value.is_a? Integer
return cell.timestamp_value unless @convert_timestamp
tsv = cell.timestamp_value
secs = tsv / 1000
Expand Down
8 changes: 4 additions & 4 deletions lib/riak/counter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class Counter
# @param [Bucket] bucket the {Riak::Bucket} for this counter
# @param [String] key the name of the counter
def initialize(bucket, key)
fail ArgumentError, t('bucket_type', bucket: bucket.inspect) unless Bucket === bucket
fail ArgumentError, t('string_type', string: key.inspect) unless String === key
raise ArgumentError, t('bucket_type', bucket: bucket.inspect) unless bucket.is_a? Bucket
raise ArgumentError, t('string_type', string: key.inspect) unless key.is_a? String
@bucket, @key = bucket, key
@client = bucket.client

Expand Down Expand Up @@ -79,11 +79,11 @@ def decrement(amount = 1, options = {})

private
def validate_bucket
fail ArgumentError, t("counter.bucket_needs_allow_mult") unless bucket.allow_mult
raise ArgumentError, t("counter.bucket_needs_allow_mult") unless bucket.allow_mult
end

def validate_amount(amount)
fail ArgumentError, t("counter.increment_by_integer") unless amount.is_a? Integer
raise ArgumentError, t("counter.increment_by_integer") unless amount.is_a? Integer
end

def backend(&blk)
Expand Down
8 changes: 5 additions & 3 deletions lib/riak/robject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,12 @@ def load_from_mapreduce(response)
# @raise [Conflict] if the object has siblings
def store(options = {})
fail Conflict, self if conflict?
fail ArgumentError, t('content_type_undefined') unless content_type.present?
fail ArgumentError, t('zero_length_key') if key == ''
raise ArgumentError, t('content_type_undefined') unless content_type.present?
raise ArgumentError, t('zero_length_key') if key == ''
# NB: key can be nil to indicate that Riak should generate one
fail ArgumentError, t('string_type', :string => key) unless key.nil? or String === key
unless key.nil? || key.is_a?(String)
raise ArgumentError, t('string_type', :string => key)
end
@bucket.client.store_object(self, default(options))
self
end
Expand Down
25 changes: 12 additions & 13 deletions spec/integration/riak/protobuffs/timeouts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
port = 0

server = nil
thr = Thread.new {
thr = Thread.new do
server = TCPServer.new port
port = server.addr[1]
ok_to_continue = true
Expand All @@ -36,8 +36,8 @@
loop do
p = Riak::Client::BeefcakeProtobuffsBackend::Protocol.new s
begin
msgname, body = p.receive
rescue IOError => e
msgname, _body = p.receive
rescue IOError
break if quitting
raise
end
Expand All @@ -50,12 +50,12 @@
end
end
end
rescue IOError => e
rescue IOError
break if quitting
raise
end
end
}
end

loop do
break if ok_to_continue
Expand Down Expand Up @@ -86,7 +86,7 @@
server.close
thr.join

ping_count > max_ping_attempts and fail 'did not see expected timeout!'
expect(ping_count).to be < max_ping_attempts
end

it 'raises error on write timeout' do
Expand All @@ -95,19 +95,18 @@
port = 0

server = nil
thr = Thread.new {
thr = Thread.new do
server = TCPServer.new port
port = server.addr[1]
ok_to_continue = true
put_count = 0
loop do
begin
Thread.start(server.accept) do |s|
loop do
p = Riak::Client::BeefcakeProtobuffsBackend::Protocol.new s
begin
msgname, body = p.receive
rescue IOError => e
msgname, _body = p.receive
rescue IOError
break if quitting
raise
end
Expand All @@ -127,12 +126,12 @@
end
end
end
rescue IOError => e
rescue IOError
break if quitting
raise
end
end
}
end

loop do
break if ok_to_continue
Expand Down Expand Up @@ -169,7 +168,7 @@
server.close
thr.join

store_count > max_store_attempts and fail 'did not see expected timeout!'
expect(store_count).to be < max_store_attempts
end
end
end

0 comments on commit c0c8815

Please sign in to comment.