mgechev / revive

šŸ”„ ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
https://revive.run
MIT License
4.78k stars 279 forks source link

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

Closed emredalkiran closed 4 months ago

emredalkiran commented 5 months ago

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**
```shell
 āœ˜  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):

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 commented 5 months ago

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 commented 4 months ago

Hi! @chavacava can you assign it to me?