-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "inamedparam": checks for interface method with unnamed params (#…
…3793) Co-authored-by: Fernandez Ludovic <[email protected]>
- Loading branch information
Showing
6 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package golinters | ||
|
||
import ( | ||
"github.com/macabu/inamedparam" | ||
"golang.org/x/tools/go/analysis" | ||
|
||
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis" | ||
) | ||
|
||
func NewINamedParam() *goanalysis.Linter { | ||
a := inamedparam.Analyzer | ||
|
||
return goanalysis.NewLinter( | ||
a.Name, | ||
a.Doc, | ||
[]*analysis.Analyzer{a}, | ||
nil, | ||
).WithLoadMode(goanalysis.LoadModeSyntax) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//golangcitest:args -Einamedparam | ||
package testdata | ||
|
||
import "context" | ||
|
||
type tStruct struct { | ||
a int | ||
} | ||
|
||
type Doer interface { | ||
Do() string | ||
} | ||
|
||
type NamedParam interface { | ||
Void() | ||
|
||
NoArgs() string | ||
|
||
WithName(ctx context.Context, number int, toggle bool, tStruct *tStruct, doer Doer) (bool, error) | ||
|
||
WithoutName( | ||
context.Context, // want "interface method WithoutName must have named param for type context.Context" | ||
int, // want "interface method WithoutName must have named param for type int" | ||
bool, // want "interface method WithoutName must have named param for type bool" | ||
tStruct, // want "interface method WithoutName must have named param for type tStruct" | ||
Doer, // want "interface method WithoutName must have named param for type Doer" | ||
struct{ b bool }, // want "interface method WithoutName must have all named params" | ||
) | ||
} |