Skip to content

MissingOverrideAnnotation: removeFalsyOverrideAnnotation #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Pankraz76
Copy link
Contributor

@Pankraz76 Pankraz76 commented Aug 2, 2025

What's changed?

It seems the rules does not cover false positives as well. Should this be included?

What's your motivation?

are those annotations really necessary

Anything in particular you'd like reviewers to focus on?

Anyone you would like to review specifically?

Have you considered any alternatives or workarounds?

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@Pankraz76
Copy link
Contributor Author

is this any good? @timtebeek

fell free to tune and complete @iddeepak

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • src/main/java/org/openrewrite/staticanalysis/MissingOverrideAnnotation.java
    • lines 33-33

Comment on lines +20 to 21
import lombok.var;
import org.jspecify.annotations.Nullable;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import lombok.var;
import org.jspecify.annotations.Nullable;
import org.jspecify.annotations.Nullable;

public void doesNotOverrideAnything() {
}
}
""")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
""")
"""
)

public void method2() {
}
}
""")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
""")
"""
)

\s
public void invalidMethod() {}
}
""")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
""")
"""
)

Comment on lines +665 to +666
""")
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
""")
);
"""
)
@Test

public void documentedMethod() {
}
}
""")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
""")
"""
)

public void annotatedMethod() {
}
}
""")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
""")
"""
)

@Pankraz76 Pankraz76 changed the title removeFalsyOverrideAnnotation missingoverrideannotation: removeFalsyOverrideAnnotation Aug 2, 2025
@Pankraz76 Pankraz76 changed the title missingoverrideannotation: removeFalsyOverrideAnnotation MissingOverrideAnnotation: removeFalsyOverrideAnnotation Aug 2, 2025
@timtebeek
Copy link
Member

On my machine this already fails to compile; what would be the reason then to add this to a recipe that aims to add missing override annotations?
image

I'd lean towards closing this effort, as it's quite unlikely, and misplaced / unexpected in this recipe.

@Pankraz76
Copy link
Contributor Author

aims to add missing override annotations

What about changing the scope to check for corrupt (missing/falsy) override annotations.

We could create a new one like CheckforFalsyOverrideAnnotation but that would impose configuration burden on customer instead of applying convention. Once could argue that every recipe, could check for false negatives as well.

As if not, gonna have to copy potentially every recipe 1 times to check for false negative as well.

@timtebeek
Copy link
Member

As indicated above, a misplaced Override annotation already does not compile on my machine; have you seen any number of example of that in the wild at all that warrant an automated remediation? If there's a convincing case we can reopen, but for now I just don't see it.

@timtebeek timtebeek closed this Aug 8, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Aug 8, 2025
@Pankraz76
Copy link
Contributor Author

this was my intention:

apache/kafka@2575f47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants