Disable inspections for specific methods
I generally like to have as many inspections enabled as possible, except for the ones I really know I will never care about. I would like to be able to disable inspections not on the basis of package or classes (as in the Scopes settings), but for specific methods. The method I'm thinking about is toString() and the inspection is Java -> Logging -> 'public' method without logging. I know I will never log a call to toString, but I want to keep that inspection enabled for everything else. Annotating every such method with a suppression is an option, but I feel it's polluting my code, since I have a toString in almost all of my classes.
Is there a way of suppressing/disabling inspections for specific methods, an in particular toString?
请先登录再写评论。
Hello, please follow the issue that covers your case:
https://youtrack.jetbrains.com/issue/IDEA-91006
Thank you
Hello, so is there a way to ignore an inspection on a specific method or not? There are several irrelevant inspections with different packages (especially with python packages) that I would like to ignore. A usual example is an “Unexpected type” warning
Gregoirebaumann94, thank you for your question.
You can suppress an inspection within a specific line, and the code analysis engine will then ignore the issue flagged by that inspection.
To suppress an inspection directly from the editor:
For more detailed guidance, you can refer to our Help article here:
https://www.jetbrains.com/help/pycharm/disabling-and-enabling-inspections.html
Please let us know if that helps.