Skip to content

Commit 2bc9cb3

Browse files
committed
Suppress CodeQL warnings to use File methods instead of IO
1 parent e1ce1b8 commit 2bc9cb3

1 file changed

Lines changed: 21 additions & 23 deletions

File tree

lib/pathname.rb

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ module ::Kernel
146146
# === File property and manipulation methods
147147
#
148148
# These methods are a facade for File:
149+
# - #each_line(*args, &block)
150+
# - #read(*args)
151+
# - #binread(*args)
152+
# - #readlines(*args)
153+
# - #write(*args)
154+
# - #binwrite(*args)
149155
# - #atime
150156
# - #birthtime
151157
# - #ctime
@@ -186,14 +192,8 @@ module ::Kernel
186192
#
187193
# === IO
188194
#
189-
# These methods are a facade for IO:
190-
# - #each_line(*args, &block)
191-
# - #read(*args)
192-
# - #binread(*args)
193-
# - #readlines(*args)
195+
# This method is a facade for IO:
194196
# - #sysopen(*args)
195-
# - #write(*args)
196-
# - #binwrite(*args)
197197
#
198198
# === Utilities
199199
#
@@ -856,41 +856,39 @@ def relative_path_from(base_directory)
856856
end
857857

858858
class Pathname # * IO *
859+
# See <tt>IO.sysopen</tt>.
860+
def sysopen(...) IO.sysopen(@path, ...) end
861+
end
862+
863+
class Pathname # * File *
859864
#
860865
# #each_line iterates over the line in the file. It yields a String object
861866
# for each line.
862867
#
863868
# This method has existed since 1.8.1.
864869
#
865870
def each_line(...) # :yield: line
866-
IO.foreach(@path, ...)
871+
File.foreach(@path, ...)
867872
end
868873

869-
# See <tt>IO.read</tt>. Returns all data from the file, or the first +N+ bytes
874+
# See <tt>File.read</tt>. Returns all data from the file, or the first +N+ bytes
870875
# if specified.
871-
def read(...) IO.read(@path, ...) end
876+
def read(...) File.read(@path, ...) end
872877

873-
# See <tt>IO.binread</tt>. Returns all the bytes from the file, or the first +N+
878+
# See <tt>File.binread</tt>. Returns all the bytes from the file, or the first +N+
874879
# if specified.
875-
def binread(...) IO.binread(@path, ...) end
876-
877-
# See <tt>IO.readlines</tt>. Returns all the lines from the file.
878-
def readlines(...) IO.readlines(@path, ...) end
880+
def binread(...) File.binread(@path, ...) end
879881

880-
# See <tt>IO.sysopen</tt>.
881-
def sysopen(...) IO.sysopen(@path, ...) end
882+
# See <tt>File.readlines</tt>. Returns all the lines from the file.
883+
def readlines(...) File.readlines(@path, ...) end
882884

883885
# Writes +contents+ to the file. See <tt>File.write</tt>.
884-
def write(...) IO.write(@path, ...) end
886+
def write(...) File.write(@path, ...) end
885887

886888
# Writes +contents+ to the file, opening it in binary mode.
887889
#
888890
# See File.binwrite.
889-
def binwrite(...) IO.binwrite(@path, ...) end
890-
end
891-
892-
893-
class Pathname # * File *
891+
def binwrite(...) File.binwrite(@path, ...) end
894892

895893
# See <tt>File.atime</tt>. Returns last access time.
896894
def atime() File.atime(@path) end

0 commit comments

Comments
 (0)