Skip to content

Commit 5710f0c

Browse files
committed
Add test cases for non-stream field accesses and methods before and after pipe operations
1 parent 03d1f9a commit 5710f0c

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as rx from 'rxjs';
2+
import * as ops from 'rxjs/operators';
3+
4+
const { of, from } = rx;
5+
const { map, filter } = ops;
6+
7+
function f(){
8+
of(1, 2, 3).pipe(map(x => x * 2)); // $SPURIOUS:Alert
9+
someNonStream().pipe(map(x => x * 2)); // $SPURIOUS:Alert
10+
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
| rxjsStreams.js:8:3:8:35 | of(1, 2 ... x * 2)) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
2+
| rxjsStreams.js:9:3:9:39 | someNon ... x * 2)) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
13
| test.js:4:5:4:28 | stream. ... nation) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
24
| test.js:19:5:19:17 | s2.pipe(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
35
| test.js:45:5:45:30 | stream2 ... ation2) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
@@ -9,3 +11,18 @@
911
| 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. |
1012
| 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. |
1113
| 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. |
14+
| test.js:171:17:171:40 | notStre ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
15+
| test.js:175:17:175:40 | notStre ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
16+
| test.js:185:5:185:32 | copyStr ... nation) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
17+
| test.js:190:17:190:40 | notStre ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
18+
| test.js:195:17:195:40 | notStre ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
19+
| test.js:199:5:199:22 | notStream.pipe({}) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
20+
| test.js:203:5:203:26 | notStre ... ()=>{}) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
21+
| test.js:207:5:207:31 | getStre ... mber()) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
22+
| test.js:207:5:207:42 | getStre ... e(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
23+
| test.js:207:5:207:53 | getStre ... e(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
24+
| test.js:207:5:207:64 | getStre ... e(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
25+
| test.js:212:5:212:23 | getStream().pipe(p) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
26+
| test.js:212:5:212:34 | getStre ... e(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
27+
| test.js:212:5:212:45 | getStre ... e(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
28+
| test.js:212:5:212:56 | getStre ... e(dest) | 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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,49 @@ function test() {
166166
const notStream = getNotAStream();
167167
notStream.pipe(arg1, arg2, arg3);
168168
}
169+
{ // Member access on a non-stream after pipe
170+
const notStream = getNotAStream();
171+
const val = notStream.pipe(writable).someMember; // $SPURIOUS:Alert
172+
}
173+
{ // Member access on a stream after pipe
174+
const notStream = getNotAStream();
175+
const val = notStream.pipe(writable).readable; // $Alert
176+
}
177+
{ // Method access on a non-stream after pipe
178+
const notStream = getNotAStream();
179+
const val = notStream.pipe(writable).someMethod();
180+
}
181+
{ // Pipe on fs readStream
182+
const fs = require('fs');
183+
const stream = fs.createReadStream('file.txt');
184+
const copyStream = stream;
185+
copyStream.pipe(destination); // $Alert
186+
}
187+
{
188+
const notStream = getNotAStream();
189+
const something = notStream.someNotStreamPropertyAccess;
190+
const val = notStream.pipe(writable); // $SPURIOUS:Alert
191+
}
192+
{
193+
const notStream = getNotAStream();
194+
const something = notStream.someNotStreamPropertyAccess();
195+
const val = notStream.pipe(writable); // $SPURIOUS:Alert
196+
}
197+
{
198+
const notStream = getNotAStream();
199+
notStream.pipe({}); // $SPURIOUS:Alert
200+
}
201+
{
202+
const notStream = getNotAStream();
203+
notStream.pipe(()=>{}); // $SPURIOUS:Alert
204+
}
205+
{
206+
const plumber = require('gulp-plumber');
207+
getStream().pipe(plumber()).pipe(dest).pipe(dest).pipe(dest); // $SPURIOUS:Alert
208+
}
209+
{
210+
const plumber = require('gulp-plumber');
211+
const p = plumber();
212+
getStream().pipe(p).pipe(dest).pipe(dest).pipe(dest); // $SPURIOUS:Alert
213+
}
169214
}

0 commit comments

Comments
 (0)