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

confusing-naming FP on methods of generic types #864

Closed
feldgendler opened this issue Aug 9, 2023 · 1 comment · Fixed by #869
Closed

confusing-naming FP on methods of generic types #864

feldgendler opened this issue Aug 9, 2023 · 1 comment · Fixed by #869

Comments

@feldgendler
Copy link

Describe the bug
The confusing-naming check misfires on similarly named methods of distinct generic types.

To Reproduce
Steps to reproduce the behavior:

  1. I updated revive go install github.com/mgechev/revive@latest
  2. I run it with the following flags & configuration file:
revive -config revive.toml test.go

revive.toml:

[rule.confusing-naming]

test.go:

package test

type x[T any] struct{}

func (x[T]) method() {
}

type y[T any] struct{}

func (y[T]) method() {
}

It's completely legitimate to define methods by the same name on different types.

The false positive only happens when both x and y are generic. Defining one or both as a concrete type (such as type x struct{}) makes the issue disappear.

Expected behavior
No confusing-naming issue is reported.

Logs

test.go:10:13: Method 'method' differs only by capitalization to function 'method' in the same source file

Desktop (please complete the following information):

  • OS: Ubuntu 23.04
  • go version go1.20.6 linux/amd64
@chavacava
Copy link
Collaborator

Hi @feldgendler thanks for filling the issue.
The rule needs an update to cope with generic types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants