“An open curly brace should be located at the end of a line”
I like to format code like this, but S1105 complains about the ) { for the record even though it is fine with the ) { for the method.
public record ExampleRecord(
AReallyLongClassNameThatNecessitatesSplittingOntoMultipleLines a,
AnotherReallyLongClassNameThatNecessitatesSplittingOntoMultipleLines b
) {
public AReallyLongClassNameThatNecessitatesSplittingOntoMultipleLines abc(
AReallyLongClassNameThatNecessitatesSplittingOntoMultipleLines b,
AnotherReallyLongClassNameThatNecessitatesSplittingOntoMultipleLines c
) {
return b;
}
}
It seems like it should either complain about both or neither. I’d prefer neither.
Hey, this seems to still be happening in some cases. Here are some more false positives from my code:
// If I remove the type parameters, the warning goes away
public record Batch<E, L>(
List<E> elements,
@Nullable L lastElement
) { // <- Sonar complains about this one
// If I remove this method, the warning goes away
public boolean isEmpty() {
return elements.isEmpty();
}
}
and
public record SomeRecord(Integer value) {
public SomeRecord(String id) { // <- Sonar complains about this one
this(0);
}
// Removing this field makes the warning go away
public static final String EXAMPLE = "example";
}
and
public record OuterRecord(String value) {
public String getThing() { // <- Sonar complains about this one
return null;
}
// Removing this record declaration makes the warning go away
private record InnerRecord(int value) {}
}