如何从声纳中排除简单的吸气剂和吸气剂? [英] How exclude simple getter and setter from sonar?

查看:111
本文介绍了如何从声纳中排除简单的吸气剂和吸气剂?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一种方式可以将声纳和设置器从声纳报告中排除.假设我有两个"getters":

There is the way to exclude getter and setters from sonar report. Suppose I have 2 "getters":

public int getId(){
    return this.id;
}

public int getComplexId(){
    int result = 0;
    // some complex calculation there
    return result;
}

是否可以同时排除 getId()和 include getComplexId()? Sonar可以分析简单代码从复杂代码中返回this.id吗?

It is possible to exclude getId() and include getComplexId() simultaneously? Can Sonar analyze simple return this.id from complex code?

推荐答案

您可以使用NOPMD注释来避免进行声纳分析.

You can use NOPMD comment to avoid Sonar analysis.

public int getId(){ // NOPMD
    return this.id;
}

public int getComplexId(){ 
    int result = 0;
    // some complex calculation there
    return result;
}

您还可以使用//NOSONAR或//CHECKSTYLE:OFF注释.有关更多信息,请参见 http://www.sonarqube.org/sonar-1-12 -屏幕快照/

Also you can use //NOSONAR or //CHECKSTYLE:OFF comment. More info in http://www.sonarqube.org/sonar-1-12-in-screenshots/

这篇关于如何从声纳中排除简单的吸气剂和吸气剂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆