Skip to content

Commit f39bf62

Browse files
committed
test: Add edge cases for stream pipe error handling
Add tests for chained stream methods and non-stream pipe objects
1 parent c27157f commit f39bf62

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

javascript/ql/test/query-tests/Quality/UnhandledStreamPipe/test.expected

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@
88
| test.js:109:26:109:37 | s.pipe(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
99
| test.js:116:5:116:21 | stream.pipe(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
1010
| test.js:125:5:125:26 | getStre ... e(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
11+
| test.js:139:5:139:87 | stream. ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
12+
| test.js:143:5:143:62 | stream. ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
13+
| test.js:147:5:147:28 | notStre ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
14+
| test.js:151:20:151:43 | notStre ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
15+
| test.js:157:47:157:74 | someVar ... ething) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
16+
| test.js:163:5:163:20 | notStream.pipe() | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
17+
| test.js:167:5:167:36 | notStre ... , arg3) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |

javascript/ql/test/query-tests/Quality/UnhandledStreamPipe/test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,36 @@ function test() {
134134
stream.pipe(dest);
135135
stream.once('error', handleError);
136136
}
137+
{ // Long chained pipe with error handler
138+
const stream = getStream();
139+
stream.pause().on('error', handleError).setEncoding('utf8').resume().pipe(writable); // $SPURIOUS:Alert
140+
}
141+
{ // Long chained pipe without error handler
142+
const stream = getStream();
143+
stream.pause().setEncoding('utf8').resume().pipe(writable); // $Alert
144+
}
145+
{ // Non-stream with pipe method that returns subscribable object (Streams do not have subscribe method)
146+
const notStream = getNotAStream();
147+
notStream.pipe(writable).subscribe(); // $SPURIOUS:Alert
148+
}
149+
{ // Non-stream with pipe method that returns subscribable object (Streams do not have subscribe method)
150+
const notStream = getNotAStream();
151+
const result = notStream.pipe(writable); // $SPURIOUS:Alert
152+
const dealWithResult = (result) => { result.subscribe(); };
153+
dealWithResult(result);
154+
}
155+
{ // Non-stream with pipe method that returns subscribable object (Streams do not have subscribe method)
156+
const notStream = getNotAStream();
157+
const pipeIt = (someVariable) => { return someVariable.pipe(something); }; // $SPURIOUS:Alert
158+
let x = pipeIt(notStream);
159+
x.subscribe();
160+
}
161+
{ // Calling custom pipe method with no arguments
162+
const notStream = getNotAStream();
163+
notStream.pipe(); // $SPURIOUS:Alert
164+
}
165+
{ // Calling custom pipe method with more then 2 arguments
166+
const notStream = getNotAStream();
167+
notStream.pipe(arg1, arg2, arg3); // $SPURIOUS:Alert
168+
}
137169
}

0 commit comments

Comments
 (0)