And a thorough description of the problem / question:
I have the following code:
from http import HTTPStatus
def response(message: str, status_code: HTTPStatus):
#This is a test.
pass
response("Blah", HTTPStatus.OK)
When launching VS Code, the SonarQube plugin says that my call to response with HTTPStatus.OK is a violation of RSPEC-5655. This doesn’t make sense as I am literally passing in an HTTPStatus equivalent object.
If I change status_code to be of type int, then the warning goes away. Then if I change it back the warning flashes for a second before going away in that file. It stays gone until I restart VS Code.
This seems like a bug in SonarQube’s rule parsing.
Thanks for reporting this behavior. I think it has two parts—one about a False Positive report from the rule and another about issues coming and suddenly disappearing.
For the latter, we have just released SonarQube for VSCode (formerly SonarLint) v4.13.1. Could you please update and let us know if your issue persists?
Here is an example of the warning appearing in my project.
It does NOT seem to appear in a standalone project where I attempt to replicate the issue, which is odd.
I was able to replicate it.
Ensuring that the rule Python:S5655 is enabled, I create a new file with the original code in VS Code and change the type HTTPStatus to a str in __response. This (correctly) causes an error to appear.
Then revert the type back to HTTPStatus. The error appears and persists through restarts.