java:S1213 has problems with static fields in records

We are using Sonarqube 9.6

The following code produces a false positive for rule java:S1213

public record Fraction(String numerator, String denominator) {
 public static final RoundingMode ROUNDING_MODE = RoundingMode.HALF_UP;
// Move this static variable to comply with Java Code Conventions.
 public static final int DECIMAL_SCALE = 10;
// Move this static variable to comply with Java Code Conventions.

 public Fraction {
 Objects.requireNonNull(numerator);
 Objects.requireNonNull(denominator);
 }
}

I’m not sure if its irritated by the extra constructor in the record.

Kind regards,
Michael

Hey there.

I think you’re facing this issue (just reported to us a few days ago!): SONARJAVA-4331

I’ve linked this thread to that ticket for recordkeeping / building traction – but it already looks like it is targeted for the next release.