rewrite
rewrite copied to clipboard
org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods ignores class level @SuppressWarnings("unused")
What version of OpenRewrite are you using?
6.6.3
How are you running OpenRewrite?
What is the smallest, simplest way to reproduce the problem?
@SuppressWarnings("unused")
class A {
@SuppressWarnings("unused")
private static void foo() {
}
private void bar() {
}
}
What did you expect to see?
@SuppressWarnings("unused")
class A {
@SuppressWarnings("unused")
private static void foo() {
}
private void bar() {
}
}
What did you see instead?
@SuppressWarnings("unused")
class A {
@SuppressWarnings("unused")
private static void foo() {
}
}
The looks like that https://github.com/openrewrite/rewrite-static-analysis/blob/main/src/main/java/org/openrewrite/staticanalysis/RemoveUnusedPrivateMethods.java#L62 doesn't look at the class level annotation and is also just assuming that any class annotation means don't do anything. IT should look for @SuppressWarnings("unused") at the class level.
What is the full stack trace of any errors you encountered?
stacktrace output here