Skip to content

Add recvcheck linter #5014

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

Merged
merged 3 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2689,6 +2689,7 @@ linters:
- promlinter
- protogetter
- reassign
- recvcheck
- revive
- rowserrcheck
- sloglint
Expand Down Expand Up @@ -2804,6 +2805,7 @@ linters:
- promlinter
- protogetter
- reassign
- recvcheck
- revive
- rowserrcheck
- sloglint
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ require (
github.com/pelletier/go-toml/v2 v2.2.3
github.com/polyfloyd/go-errorlint v1.6.0
github.com/quasilyte/go-ruleguard/dsl v0.3.22
github.com/raeperd/recvcheck v0.1.2
github.com/ryancurrah/gomodguard v1.3.5
github.com/ryanrolds/sqlclosecheck v0.5.1
github.com/sanposhiho/wastedassign/v2 v2.0.7
Expand Down
2 changes: 2 additions & 0 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@
"promlinter",
"protogetter",
"reassign",
"recvcheck",
"revive",
"rowserrcheck",
"scopelint",
Expand Down
19 changes: 19 additions & 0 deletions pkg/golinters/recvcheck/recvcheck.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package recvcheck

import (
"github.com/raeperd/recvcheck"
"golang.org/x/tools/go/analysis"

"github.com/golangci/golangci-lint/pkg/goanalysis"
)

func New() *goanalysis.Linter {
a := recvcheck.Analyzer

return goanalysis.NewLinter(
a.Name,
a.Doc,
[]*analysis.Analyzer{a},
nil,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}
11 changes: 11 additions & 0 deletions pkg/golinters/recvcheck/recvcheck_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package recvcheck_test

import (
"testing"

"github.com/golangci/golangci-lint/test/testshared/integration"
)

func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}
14 changes: 14 additions & 0 deletions pkg/golinters/recvcheck/testdata/recvcheck.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//golangcitest:args -Erecvcheck
package testdata

import "fmt"

type Bar struct{} // want `the methods of "Bar" use pointer receiver and non-pointer receiver.`

func (b Bar) A() {
fmt.Println("A")
}

func (b *Bar) B() {
fmt.Println("B")
}
7 changes: 7 additions & 0 deletions pkg/lint/lintersdb/builder_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/promlinter"
"github.com/golangci/golangci-lint/pkg/golinters/protogetter"
"github.com/golangci/golangci-lint/pkg/golinters/reassign"
"github.com/golangci/golangci-lint/pkg/golinters/recvcheck"
"github.com/golangci/golangci-lint/pkg/golinters/revive"
"github.com/golangci/golangci-lint/pkg/golinters/rowserrcheck"
"github.com/golangci/golangci-lint/pkg/golinters/sloglint"
Expand Down Expand Up @@ -657,6 +658,12 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithLoadForGoAnalysis().
WithURL("https://github.com/curioswitch/go-reassign"),

linter.NewConfig(recvcheck.New()).
WithSince("v1.62.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/raeperd/recvcheck"),

linter.NewConfig(revive.New(&cfg.LintersSettings.Revive)).
WithSince("v1.37.0").
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
Expand Down
Loading