1 Star 0 Fork 0

Laomo. / golangci-lint

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
megacheck.go 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
package golinters
import (
"context"
megacheckAPI "github.com/golangci/go-tools/cmd/megacheck"
"github.com/golangci/golangci-lint/pkg/result"
)
type Megacheck struct {
UnusedEnabled bool
GosimpleEnabled bool
StaticcheckEnabled bool
}
func (m Megacheck) Name() string {
if m.UnusedEnabled && !m.GosimpleEnabled && !m.StaticcheckEnabled {
return "unused"
}
if m.GosimpleEnabled && !m.UnusedEnabled && !m.StaticcheckEnabled {
return "gosimple"
}
if m.StaticcheckEnabled && !m.UnusedEnabled && !m.GosimpleEnabled {
return "staticcheck"
}
return "megacheck" // all enabled
}
func (m Megacheck) Desc() string {
descs := map[string]string{
"unused": "Checks Go code for unused constants, variables, functions and types",
"gosimple": "Linter for Go source code that specialises on simplifying code",
"staticcheck": "Staticcheck is go vet on steroids, applying a ton of static analysis checks",
"megacheck": "3 sub-linters in one: unused, gosimple and staticcheck",
}
return descs[m.Name()]
}
func (m Megacheck) Run(ctx context.Context, lintCtx *Context) ([]result.Issue, error) {
issues := megacheckAPI.Run(lintCtx.Program, lintCtx.LoaderConfig, lintCtx.SSAProgram,
m.StaticcheckEnabled, m.GosimpleEnabled, m.UnusedEnabled)
var res []result.Issue
for _, i := range issues {
res = append(res, result.Issue{
Pos: i.Position,
Text: i.Text,
FromLinter: m.Name(),
})
}
return res, nil
}
1
https://gitee.com/LaomoBK/golangci-lint.git
git@gitee.com:LaomoBK/golangci-lint.git
LaomoBK
golangci-lint
golangci-lint
v1.3.5

搜索帮助

53164aa7 5694891 3bd8fe86 5694891