代码之家  ›  专栏  ›  技术社区  ›  aristotll

如何使用Intellij Sonarint插件抑制特定方法的警告

  •  57
  • aristotll  · 技术社区  · 8 年前

    我想抑制一些方法的声纳lint插件警告, 这个问题不是我想要的 Intellij SonarLint 2.3 - ignore rule .

    目前,我必须用 @SuppressWarnings("all") ,将取消所有警告。

    2 回复  |  直到 8 年前
        1
  •  100
  •   syncdk    4 年前

    您可以使用 //NOSONAR @SuppressWarnings() 但您需要指定规则。

    documentation :

    这个 //NOSONAR公司 标记用于停用给定行的所有规则 但不适合停用所有规则(或仅限给定规则) 方法或类的所有行。这就是为什么支持 @SuppressWarnings("all") 已添加到SonarQube。

    @SuppressWarnings 带有规则键列表的注释:

    @SuppressWarnings("squid:S2078")

    @SuppressWarnings({"squid:S2078", "squid:S2076"}) .

        2
  •  1
  •   prime    5 年前

    您可以在编辑器中抑制检查,

    enter image description here

    提到 https://www.jetbrains.com/help/idea/disabling-and-enabling-inspections.html ,它有各种方法来实现这一点,有许多方法可以自定义所需的行为。