Allow comment on suppressing inspection

Usually when I suppress a code inspection, I prefer to suppress a specific inspection for a specific statement for a specific reason. I think it’s great you can suppress inspection on a specific statement, as most other linting tools I’ve used before allow. I also think it’s important that the specific inspection that’s failing can be disabled. What I saw using your code analyzer seems to do that also, but i’m slightly unsure reading the generated suppression comment.

That said, the warnings do not seem to be entirely hidden, and still are visible in the UI here and there. I would find it helpful to allow a specific statement inspection suppression line to allow an optional “justification” comment that can be displayed in a tooltip, or somewhere similar, when the inspection failure *DOES* show up in the UI.

In case my use case is helpful, i’m using https://github.com/nikic/PHP-Parser in my project, and supporting 1.x and 2.x versions of this library. In version 1 you are expected to instantiate a PhpParser\Parser manually, while version 2 has a factory that returns a parser implementing the PhpParser\Parser interface. I am using reflection to detect that PhpParser\Parser is an interface, and using a factory in that case. IntelliJ sees manual instantiation of what is now an interface, and detects this as an error. In order to not hit this false positive, the analyzer would need to understand the relationship between the reflection of the class-name, the implications of the isInterface() method return value, and that the class being reflected is the same as the one being conditionally instantiate. This sounds like a pretty tall order to expect from static analysis.

1 comment

What suppression keyword are you using (the one that still shows in UI)? 

0

Please sign in to leave a comment.