In general you cannot go ahead and exclude just one or two lines but, you can do something else which can get you 100% coverage.
The reason why you see an extreme drop in coverage after using @Data
is that it contains a lot of annotations in it like @ToString
, @EqualsAndHashCode
, @Getter
, @Setter
, @RequiredArgsConstructor
, etc. And sonar starts to look for all these methods which may or may not used by your bean/pojo.
For details on @Data
annotation - https://projectlombok.org/features/Data
I am just assuming but, if you are using @Data
annotation only for getters and setters then, use @Getter
and @Setter
annotations rather than @Data
and I am sure that you will see a boost in your coverage.