We have a paid subscription with SonarCloud and since we adopted typescript 3.7.2, we get false positives with error being: Non-empty statements should change control flow or have at least one side-effect
The code that’s reported as buggy is this
x?.somefunction("abc") where somefunction property has the following type (aaa: string) => void
So if the function is defined, it should be called, which is exactly what the ?. does.
I guess that you will find something like this in the logs:
WARN: You are using version of TypeScript 3.7.2 which is not officially supported; supported versions >=3.2.1 <3.6.0
The false positive you are facing is a typical consequence of using more recent version, the analysis will probably goes though, but rules may not behave correctly in the presence of new ts features (in this case: optional chaining introduced in ts 3.7).
For the specific case you are reporting, I agree that it looks like a false positive, and in fact it looks like this issue who is already fixed. (typescript-eslint is a dependency used by our plugin).
All in all, this false positive should disappear once we upgrade our dependencies and officially support TS 3.7, it will probably be the case for the next release.
Hello, are there updates in Typescript 3.7 support by SonarCloud? When is the next release planned?
We still get false positives which we need to manually resolve every week…
Hi Quentin, I see that there is no movement on the github issues. Is there any way in sonarcloud configuration to turn off this check, for this use case? We basically get failing builds every week for no good reason.
Is there any way in sonarcloud configuration to turn off this check
You can remove it from your quality profile. Note that it will remove all issues raised by this rule, including ones unrelated to optional chaining. I don’t see other alternative though.
Here is an example on how to do it:
In addition, I advise you to come back to the original profile once the issue is resolved, to benefit from the latest changes and additions (or regularly check for updates).