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

Possible false positive confusing-naming error on generics with pointer type receiver #982

Closed
emredalkiran opened this issue Apr 29, 2024 · 2 comments · Fixed by #985
Closed

Comments

@emredalkiran
Copy link

emredalkiran commented Apr 29, 2024

Describe the bug
confusing-naming check possibly misfires on different named methods of 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:
    command:
revive -config revive.toml test.go

config:

[rule.confusing-naming]

test.go:

package test


type a[T any] struct{}

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

type b[T any] struct{}

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

Expected behavior
Since methods are on different types, I expect check to pass

Logs

 ✘  https://revive.run/r#confusing-naming  Method 'method' differs only by capitalization to function 'method' in the same source file
  test/test.go:11:16

✘ 1 problem (1 error, 0 warnings)

Errors:
  1  confusing-naming

Desktop (please complete the following information):

  • OS: [macOS]
  • Version of Go: 1.22

Additional context
The issue is previously mentioned in #864 but the error persists if the receiver of the method is of pointer type. Is this the expected behaviour?

I'm relatively new to go, sorry if this issue is due to my misunderstanding or lack of knowledge.

@chavacava
Copy link
Collaborator

Hi @emredalkiran thanks for reporting the issue. I think the linter should be able to differentiate both methods and do not raise a warning in cases like yours.

@Entuazism
Copy link
Contributor

Hi! @chavacava can you assign it to me?

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.

3 participants