简体   繁体   中英

How to ignore Sonar 'Uncovered Conditions' for lombok @EqualsAndHashCode

For below class Sonar is complaining about Uncovered Conditions for @EqualsAndHashCode (lombok annotations). I have tried adding '// NOSONAR' to ignore but it did not help. Please see code below for reference.

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@EqualsAndHashCode(callSuper = false) // NOSONAR
public class UserPersonalInfo extends PersonalInfo {

  private String userId;

  private String empployeeId;
}

It shows 22 uncovered conditions for EqualsAndHashCode in Sonar report. Please help me to resolve this issue.

Add lombok.config file at the root of your project and add:

config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true

config.stopBubbling = true is telling Lombok that this is the root directory and that it shouldn't search parent directories for more configuration files (you can have more than one Lombok config files in different directories/packages).

lombok.addLombokGeneratedAnnotation = true is telling Lombok to add @lombok.Generated annotation to all generated methods.

Jacoco (at least 0.8.0) filters out all methods annotated with @lombok.Generated.

Source: https://medium.com/@mladen.bolic/lombok-data-improve-your-code-coverage-a74fb624a72b

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM