Fix Style/UnpackFirst cop.

This commit is contained in:
Robert Haines 2019-09-22 11:23:35 +01:00
parent 4e1b679c73
commit 2dfe092728
5 changed files with 6 additions and 15 deletions

View File

@ -335,15 +335,6 @@ Style/TrailingCommaInHashLiteral:
Exclude: Exclude:
- 'lib/zip/constants.rb' - 'lib/zip/constants.rb'
# Offense count: 6
# Cop supports --auto-correct.
Style/UnpackFirst:
Exclude:
- 'lib/zip/entry.rb'
- 'lib/zip/extra_field.rb'
- 'lib/zip/extra_field/generic.rb'
- 'lib/zip/extra_field/zip64.rb'
# Offense count: 247 # Offense count: 247
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.

View File

@ -194,15 +194,15 @@ module Zip
class << self class << self
def read_zip_short(io) # :nodoc: def read_zip_short(io) # :nodoc:
io.read(2).unpack('v')[0] io.read(2).unpack1('v')
end end
def read_zip_long(io) # :nodoc: def read_zip_long(io) # :nodoc:
io.read(4).unpack('V')[0] io.read(4).unpack1('V')
end end
def read_zip_64_long(io) # :nodoc: def read_zip_64_long(io) # :nodoc:
io.read(8).unpack('Q<')[0] io.read(8).unpack1('Q<')
end end
def read_c_dir_entry(io) #:nodoc:all def read_c_dir_entry(io) #:nodoc:all

View File

@ -40,7 +40,7 @@ module Zip
i = 0 i = 0
while i < binstr.bytesize while i < binstr.bytesize
id = binstr[i, 2] id = binstr[i, 2]
len = binstr[i + 2, 2].to_s.unpack('v').first len = binstr[i + 2, 2].to_s.unpack1('v')
if id && ID_MAP.member?(id) if id && ID_MAP.member?(id)
extra_field_type_exist(binstr, id, len, i) extra_field_type_exist(binstr, id, len, i)
elsif id elsif id

View File

@ -19,7 +19,7 @@ module Zip
return false return false
end end
[binstr[2, 2].unpack('v')[0], binstr[4..-1]] [binstr[2, 2].unpack1('v'), binstr[4..-1]]
end end
def ==(other) def ==(other)

View File

@ -46,7 +46,7 @@ module Zip
end end
def extract(size, format) def extract(size, format)
@content.slice!(0, size).unpack(format)[0] @content.slice!(0, size).unpack1(format)
end end
private :extract private :extract