Denis Isaev a6b91ccc77 Fix #124: support unparam linter
1. Support unparam linter and fix found issues
2. Replace forked mvdan.cc/lint and mvdan.cc/interfacer with the
upstream ones
3. Minimize forked megacheck: move the most of it's code to this repo
4. Use golang.org/x/tools/go/ssa import path instead of custom fork
paths
5. In golang.org/x/tools/go/{ssa,callgraph} use changed code from
honnef.co/go/tools
6. Add megacheck.check-unexported option: it found some issues in
the repo, fixed them all
2018-06-30 12:24:07 +03:00

46 lines
893 B
Go

package golinters
import (
"context"
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/result"
"mvdan.cc/unparam/check"
)
type Unparam struct{}
func (Unparam) Name() string {
return "unparam"
}
func (Unparam) Desc() string {
return "Reports unused function parameters"
}
func (lint Unparam) Run(ctx context.Context, lintCtx *linter.Context) ([]result.Issue, error) {
us := &lintCtx.Settings().Unparam
c := &check.Checker{}
c.Algo(us.Algo)
c.Exported(us.CheckExported)
c.Program(lintCtx.Program)
c.ProgramSSA(lintCtx.SSAProgram)
unparamIssues, err := c.Check()
if err != nil {
return nil, err
}
var res []result.Issue
for _, i := range unparamIssues {
res = append(res, result.Issue{
Pos: lintCtx.Program.Fset.Position(i.Pos()),
Text: i.Message(),
FromLinter: lint.Name(),
})
}
return res, nil
}