Skip to content

Commit 1ec935d

Browse files
committed
Ruby: make documentation of IOReader and FileReader less ambiguous
1 parent bd94071 commit 1ec935d

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

ruby/ql/lib/codeql/ruby/frameworks/Files.qll

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,18 @@ module IO {
9898

9999
/**
100100
* A `DataFlow::CallNode` that reads data using the `IO` class. For example,
101-
* the `IO.read call in:
101+
* the `read` and `readline` calls in:
102102
*
103103
* ```rb
104+
* # invokes the `date` shell command as a subprocess, returning its output as a string
104105
* IO.read("|date")
105-
* ```
106106
*
107-
* returns the output of the `date` shell command, invoked as a subprocess.
107+
* # reads from the file `foo.txt`, returning its first line as a string
108+
* IO.new(IO.sysopen("foo.txt")).readline
109+
* ```
108110
*
109-
* This class includes reads both from shell commands and reads from the
110-
* filesystem. For working with filesystem accesses specifically, see
111-
* `FileReader` or the `FileSystemReadAccess` concept.
111+
* This class includes only reads that use the `IO` class directly, not those
112+
* that use a subclass of `IO` such as `File`.
112113
*/
113114
class IOReader extends DataFlow::CallNode {
114115
private string receiverKind;
@@ -135,13 +136,15 @@ module IO {
135136

136137
/**
137138
* A `DataFlow::CallNode` that reads data from the filesystem using the `IO`
138-
* or `File` classes. For example, the `IO.read` call in:
139+
* or `File` classes. For example, the `IO.read` and `File#readline` calls in:
139140
*
140141
* ```rb
142+
* # reads the file `foo.txt` and returns its contents as a string.
141143
* IO.read("foo.txt")
142-
* ```
143144
*
144-
* reads the file `foo.txt` and returns its contents as a string.
145+
* # reads from the file `foo.txt`, returning its first line as a string
146+
* File.new("foo.txt").readline
147+
* ```
145148
*/
146149
class FileReader extends DataFlow::CallNode, FileSystemReadAccess::Range {
147150
private string receiverKind;

0 commit comments

Comments
 (0)