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?

0

Hello, please follow the issue that covers your case:

https://youtrack.jetbrains.com/issue/IDEA-91006

 

Thank you 

1

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 

0

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:

  1. Place the caret on the highlighted line.
  2. Click the Intention action icon 💡 that appears.
  3. Click the button next to the inspection you'd like to suppress.
  4. Select the appropriate suppression action based on your desired scope.

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.

0

请先登录再写评论。