Yet more Rubocopping

This commit is contained in:
Maruno17
2021-12-23 00:27:17 +00:00
parent 514fe13ca2
commit 132a16950d
171 changed files with 1455 additions and 1647 deletions

View File

@@ -7,7 +7,7 @@ module PBDebug
rescue
PBDebug.log("")
PBDebug.log("**Exception: #{$!.message}")
PBDebug.log("#{$!.backtrace.inspect}")
PBDebug.log($!.backtrace.inspect.to_s)
PBDebug.log("")
pbPrintException($!) # if $INTERNAL
PBDebug.flush

View File

@@ -37,7 +37,7 @@ def pbPrintException(e)
message += "Exception: #{e.class}\r\n"
message += "Message: "
end
message += "#{emessage}"
message += emessage
# show last 10/25 lines of backtrace
if !e.is_a?(EventScriptError)
message += "\r\n\r\nBacktrace:\r\n"

View File

@@ -378,7 +378,7 @@ class StringInput
f = super
yield f
ensure
f.close if f
f&.close
end
else
super

View File

@@ -137,7 +137,7 @@ class StringInput
end
def each_byte
while !eof?
until eof?
yield getc
end
end

View File

@@ -69,7 +69,7 @@ def pbSetTextMessages
neednewline = false
end
if list.code == 101
lastitem += "#{list.parameters[0]}"
lastitem += list.parameters[0].to_s
neednewline = true
elsif list.code == 102
list.parameters[0].length.times do |k|
@@ -78,7 +78,7 @@ def pbSetTextMessages
neednewline = false
elsif list.code == 401
lastitem += " " if lastitem != ""
lastitem += "#{list.parameters[0]}"
lastitem += list.parameters[0].to_s
neednewline = true
elsif list.code == 355 || list.code == 655
pbAddScriptTexts(items, list.parameters[0])
@@ -93,11 +93,9 @@ def pbSetTextMessages
end
end
end
if neednewline
if lastitem != ""
items.push(lastitem)
lastitem = ""
end
if neednewline && lastitem != ""
items.push(lastitem)
lastitem = ""
end
end
end
@@ -140,7 +138,7 @@ def pbSetTextMessages
neednewline = false
end
if list.code == 101
lastitem += "#{list.parameters[0]}"
lastitem += list.parameters[0].to_s
neednewline = true
elsif list.code == 102
list.parameters[0].length.times do |k|
@@ -149,7 +147,7 @@ def pbSetTextMessages
neednewline = false
elsif list.code == 401
lastitem += " " if lastitem != ""
lastitem += "#{list.parameters[0]}"
lastitem += list.parameters[0].to_s
neednewline = true
elsif list.code == 355 || list.code == 655
pbAddScriptTexts(items, list.parameters[0])
@@ -164,11 +162,9 @@ def pbSetTextMessages
end
end
end
if neednewline
if lastitem != ""
items.push(lastitem)
lastitem = ""
end
if neednewline && lastitem != ""
items.push(lastitem)
lastitem = ""
end
end
end
@@ -210,7 +206,7 @@ def pbEachIntlSection(file)
sectionname = $~[1]
havesection = true
else
if sectionname == nil
if sectionname.nil?
raise _INTL("Expected a section at the beginning of the file (line {1})", lineno)
end
lastsection.push(line.gsub(/\s+$/, ""))
@@ -739,7 +735,7 @@ def _INTL(*arg)
end
string = string.clone
(1...arg.length).each do |i|
string.gsub!(/\{#{i}\}/, "#{arg[i]}")
string.gsub!(/\{#{i}\}/, arg[i].to_s)
end
return string
end
@@ -770,7 +766,7 @@ def _MAPINTL(mapid, *arg)
string = MessageTypes.getFromMapHash(mapid, arg[0])
string = string.clone
(1...arg.length).each do |i|
string.gsub!(/\{#{i}\}/, "#{arg[i]}")
string.gsub!(/\{#{i}\}/, arg[i].to_s)
end
return string
end

View File

@@ -319,10 +319,10 @@ module PluginManager
value = [value] if value.is_a?(String)
if value.is_a?(Array)
value.each do |entry|
if !entry.is_a?(String)
self.error("Plugin '#{name}'s credits array contains a non-string value.")
else
if entry.is_a?(String)
credits << entry
else
self.error("Plugin '#{name}'s credits array contains a non-string value.")
end
end
else
@@ -333,7 +333,7 @@ module PluginManager
end
end
@@Plugins.values.each do |plugin|
if plugin[:incompatibilities] && plugin[:incompatibilities].include?(name)
if plugin[:incompatibilities]&.include?(name)
self.error("Plugin '#{plugin[:name]}' is incompatible with '#{name}'. " +
"They cannot both be used at the same time.")
end
@@ -475,7 +475,7 @@ module PluginManager
print("#{message}\r\nThis exception was logged in #{errorlogline}.\r\nHold Ctrl when closing this message to copy it to the clipboard.")
# Give a ~500ms coyote time to start holding Control
t = System.delta
until (System.delta - t) >= 500000
until (System.delta - t) >= 500_000
Input.update
if Input.press?(Input::CTRL)
Input.clipboard = message

View File

@@ -6,13 +6,11 @@ class SpriteAnimation
@sprite = sprite
end
%w[
x y ox oy viewport flash src_rect opacity tone
].each_with_index do |s, _i|
["x", "y", "ox", "oy", "viewport", "flash", "src_rect", "opacity", "tone"].each do |def_name|
eval <<-__END__
def #{s}(*arg)
@sprite.#{s}(*arg)
def #{def_name}(*arg)
@sprite.#{def_name}(*arg)
end
__END__
@@ -30,7 +28,7 @@ class SpriteAnimation
def animation(animation, hit, height = 3)
dispose_animation
@_animation = animation
return if @_animation == nil
return if @_animation.nil?
@_animation_hit = hit
@_animation_height = height
@_animation_duration = @_animation.frame_max
@@ -66,7 +64,7 @@ class SpriteAnimation
return if animation == @_loop_animation
dispose_loop_animation
@_loop_animation = animation
return if @_loop_animation == nil
return if @_loop_animation.nil?
@_loop_animation_index = 0
fr = 20
if @_animation.name[/\[\s*(\d+?)\s*\]\s*$/]
@@ -92,7 +90,7 @@ class SpriteAnimation
end
def dispose_animation
return if @_animation_sprites == nil
return if @_animation_sprites.nil?
sprite = @_animation_sprites[0]
if sprite != nil
@@_reference_count[sprite.bitmap] -= 1
@@ -108,7 +106,7 @@ class SpriteAnimation
end
def dispose_loop_animation
return if @_loop_animation_sprites == nil
return if @_loop_animation_sprites.nil?
sprite = @_loop_animation_sprites[0]
if sprite != nil
@@_reference_count[sprite.bitmap] -= 1
@@ -195,7 +193,7 @@ class SpriteAnimation
16.times do |i|
sprite = sprites[i]
pattern = cell_data[i, 0]
if sprite == nil || pattern == nil || pattern == -1
if sprite.nil? || pattern.nil? || pattern == -1
sprite.visible = false if sprite != nil
next
end
@@ -377,7 +375,7 @@ module RPG
def pushAnimation(array, anim)
array.length.times do |i|
next if array[i] && array[i].active?
next if array[i]&.active?
array[i] = anim
return
end
@@ -397,7 +395,7 @@ module RPG
end
def dispose_damage
return if @_damage_sprite == nil
return if @_damage_sprite.nil?
@_damage_sprite.bitmap.dispose
@_damage_sprite.dispose
@_damage_sprite = nil
@@ -406,14 +404,14 @@ module RPG
def dispose_animation
@animations.each do |a|
a.dispose_animation if a
a&.dispose_animation
end
@animations.clear
end
def dispose_loop_animation
@loopAnimations.each do |a|
a.dispose_loop_animation if a
a&.dispose_loop_animation
end
@loopAnimations.clear
end
@@ -501,13 +499,13 @@ module RPG
def update_animation
@animations.each do |a|
a.update_animation if a && a.active?
a.update_animation if a&.active?
end
end
def update_loop_animation
@loopAnimations.each do |a|
a.update_loop_animation if a && a.active?
a.update_loop_animation if a&.active?
end
end