Rule S00107 "Methods should not have too many parameters" should consider Lombok annotations

java

(Thomas Turrell Croft) #1

The following code smell would be detected by S00107:

public class Application {

private final String param1;
private final String param2;
private final String param3;
private final String param4;
private final String param5;
private final String param6;
private final String param7;
private final String param8;
private final String param9;

public Application(String param1, String param2, String param3, String param4, String param5, String param6, String param7, String param8, String param9) {
this.param1 = param1;
this.param2 = param2;
this.param3 = param3;
this.param4 = param4;
this.param5 = param5;
this.param6 = param6;
this.param7 = param7;
this.param8 = param8;
this.param9 = param9;
}

However this code would pass rule S00107:

@RequiredArgsConstructor
public class Application {

private final String param1;
private final String param2;
private final String param3;
private final String param4;
private final String param5;
private final String param6;
private final String param7;
private final String param8;
private final String param9;

The code is identical, both examples have too many parameters however since the second example uses the Lombok RequiredArgs constructor it is not detected. The same is true for the Lombok AllArgsConstructor annotation.