Setup:
-
JDK 25, Lombok 1.18.42 (
providedscope) -
Maven 3.9.12, Sonar scanner for Maven 5.5.0.6356
-
SonarQube Cloud
I have a composite type bound to a Spring controller method using the @ModelAttribute annotation:
@PostMapping("/{orderIdType}/{orderIdValue}/ship-info/{shipToId}/actions/update-ship-fees")
public ResponseEntity<OrderResponse> updateFees(
@ModelAttribute OrderIdentifier orderId,
@PathVariable String shipToId,
@Valid @RequestBody UpdateShipInfoResource request) {
The variables orderIdType and orderIdValue are bound from the model using @BindParam:
public record OrderIdentifier(
@BindParam("orderIdType")
Type type,
@BindParam("orderIdValue")
String value
)
Sonar is complaining about the component fields in the @PostMapping:
Bind template variable “orderIdValue”, “orderIdType” to a method parameter.
If there isn’t a way to get Sonar to examine the model itself, is there a better way to suppress this than either annotating every controller method, or adding a broad package-level suppression that might mask other genuine problems?