Template for a good false-positive report, formatted with Markdown:
-
versions used: SonarCloud, SonarScanner 4.4.0 (tried 4.6.0-2311 and that didn’t help)
-
minimal code sample to reproduce (with analysis parameter, and potential instructions to compile).
import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'sonar-rxjs-issue-demo',
template: '<h1>Hello World!</h1>'
})
export class SonarRxJSIssueDemoComponent {
constructor(private http: HttpClient) {
}
method1() {
this.http.get('/api/some-url')
.subscribe(() => console.log('Next1'));// shouldn't be marked as deprecated https://github.com/ReactiveX/rxjs/blob/6.6.3/src/internal/Observable.ts#L80
}
method2(): void {
this.http.get('/api/some-url')
.subscribe({ next: () => console.log('Next2') }); // shouldn't be marked as deprecated https://github.com/ReactiveX/rxjs/blob/6.6.3/src/internal/Observable.ts#L73
}
}
This afternoon (3/26/21), my pipelines started to suddenly fail due to a sudden increase in Sonar issues with my Typescript code (Angular 11.0.8 with RxJs 6.6.3). Looks like the scanner started to flag any use of the subscribe
method of the RxJS observable class as issues (Deprecated APIs should not be used
, minor code smell).
Tried to change things around and noticed this is affecting all uses of the subscribe
method overloads, even the non-deprecated ones. Found this thread that mentioned something similar (Unexpected deprecation warnings reported - #3 by JounQin), and from what I can tell the related SonarJS change was released today (related to my issue? not sure).
I was originally running TypeScript 4.0.5 and tried to upgrade to 4.2.3 and that didn’t help. Also tried to upgrade my sonar-scanner to 4.6.0, which also didn’t help.
Can you look into this and advise on how to resolve it?
Thanks.
edit: grammar and formatting