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

Interfaces are violating the USE_DATA_CLASS rule #1003

Closed
cldfzn opened this issue Jul 27, 2021 · 3 comments · Fixed by #1014
Closed

Interfaces are violating the USE_DATA_CLASS rule #1003

cldfzn opened this issue Jul 27, 2021 · 3 comments · Fixed by #1014
Assignees
Labels
bug Something isn't working
Milestone

Comments

@cldfzn
Copy link

cldfzn commented Jul 27, 2021

Describe the bug

Interfaces are violating the USE_DATA_CLASS rule.

Expected behavior

Interfaces cannot be data classes, so this should not happen.

Observed behavior

Steps to Reproduce

Have an interface with simple fields:

interface MutationResponse {
    val code: String
    val success: Boolean
    val message: String
}

Environment information

  • diktat version: 1.0.0-rc.2
  • build tool (maven/gradle): gradle
  • how is diktat run (CLI, plugin, etc.): plugin
  • kotlin version: 1.5.21
  • operating system: macOS
  • link to a project (if your project is public):
@cldfzn cldfzn added the bug Something isn't working label Jul 27, 2021
@orchestr7
Copy link
Member

Hello, @cldfzn and thank you for your report!

Yes, it is a bug in the context of data class inspection. But what is the use case for interfaces without any methods, but which contain only with fields? May be we need to create an inspection or code style inspection to prohibit that?

@orchestr7
Copy link
Member

orchestr7 commented Jul 27, 2021

Until fixed, you can use @Suppress(“USE_DATA_CLASS”) annotation on your interface or disable this rule in config file

we will take it to 1.0.0 release

@cldfzn
Copy link
Author

cldfzn commented Jul 27, 2021

Fields can be overridden by implementations. We provide traits that can provide either a lazy or eager implementation depending on context, for example.

@orchestr7 orchestr7 self-assigned this Jul 27, 2021
@orchestr7 orchestr7 added this to the 1.0.0 milestone Jul 27, 2021
kentr0w added a commit that referenced this issue Jul 30, 2021
* Interface vs Data class bug

### What's done:
Fixed bug
Added test
Closes #1003
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