Skip to content

Commit

Permalink
Upgrade Rubocop to 0.43 (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeu2000 authored and igrigorik committed Oct 12, 2016
1 parent 5998269 commit f7dc3d6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -10,7 +10,7 @@ group :test do
gem 'pry-byebug', platform: :mri
gem 'rspec', '~> 3.4.0'
gem 'rspec-autotest'
gem 'rubocop', '~> 0.40.0'
gem 'rubocop', '~> 0.43'
end

gemspec
4 changes: 2 additions & 2 deletions lib/http/2/compressor.rb
Expand Up @@ -527,12 +527,12 @@ def header(buf)

case header[:type]
when :indexed
fail CompressionError if header[:name] == 0
fail CompressionError if (header[:name]).zero?
header[:name] -= 1
when :changetablesize
header[:value] = header[:name]
else
if header[:name] == 0
if (header[:name]).zero?
header[:name] = string(buf)
else
header[:name] -= 1
Expand Down
8 changes: 4 additions & 4 deletions lib/http/2/connection.rb
Expand Up @@ -379,7 +379,7 @@ def encode(frame)
# @param frame [Hash]
# @return [Boolean]
def connection_frame?(frame)
frame[:stream] == 0 ||
(frame[:stream]).zero? ||
frame[:type] == :settings ||
frame[:type] == :ping ||
frame[:type] == :goaway
Expand Down Expand Up @@ -445,11 +445,11 @@ def validate_settings(role, settings)
# Clients MUST reject any attempt to change the
# SETTINGS_ENABLE_PUSH setting to a value other than 0 by treating the
# message as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.
return ProtocolError.new("invalid #{key} value") unless v == 0
return ProtocolError.new("invalid #{key} value") unless v.zero?
when :client
# Any value other than 0 or 1 MUST be treated as a
# connection error (Section 5.4.1) of type PROTOCOL_ERROR.
unless v == 0 || v == 1
unless v.zero? || v == 1
return ProtocolError.new("invalid #{key} value")
end
end
Expand Down Expand Up @@ -483,7 +483,7 @@ def validate_settings(role, settings)
#
# @param frame [Hash]
def connection_settings(frame)
connection_error unless frame[:type] == :settings && frame[:stream] == 0
connection_error unless frame[:type] == :settings && (frame[:stream]).zero?

# Apply settings.
# side =
Expand Down
10 changes: 5 additions & 5 deletions lib/http/2/framer.rb
Expand Up @@ -216,7 +216,7 @@ def generate(frame)
length += 4

when :settings
if frame[:stream] != 0
if (frame[:stream]).nonzero?
fail CompressionError, "Invalid stream ID (#{frame[:stream]})"
end

Expand Down Expand Up @@ -357,14 +357,14 @@ def parse(buf)
if frame[:flags].include? :priority
e_sd = payload.read_uint32
frame[:stream_dependency] = e_sd & RBIT
frame[:exclusive] = (e_sd & EBIT) != 0
frame[:exclusive] = (e_sd & EBIT) != 0 # rubocop:disable Style/NumericPredicate
frame[:weight] = payload.getbyte + 1
end
frame[:payload] = payload.read(frame[:length])
when :priority
e_sd = payload.read_uint32
frame[:stream_dependency] = e_sd & RBIT
frame[:exclusive] = (e_sd & EBIT) != 0
frame[:exclusive] = (e_sd & EBIT) != 0 # rubocop:disable Style/NumericPredicate
frame[:weight] = payload.getbyte + 1
when :rst_stream
frame[:error] = unpack_error payload.read_uint32
Expand All @@ -373,11 +373,11 @@ def parse(buf)
# NOTE: frame[:length] might not match the number of frame[:payload]
# because unknown extensions are ignored.
frame[:payload] = []
unless frame[:length] % 6 == 0
unless (frame[:length] % 6).zero?
fail ProtocolError, 'Invalid settings payload length'
end

if frame[:stream] != 0
if (frame[:stream]).nonzero?
fail ProtocolError, "Invalid stream ID (#{frame[:stream]})"
end

Expand Down
6 changes: 3 additions & 3 deletions lib/tasks/generate_huffman_table.rb
Expand Up @@ -25,10 +25,10 @@ def initialize(depth)

def add(code, len, chr)
self.final = true if chr == EOS && @depth <= 7
if len == 0
if len.zero?
@emit = chr
else
bit = (code & (1 << (len - 1))) == 0 ? 0 : 1
bit = (code & (1 << (len - 1))).zero? ? 0 : 1
node = @next[bit] ||= Node.new(@depth + 1)
node.add(code, len - 1, chr)
end
Expand Down Expand Up @@ -68,7 +68,7 @@ def self.generate_machine
n = node
emit = ''
(BITS_AT_ONCE - 1).downto(0) do |i|
bit = (input & (1 << i)) == 0 ? 0 : 1
bit = (input & (1 << i)).zero? ? 0 : 1
n = n.next[bit]
next unless n.emit
if n.emit == EOS
Expand Down

0 comments on commit f7dc3d6

Please sign in to comment.