- What language is this for? Java
- Which rule? java:S107
- Why do you believe it’s a false-positive/false-negative? Works fine when not using lombok
- Are you using
- SonarCloud
- in connected mode with SonarCloud
- SonarCloud
- How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
Appears java:S107 rule ignores Lombok annotations AllArgsConstructor and RequiredArgsConstructor.
Manually doing the constructor will make java:s107 return true positive.
Lombok example with constructor with 8+ parameters (false negative):
package com.example;
@RequiredArgsConstructor
public class LombokConstructorExample {
private final Environment environment;
private final ServerProperties serverProperties;
private final DataSourceProperties dataSourceProperties;
private final JdbcProperties jdbcProperties;
private final WebProperties webProperties;
private final CacheProperties cacheProperties;
private final JacksonProperties jacksonProperties;
private final GsonProperties gsonProperties;
}
Manually made constructor with 8+ parameters (true positive):
package com.example;
public class ManualConstructorExample {
private final Environment environment;
private final ServerProperties serverProperties;
private final DataSourceProperties dataSourceProperties;
private final JdbcProperties jdbcProperties;
private final WebProperties webProperties;
private final CacheProperties cacheProperties;
private final JacksonProperties jacksonProperties;
private final GsonProperties gsonProperties;
public ManualConstructorExample(
Environment environment,
ServerProperties serverProperties,
DataSourceProperties dataSourceProperties,
JdbcProperties jdbcProperties,
WebProperties webProperties,
CacheProperties cacheProperties,
JacksonProperties jacksonProperties,
GsonProperties gsonProperties) {
this.environment = environment;
this.serverProperties = serverProperties;
this.dataSourceProperties = dataSourceProperties;
this.jdbcProperties = jdbcProperties;
this.webProperties = webProperties;
this.cacheProperties = cacheProperties;
this.jacksonProperties = jacksonProperties;
this.gsonProperties = gsonProperties;
}
}