Lombok生成的代码在覆盖范围上不容忽视 [英] Lombok generated code can not be ignored on coverage

查看:1312
本文介绍了Lombok生成的代码在覆盖范围上不容忽视的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里我问了一个问题:

Here I asked the question:

Lombok,请仅使用getter设置器等于或串起

我不想在那儿发表评论,因为它已经很老了.

I did not want to comment there, because it was very old.

我想要的是,我希望在覆盖inteljideasonar.

What I want is, I want the code which is generated by lombok to be ignored during coverage of inteljidea and also sonar.

作为我之前链接的问题的建议,我添加了此内容

As suggestion in my previous question that I linked , I added this

config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true

我将此添加到根目录,然后重建恢复.

I added this to root ,then rebuilded recoveraged.

但是对于那个班级

@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(parent = BaseApiResponse.class)
public class SaveObligation extends Base{

    @ApiModelProperty(required = true)
    List<LegalObligationDTO> legalObligations;


    public SaveLegalObligatione(String id, List<LegalObligationDTO> legalObligations) {
        super(id, true);
        this.legalObligations = legalObligations;
    }
}



inteljidea shows all green (which means covered) except those lines:

@Data
@EqualsAndHashCode(callSuper = true)

我猜是因为龙目岛.

我该怎么办?

还,我尝试过

config.stopBubbling = true
lombok.addJavaxGeneratedAnnotation = true
lombok.addLombokGeneratedAnnotation = true

对于intelj,我不会使用其他工具.它自己的报道.

For intelj, i dont use different tool coverage. Its own coverage.

顺便说一句,intelj像这样显示.但是代码也将用于声纳法,所以coverage也会有analysed.

By the way, intelj shows like that. But also the code is going to sonarqube so also there will be analysed for coverage.

这是buildgradle

This is buildgradle

    compileOnly 'org.projectlombok:lombok:+'

推荐答案

Lombok在编译时起作用. 有关详细信息,请参见此处

Lombok works in compile time. For more information see Here for example

因此字节码已经包含Lombok生成的转换.

So that the bytecode already contains Lombok generated transformations.

另一方面,覆盖工具通常在运行时执行字节码操作.

Coverage tools, on the other hand, usually work in runtime performing bytecode manipulation).

因此,将Lombok配置为在覆盖范围内排除某些代码没有任何意义,而是取决于您选择的覆盖范围工具.

So, it doesn't make sense to configure Lombok to exclude certain code in coverage, but rather depends on the coverage tool of your choice.

Sonar通过收集覆盖工具生成的报告并将其发送到Sonar服务器,在以后阶段工作.

Sonar works at the later phase by gathering reports generated by the coverage tools and sending them to Sonar server.

因此,我认为您应该检查是否可以配置您的代码覆盖率工具.

So I think you should check whether its possible to configure your code coverage tool.

话虽如此,可能应该在单元测试中调用此代码-隐式而非直接地,我不建议对lombok生成的代码进行单元测试.

Having said that, probably this code should be called in unit tests - implicitly, not directly, I'm not suggesting unit-testing of lombok generated code.

这篇关于Lombok生成的代码在覆盖范围上不容忽视的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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