JaCoCo 忽略 Lombok 代码,这是预期的吗?
JaCoCo ignoring Lombok code, is this expected?
我正在使用 Lombok 1.18.2 和 JaCoCo 0.8.3,理论上 recognize/ignore lombok 注释。我做了一个测试,在我的 lombok.config
中添加了 lombok.addLombokGeneratedAnnotation = true
参数,然后我在我的目标 类 反编译代码中看到了生成的注释。
但我很惊讶打开 jacoco.exec 文件并看到像 @Getter 这样的东西增加了 "Total Probes" 值,但保持 "Executed Probes" 不变。
这是预期的吗?
如果是这样,SonarQube 如何巧妙地利用它,如果通过将其指向 jacoco.exec 个文件,只有 total/hit 个探测器的信息? Sonar 如何判断其中一个探测器与 lombok 有关?
I am using Lombok 1.18.2 and JaCoCo 0.8.3, which theoretically recognize/ignore lombok annotations.
理论上没有,但是practically。
不是"ignore lombok annotations",而是用@lombok.Generated
, or even more precise quoting entry from 0.8.3 changelog注释的方法:
Classes and methods annotated by annotation whose retention policy is runtime or class and whose simple name contains "Generated" (previously equality was required) are filtered out during generation of report
But I am surprised to open jacoco.exec file and see that things like @Getter increase the "Total Probes" values, but keep untouched the "Executed Probes" one. Is this expected?
是的,这是意料之中的。在检测 classes(插入探针)期间不会发生方法过滤。 exec
文件不是最终报告,它包含有关 class 中插入的所有探测器的原始信息。方法过滤发生在报告生成期间(分析 exec
和 class
文件),例如在执行 report
JaCoCo Ant Task 期间。
If so, how can SonarQube make smart use of it, if by pointing it to the jacoco.exec files, there is only information on total/hit probes? How can Sonar tell one of this probes has something to do with lombok?
SonarQube embeds JaCoCo as a library and use it to analyze exec
and class files for generation of their report.
这就是为什么 JaCoCo 发布公告通常包含以下声明,例如0.8.2:
As before - please note
0.8.2 version of integrations developed as part of JaCoCo project by us (Ant Tasks, Maven Plugin and Command Line Interface) provide Java 11 support and new filters,
tools that directly read exec files (which is not a final report) and embed JaCoCo as a library for generation of report will provide ability to analyze Java 11 class files and to use new filters only after they updated to this version of JaCoCo.
So please follow/wait/etc respective vendors such as
SonarQube - https://jira.sonarsource.com/browse/SONARJAVA-2876 , or try to use new plugin that reads XML report - https://github.com/SonarSource/sonar-jacoco
我正在使用 Lombok 1.18.2 和 JaCoCo 0.8.3,理论上 recognize/ignore lombok 注释。我做了一个测试,在我的 lombok.config
中添加了 lombok.addLombokGeneratedAnnotation = true
参数,然后我在我的目标 类 反编译代码中看到了生成的注释。
但我很惊讶打开 jacoco.exec 文件并看到像 @Getter 这样的东西增加了 "Total Probes" 值,但保持 "Executed Probes" 不变。 这是预期的吗?
如果是这样,SonarQube 如何巧妙地利用它,如果通过将其指向 jacoco.exec 个文件,只有 total/hit 个探测器的信息? Sonar 如何判断其中一个探测器与 lombok 有关?
I am using Lombok 1.18.2 and JaCoCo 0.8.3, which theoretically recognize/ignore lombok annotations.
理论上没有,但是practically。
不是"ignore lombok annotations",而是用@lombok.Generated
, or even more precise quoting entry from 0.8.3 changelog注释的方法:
Classes and methods annotated by annotation whose retention policy is runtime or class and whose simple name contains "Generated" (previously equality was required) are filtered out during generation of report
But I am surprised to open jacoco.exec file and see that things like @Getter increase the "Total Probes" values, but keep untouched the "Executed Probes" one. Is this expected?
是的,这是意料之中的。在检测 classes(插入探针)期间不会发生方法过滤。 exec
文件不是最终报告,它包含有关 class 中插入的所有探测器的原始信息。方法过滤发生在报告生成期间(分析 exec
和 class
文件),例如在执行 report
JaCoCo Ant Task 期间。
If so, how can SonarQube make smart use of it, if by pointing it to the jacoco.exec files, there is only information on total/hit probes? How can Sonar tell one of this probes has something to do with lombok?
SonarQube embeds JaCoCo as a library and use it to analyze exec
and class files for generation of their report.
这就是为什么 JaCoCo 发布公告通常包含以下声明,例如0.8.2:
As before - please note
0.8.2 version of integrations developed as part of JaCoCo project by us (Ant Tasks, Maven Plugin and Command Line Interface) provide Java 11 support and new filters,
tools that directly read exec files (which is not a final report) and embed JaCoCo as a library for generation of report will provide ability to analyze Java 11 class files and to use new filters only after they updated to this version of JaCoCo. So please follow/wait/etc respective vendors such as
SonarQube - https://jira.sonarsource.com/browse/SONARJAVA-2876 , or try to use new plugin that reads XML report - https://github.com/SonarSource/sonar-jacoco