Skip to content
New issue

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

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

Already on GitHub? # to your account

backing-property-naming rule shouldn't be applied to fields that have the override modifier #2748

Closed
Ezard opened this issue Jul 22, 2024 · 0 comments · Fixed by #2753
Closed

Comments

@Ezard
Copy link

Ezard commented Jul 22, 2024

Expected Behavior

If a class overrides an abstract field that is not named according to standard conventions (e.g. __typename in code generated by GraphQL libraries such as Apollo), then the overridden field should not have a lint warning for its name, as the user has no control over this field name. Only the base field should have the lint error triggered for it (for the GraphQL example it would not be triggered, as the base field is generated code that Ktlint rightly ignores)

e.g.

// autogenerated code
interface SomeGraphQLType {
  val __typename: String
  // other, conventionally-named fields
}

// user code
object : SomeGraphQLType {
  override val __typename = "something" // <-- unfixable lint error
}

Current Behavior

A lint warning is raised for overridden fields which do not comply with standard naming conventions

Additional information

  • Current version of ktlint: 1.3.1
paul-dingemans added a commit that referenced this issue Jul 23, 2024
Name of an overridden property can only be changed by changing the name of the base property.

Closes #2748
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant