How to suppress warning for a specific method with Intellij SonarLint plugin

Intellij IdeaSonarlintSonarlint Intellij

Intellij Idea Problem Overview


I want to suppress the Sonar lint plugin warning for some methods, this question is not what I want https://stackoverflow.com/questions/39449816/intellij-sonarlint-2-3-ignore-rule.

Currently I have to annotate the method with @SuppressWarnings("all"),which suppresses all warnings.

Intellij Idea Solutions


Solution 1 - Intellij Idea

You can use //NOSONAR or @SuppressWarnings() but you need to specify the rule.

From the SonarQube documentation:

> The //NOSONAR tag is useful to deactivate all rules at a given line > but is not suitable to deactivate all rules (or only a given rule) for > all the lines of a method or a class. This is why support for > @SuppressWarnings("all") has been added to SonarQube. > > SINCE 2.8 of Java Plugin, you can also use @SuppressWarnings > annotation with a list of rule keys: > >@SuppressWarnings("squid:S2078") > >or > >@SuppressWarnings({"squid:S2078", "squid:S2076"}).

Solution 2 - Intellij Idea

You can Suppress an inspection in the editor it-self,

enter image description here

Refer to https://www.jetbrains.com/help/idea/disabling-and-enabling-inspections.html, It has various methods to get this done, there are many ways to customize the required behaviors.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionaristotllView Question on Stackoverflow
Solution 1 - Intellij IdeasyncdkView Answer on Stackoverflow
Solution 2 - Intellij IdeaprimeView Answer on Stackoverflow