Resolved many Rubocop warnings

This commit is contained in:
Maruno17
2020-09-06 17:31:12 +01:00
parent 6c4670eaa3
commit 681a8331ab
137 changed files with 921 additions and 1200 deletions

View File

@@ -133,7 +133,7 @@ def getKnownFolder(guid)
coTaskMemFree = Win32API.new("ole32.dll","CoTaskMemFree","i","") rescue nil
return "" if !(shGetKnownFolderPath && coTaskMemFree)
path = "\0"*4
ret = shGetKnownFolderPath.call(packedGuid,0,0,path)
path = shGetKnownFolderPath.call(packedGuid,0,0,path)
path = path.unpack("V")[0]
ret = getUnicodeString(path)
coTaskMemFree.call(path)
@@ -245,7 +245,7 @@ module RTP
return false if !dir || dir==""
loop do
name = dir.gsub(/[\/\\]$/,"")+"/writetest"
for i in 0...12
12.times do
name += sprintf("%02X",rand(256))
end
name += ".tmp"
@@ -471,12 +471,12 @@ module MiniRegistry
type = type.unpack("V")[0]
data = data[0,size.unpack("V")[0]]
case type
when 1; return data.chop # REG_SZ
when 2; return data.gsub(/%([^%]+)%/) { ENV[$1] || $& } # REG_EXPAND_SZ
when 3; return data # REG_BINARY
when 4; return data.unpack("V")[0] # REG_DWORD
when 5; return data.unpack("V")[0] # REG_DWORD_BIG_ENDIAN
when 11; qw = data.unpack("VV"); return (data[1]<<32|data[0]) # REG_QWORD
when 1; return data.chop # REG_SZ
when 2; return data.gsub(/%([^%]+)%/) { ENV[$1] || $& } # REG_EXPAND_SZ
when 3; return data # REG_BINARY
when 4; return data.unpack("V")[0] # REG_DWORD
when 5; return data.unpack("V")[0] # REG_DWORD_BIG_ENDIAN
when 11; data.unpack("VV"); return (data[1]<<32|data[0]) # REG_QWORD
else; raise "Type #{type} not supported."
end
end

View File

@@ -1,121 +1,113 @@
module FileInputMixin
def fgetb
x=0
ret=0
ret = 0
each_byte do |i|
ret=i || 0
ret = i || 0
break
end
return ret
end
def fgetw
x=0
ret=0
x = 0
ret = 0
each_byte do |i|
break if !i
ret|=(i<<x)
x+=8
break if x==16
ret |= (i << x)
x += 8
break if x == 16
end
return ret
end
def fgetdw
x=0
ret=0
x = 0
ret = 0
each_byte do |i|
break if !i
ret|=(i<<x)
x+=8
break if x==32
ret |= (i << x)
x += 8
break if x == 32
end
return ret
end
def fgetsb
ret=fgetb
if (ret&0x80)!=0
return ret-256
else
return ret
end
ret = fgetb
ret -= 256 if (ret & 0x80) != 0
return ret
end
def xfgetb(offset)
self.pos=offset
self.pos = offset
return fgetb
end
def xfgetw(offset)
self.pos=offset
self.pos = offset
return fgetw
end
def xfgetdw(offset)
self.pos=offset
self.pos = offset
return fgetdw
end
def getOffset(index)
self.binmode
self.pos=0
offset=fgetdw>>3
return 0 if index>=offset
self.pos=index*8
self.pos = 0
offset = fgetdw >> 3
return 0 if index >= offset
self.pos = index * 8
return fgetdw
end
def getLength(index)
self.binmode
self.pos=0
offset=fgetdw>>3
return 0 if index>=offset
self.pos=index*8+4
self.pos = 0
offset = fgetdw >> 3
return 0 if index >= offset
self.pos = index * 8 + 4
return fgetdw
end
def readName(index)
self.binmode
self.pos=0
offset=fgetdw>>3
return "" if index>=offset
self.pos=index<<3
offset=fgetdw
length=fgetdw
return "" if length==0
self.pos=offset
self.pos = 0
offset = fgetdw >> 3
return "" if index >= offset
self.pos = index << 3
offset = fgetdw
length = fgetdw
return "" if length == 0
self.pos = offset
return read(length)
end
end
module FileOutputMixin
def fputb(b)
b=b&0xFF
b &= 0xFF
write(b.chr)
end
def fputw(w)
2.times do
b=w&0xFF
b = w & 0xFF
write(b.chr)
w>>=8
w >>= 8
end
end
def fputdw(w)
4.times do
b=w&0xFF
b = w & 0xFF
write(b.chr)
w>>=8
w >>= 8
end
end
end
class File < IO
=begin
unless defined?(debugopen)
@@ -124,12 +116,12 @@ class File < IO
end
end
def open(f,m="r")
debugopen("debug.txt","ab") { |file| file.write([f,m,Time.now.to_f].inspect+"\r\n") }
def open(f, m = "r")
debugopen("debug.txt", "ab") { |file| file.write([f, m, Time.now.to_f].inspect + "\r\n") }
if block_given?
debugopen(f,m) { |file| yield file }
debugopen(f, m) { |file| yield file }
else
return debugopen(f,m)
return debugopen(f, m)
end
end
=end
@@ -137,8 +129,6 @@ class File < IO
include FileOutputMixin
end
class StringInput
include FileInputMixin
@@ -152,12 +142,9 @@ class StringInput
end
end
def binmode
end
def binmode; end
end
class StringOutput
include FileOutputMixin
end

View File

@@ -228,7 +228,6 @@ def pbGetText(infile)
begin
pbEachIntlSection(file) { |section,name|
next if section.length==0
index=name
if !name[/^([Mm][Aa][Pp])?(\d+)$/]
raise _INTL("Invalid section name {1}",name)
end
@@ -335,7 +334,7 @@ class OrderedHash < Hash
return ret
end
def _dump(depth=100)
def _dump(_depth=100)
values=[]
for key in @keys
values.push(self[key])
@@ -476,7 +475,7 @@ class Messages
@messages[type]=arr
end
def self.createHash(type,array)
def self.createHash(_type,array)
arr=OrderedHash.new
for i in 0...array.length
if array[i]
@@ -487,10 +486,8 @@ class Messages
return arr
end
def self.addToHash(type,array,hash)
if !hash
hash=OrderedHash.new
end
def self.addToHash(_type,array,hash)
hash=OrderedHash.new if !hash
for i in 0...array.length
if array[i]
key=Messages.stringToKey(array[i])