Skip to content

Commit

Permalink
Merge pull request #95 from k1LoW/or
Browse files Browse the repository at this point in the history
[ifacenames] Allow `-or` ( e.g. Validator )
  • Loading branch information
k1LoW authored Apr 2, 2024
2 parents f20c52e + 42e2b71 commit 264042e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions analyzer/effective/ifacenames/ifacenames.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ func run(pass *analysis.Pass) (any, error) {
case *ast.InterfaceType:
if len(n.Methods.List) == 1 && len(n.Methods.List[0].Names) > 0 {
mn := n.Methods.List[0].Names[0].Name
if !strings.HasPrefix(ii.Name, mn) || !strings.HasSuffix(ii.Name, "er") { // huristic
if !strings.HasPrefix(ii.Name, mn[:len(mn)-1]) || !(strings.HasSuffix(ii.Name, "er") || strings.HasSuffix(ii.Name, "or")) { // huristic
r.Append(n.Pos(), fmt.Sprintf("%s: %s", msg, ii.Name))
return
}
}
if all && !strings.HasSuffix(ii.Name, "er") {
if all && !(strings.HasSuffix(ii.Name, "er") || strings.HasSuffix(ii.Name, "or")) {
r.Append(n.Pos(), fmt.Sprintf("%s: %s", msgc, ii.Name))
return
}
Expand Down
4 changes: 4 additions & 0 deletions analyzer/effective/ifacenames/testdata/src/a/a.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ type Writer interface {
Write() error
}

type Validator interface {
Validate() error
}

type Add interface {
One() error
Two() error
Expand Down

0 comments on commit 264042e

Please sign in to comment.