Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex
// RSPEC-S1068 does not apply serialVersionUID of Serializable classes, or fields with annotations.
if (!(skipSerialVersionUID && isSerialVersionUid(vd)) &&
vd.getLeadingAnnotations().isEmpty() &&
!(vd.getTypeExpression() instanceof J.AnnotatedType) &&
vd.hasModifier(J.Modifier.Type.Private)) {
Statement nextStatement = i < statements.size() - 1 ? statements.get(i + 1) : null;
checkFields.add(new CheckField(vd, nextStatement));
Expand Down Expand Up @@ -138,6 +139,7 @@ private boolean isSerialVersionUid(J.VariableDeclarations vd) {
TypeUtils.isOfClassType(vd.getType(), "long") &&
vd.getVariables().stream().anyMatch(it -> "serialVersionUID".equals(it.getSimpleName()));
}

};
return Preconditions.check(new NoMissingTypes(), Repeat.repeatUntilStable(visitor));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,32 @@ class A {
);
}

@Issue("https://github.com/openrewrite/rewrite-static-analysis/issues/757")
@Test
void doNotRemoveLombokAnnotatedFieldWhenAnnotationIsAfterModifier() {
rewriteRun(
spec -> spec.parser(JavaParser.fromJavaVersion().classpath("lombok")),
java(
"""
import lombok.Getter;

class OnModifier {
@Getter private String foo;
}
"""
),
java(
"""
import lombok.Getter;

class OnType {
private @Getter String foo;
}
"""
)
);
}

@Issue("https://github.com/openrewrite/rewrite-static-analysis/issues/524")
@Test
void removeUntilStable() {
Expand Down