2014-06-05 73 views
0

有一种方法可以逐行抑制警告(// NOSONAR)。SonarQube:抑制功能级别的警告?

有没有一种方法可以在功能基础上抑制(可能只是抑制一种特定类型的警告)。

+0

你可以停用质量配置文件中的规则。但是,你能确定你想要完成什么吗?因为它可能有助于更具体地回答你的问题。 – benzonico

回答

0

你可以做到这一点对PMD的警告与@SuppressWarnings

// This will suppress all the PMD warnings in this class 
@SuppressWarnings("PMD") 
public class Bar { 
    void bar() { 
    int foo; 
    } 
} 

或者,您可以抑制一个规则,像这样的注释:

// This will suppress UnusedLocalVariable warnings in this class 
@SuppressWarnings("PMD.UnusedLocalVariable") 
public class Bar { 
    void bar() { 
    int foo; 
    } 
} 

更多详情请参见:http://pmd.sourceforge.net/pmd-5.1.1/suppressing.html