-
Notifications
You must be signed in to change notification settings - Fork 89
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -16,6 +16,8 @@ | |||||||||||
package org.openrewrite.staticanalysis; | ||||||||||||
|
||||||||||||
import org.intellij.lang.annotations.Language; | ||||||||||||
import org.junit.jupiter.api.Disabled; | ||||||||||||
import org.junit.jupiter.api.Nested; | ||||||||||||
import org.junit.jupiter.api.Test; | ||||||||||||
import org.openrewrite.DocumentExample; | ||||||||||||
import org.openrewrite.test.RecipeSpec; | ||||||||||||
|
@@ -524,4 +526,202 @@ public interface Reproducer extends Cloneable { | |||||||||||
""" | ||||||||||||
)); | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
@Nested | ||||||||||||
class removeFalsyOverrideAnnotation { | ||||||||||||
|
||||||||||||
@Test | ||||||||||||
void simple() { | ||||||||||||
rewriteRun( | ||||||||||||
//language=java | ||||||||||||
java( | ||||||||||||
""" | ||||||||||||
package com.example; | ||||||||||||
|
||||||||||||
class Test { | ||||||||||||
@Override | ||||||||||||
public void doesNotOverrideAnything() { | ||||||||||||
} | ||||||||||||
} | ||||||||||||
""", | ||||||||||||
""" | ||||||||||||
package com.example; | ||||||||||||
|
||||||||||||
class Test { | ||||||||||||
\s | ||||||||||||
public void doesNotOverrideAnything() { | ||||||||||||
} | ||||||||||||
} | ||||||||||||
""") | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
); | ||||||||||||
} | ||||||||||||
|
||||||||||||
@Test | ||||||||||||
void multipleMethods() { | ||||||||||||
rewriteRun( | ||||||||||||
//language=java | ||||||||||||
java( | ||||||||||||
""" | ||||||||||||
package com.example; | ||||||||||||
|
||||||||||||
class Test { | ||||||||||||
@Override | ||||||||||||
public void method1() { | ||||||||||||
} | ||||||||||||
|
||||||||||||
@Override | ||||||||||||
public void method2() { | ||||||||||||
} | ||||||||||||
} | ||||||||||||
""", | ||||||||||||
""" | ||||||||||||
package com.example; | ||||||||||||
|
||||||||||||
class Test { | ||||||||||||
\s | ||||||||||||
public void method1() { | ||||||||||||
} | ||||||||||||
|
||||||||||||
\s | ||||||||||||
public void method2() { | ||||||||||||
} | ||||||||||||
} | ||||||||||||
""") | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
); | ||||||||||||
} | ||||||||||||
|
||||||||||||
@Test | ||||||||||||
void withValidOverride() { | ||||||||||||
rewriteRun( | ||||||||||||
//language=java | ||||||||||||
java( | ||||||||||||
""" | ||||||||||||
package com.example; | ||||||||||||
|
||||||||||||
class Parent { | ||||||||||||
public void validMethod() {} | ||||||||||||
} | ||||||||||||
|
||||||||||||
class Test extends Parent { | ||||||||||||
@Override | ||||||||||||
public void validMethod() {} | ||||||||||||
|
||||||||||||
@Override | ||||||||||||
public void invalidMethod() {} | ||||||||||||
} | ||||||||||||
""", | ||||||||||||
""" | ||||||||||||
package com.example; | ||||||||||||
|
||||||||||||
class Parent { | ||||||||||||
public void validMethod() {} | ||||||||||||
} | ||||||||||||
|
||||||||||||
class Test extends Parent { | ||||||||||||
@Override | ||||||||||||
public void validMethod() {} | ||||||||||||
|
||||||||||||
\s | ||||||||||||
public void invalidMethod() {} | ||||||||||||
} | ||||||||||||
""") | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
); | ||||||||||||
} | ||||||||||||
|
||||||||||||
@Test | ||||||||||||
void withInterfaceImplementation() { | ||||||||||||
rewriteRun( | ||||||||||||
//language=java | ||||||||||||
java( | ||||||||||||
""" | ||||||||||||
package com.example; | ||||||||||||
|
||||||||||||
interface MyInterface { | ||||||||||||
void interfaceMethod(); | ||||||||||||
} | ||||||||||||
|
||||||||||||
class Test implements MyInterface { | ||||||||||||
@Override | ||||||||||||
public void interfaceMethod() {} | ||||||||||||
|
||||||||||||
@Override | ||||||||||||
public void nonInterfaceMethod() {} | ||||||||||||
} | ||||||||||||
""", | ||||||||||||
""" | ||||||||||||
package com.example; | ||||||||||||
|
||||||||||||
interface MyInterface { | ||||||||||||
void interfaceMethod(); | ||||||||||||
} | ||||||||||||
|
||||||||||||
class Test implements MyInterface { | ||||||||||||
@Override | ||||||||||||
public void interfaceMethod() {} | ||||||||||||
|
||||||||||||
\s | ||||||||||||
public void nonInterfaceMethod() {} | ||||||||||||
} | ||||||||||||
""") | ||||||||||||
); | ||||||||||||
Comment on lines
+665
to
+666
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
} | ||||||||||||
|
||||||||||||
@Test | ||||||||||||
@Disabled | ||||||||||||
void withComments() { | ||||||||||||
rewriteRun( | ||||||||||||
//language=java | ||||||||||||
java( | ||||||||||||
""" | ||||||||||||
package com.example; | ||||||||||||
|
||||||||||||
class Test { | ||||||||||||
/** | ||||||||||||
* Some documentation | ||||||||||||
*/ | ||||||||||||
@Override | ||||||||||||
public void documentedMethod() { | ||||||||||||
} | ||||||||||||
} | ||||||||||||
""", | ||||||||||||
""" | ||||||||||||
package com.example; | ||||||||||||
|
||||||||||||
class Test { | ||||||||||||
/** | ||||||||||||
* Some documentation | ||||||||||||
*/ | ||||||||||||
public void documentedMethod() { | ||||||||||||
} | ||||||||||||
} | ||||||||||||
""") | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
); | ||||||||||||
} | ||||||||||||
|
||||||||||||
@Test | ||||||||||||
void withAnnotations() { | ||||||||||||
rewriteRun( | ||||||||||||
//language=java | ||||||||||||
java( | ||||||||||||
""" | ||||||||||||
package com.example; | ||||||||||||
|
||||||||||||
class Test { | ||||||||||||
@Deprecated | ||||||||||||
@Override | ||||||||||||
public void annotatedMethod() { | ||||||||||||
} | ||||||||||||
} | ||||||||||||
""", | ||||||||||||
""" | ||||||||||||
package com.example; | ||||||||||||
|
||||||||||||
class Test { | ||||||||||||
@Deprecated | ||||||||||||
public void annotatedMethod() { | ||||||||||||
} | ||||||||||||
} | ||||||||||||
""") | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
); | ||||||||||||
} | ||||||||||||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.