Skip to content
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

USE_DATA_CLASS: False positive for Annotations #1469

Closed
leinardi opened this issue Jul 21, 2022 · 3 comments · Fixed by #1471
Closed

USE_DATA_CLASS: False positive for Annotations #1469

leinardi opened this issue Jul 21, 2022 · 3 comments · Fixed by #1471
Assignees
Labels
bug Something isn't working
Milestone

Comments

@leinardi
Copy link

I have this annotation:

@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.CLASS)
annotation class NavGraphDestination(
    val name: String = Defaults.NULL,
    val routePrefix: String = Defaults.NULL,
    val deepLink: Boolean = false,
) {
    object Defaults {
        const val NULL = "@null"
    }
}

And Diktat complains that

There are 1 unfixed errors:
Error on line: 3, column: 1 cannot be fixed automatically
[USE_DATA_CLASS] this class can be converted to a data class: NavGraphDestination
java.lang.AssertionError: There are 1 unfixed errors:

I guess that the DataClassesRule should check if a class is an annotation, beside checking for data class and interface:

I'm having this with Diktat 1.2.1. Let me know if you need more info.

@orchestr7
Copy link
Member

Hey, yeah, nice catch, thank you!
We completely forgot about that 🤦

We are already fixing this rule in #1444 and we will fix this one also in 1.2.2 release.

Thank you very much for this report :)

@orchestr7 orchestr7 self-assigned this Jul 21, 2022
@orchestr7 orchestr7 added the bug Something isn't working label Jul 21, 2022
@orchestr7 orchestr7 added this to the 1.2.2 milestone Jul 21, 2022
@orchestr7
Copy link
Member

orchestr7 commented Jul 21, 2022

By for now you can easily @Suppress this inspection on this code block

@orchestr7
Copy link
Member

fixed in #1471

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants