<small id='HFw0I'></small><noframes id='HFw0I'>

        <bdo id='HFw0I'></bdo><ul id='HFw0I'></ul>
    1. <tfoot id='HFw0I'></tfoot>

      <legend id='HFw0I'><style id='HFw0I'><dir id='HFw0I'><q id='HFw0I'></q></dir></style></legend>

      <i id='HFw0I'><tr id='HFw0I'><dt id='HFw0I'><q id='HFw0I'><span id='HFw0I'><b id='HFw0I'><form id='HFw0I'><ins id='HFw0I'></ins><ul id='HFw0I'></ul><sub id='HFw0I'></sub></form><legend id='HFw0I'></legend><bdo id='HFw0I'><pre id='HFw0I'><center id='HFw0I'></center></pre></bdo></b><th id='HFw0I'></th></span></q></dt></tr></i><div id='HFw0I'><tfoot id='HFw0I'></tfoot><dl id='HFw0I'><fieldset id='HFw0I'></fieldset></dl></div>
      1. 如何忽略 Sonar 中的重复代码报告?

        How do I ignore duplicated code report in Sonar?(如何忽略 Sonar 中的重复代码报告?)
          <i id='fDZdM'><tr id='fDZdM'><dt id='fDZdM'><q id='fDZdM'><span id='fDZdM'><b id='fDZdM'><form id='fDZdM'><ins id='fDZdM'></ins><ul id='fDZdM'></ul><sub id='fDZdM'></sub></form><legend id='fDZdM'></legend><bdo id='fDZdM'><pre id='fDZdM'><center id='fDZdM'></center></pre></bdo></b><th id='fDZdM'></th></span></q></dt></tr></i><div id='fDZdM'><tfoot id='fDZdM'></tfoot><dl id='fDZdM'><fieldset id='fDZdM'></fieldset></dl></div>
            <tbody id='fDZdM'></tbody>
          1. <small id='fDZdM'></small><noframes id='fDZdM'>

            <legend id='fDZdM'><style id='fDZdM'><dir id='fDZdM'><q id='fDZdM'></q></dir></style></legend>

              <tfoot id='fDZdM'></tfoot>
                • <bdo id='fDZdM'></bdo><ul id='fDZdM'></ul>

                  本文介绍了如何忽略 Sonar 中的重复代码报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  SonarQube 向不同的简单 POJO 类报告为重复代码块",如下所示.在这种情况下,A 和 B 是不同的角色.所以,我认为我不应该创建抽象类.

                  公共类 A{私人字符串 xxx;//省略其他字段.公共 A() {}公共字符串 getXxx() {返回xxx;}公共无效 setXxx(字符串 xxx){this.xxx=xxx;}//省略其他字段的 setter 和 getter}公共类 B{私人字符串 xxx;//省略其他字段.公共 B() {}公共字符串 getXxx() {返回xxx;}公共无效 setXxx(字符串 xxx){this.xxx=xxx;}//省略其他字段的 setter 和 getter}

                  严重性为主要.所以,我想忽略它.然后,我将@SuppressWarning("common-java:DuplicatedBlocks") 和@SuppressWarning("all") 添加到这两个类中.但也不容忽视.

                  虽然在

                  有时 Sonar 报告的情况并不严重,但又取决于项目性质 :)

                  但是,就像上面评论中提到的@Stephen,如果 xxx 是相同的字段和继承是有意义的,那么你可以有父抽象类来避免报告.

                  SonarQube reports as "block of duplicated code" to different simple POJO class like below. In this case, A and B are different role. So, I think that I should not create abstract class.

                  public class A{
                    private String xxx;
                  
                    // omitted other fields.
                  
                    public A() {}
                  
                    public String getXxx() {
                       return xxx;
                    }
                    public void setXxx(String xxx) {
                       this.xxx= xxx;
                    }
                  
                    // omitted other fields' setter and getter
                  
                  }
                  
                  public class B{
                    private String xxx;
                  
                    // omitted other fields.
                  
                    public B() {}
                  
                    public String getXxx() {
                       return xxx;
                    }
                    public void setXxx(String xxx) {
                       this.xxx= xxx;
                    }
                  
                    // omitted other fields' setter and getter
                  
                  }
                  

                  The severity is Major. So, I would like to ignore it. Then, I added @SuppressWarning("common-java:DuplicatedBlocks") and @SuppressWarning("all") to both classes. But it could not be ignored.

                  Though similar question was raised in JIRA, but it have been not solved. My SonarQube's version is 6.5. Thanks!

                  解决方案

                  Putting this into the answer section to attach a screenshot:

                  If you are confident enough that those two blocks of code have different roles, then you can change the reported severity level to Minor or Info from web-console. For example, see the screenshot below:

                  Sometimes Sonar reports as severe on things which are not really severe, but again depends on the project nature :)

                  However, like @Stephen mentioned on a comment above, if xxx are same field and inheritance makes sense, then you can have parent abstract class to avoid the report.

                  这篇关于如何忽略 Sonar 中的重复代码报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Slf4j LoggerFactory.getLogger and sonarqube(Slf4j LoggerFactory.getLogger 和 sonarqube)
                  Security - Array is stored directly(安全性 - 数组直接存储)
                  SonarQube quot;Class Not Foundquot; during Main AST Scan(SonarQube“找不到类在主 AST 扫描期间)
                  Integrate Spock#39;s test with Sonar(将 Spock 的测试与声纳集成)
                  How do I make Hudson/Jenkins fail if Sonar thresholds are breached?(如果违反声纳阈值,我如何让 Hudson/Jenkins 失败?)
                  automatically add curly brackets to all if/else/for/while etc. in a java code-base(自动将大括号添加到 java 代码库中的所有 if/else/for/while 等)

                  <tfoot id='9VvdV'></tfoot>
                    <tbody id='9VvdV'></tbody>
                      • <small id='9VvdV'></small><noframes id='9VvdV'>

                          <bdo id='9VvdV'></bdo><ul id='9VvdV'></ul>

                            <legend id='9VvdV'><style id='9VvdV'><dir id='9VvdV'><q id='9VvdV'></q></dir></style></legend>

                          1. <i id='9VvdV'><tr id='9VvdV'><dt id='9VvdV'><q id='9VvdV'><span id='9VvdV'><b id='9VvdV'><form id='9VvdV'><ins id='9VvdV'></ins><ul id='9VvdV'></ul><sub id='9VvdV'></sub></form><legend id='9VvdV'></legend><bdo id='9VvdV'><pre id='9VvdV'><center id='9VvdV'></center></pre></bdo></b><th id='9VvdV'></th></span></q></dt></tr></i><div id='9VvdV'><tfoot id='9VvdV'></tfoot><dl id='9VvdV'><fieldset id='9VvdV'></fieldset></dl></div>