alecthomas / gometalinter

DEPRECATED: Use https://github.com/golangci/golangci-lint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Output for custom linter contains "gibberish"

soupdiver opened this issue · comments

commented

I have added a custom linter with the flag --linter='imp:goimports -l -local github.com/cloudradar-monitoring/cagent:^(?P<pathh>.*?\.go)$'. After some back and forth I got it running but the output looks a bit weird:

Gives me:

config.go:1::warning:  (imp)
cpu.go:1::warning:  (imp)
mem.go:1::warning:  (imp)
mem_windows.go:1::warning:  (imp)
processes_notwindows.go:1::warning:  (imp)
raid_test.go:1::warning:  (imp)
types.go:1::warning:  (imp)

Not really sure why always :1::warning: is added. Guess it should help identify the problem but the original output is only paths without an explanation.

Can I get rid of this :1::warning: somehow or do I have to adjust the pattern for that?
Also, is there somewhere an explanation about how to use the pattern? Which things to extract for example?

I believe those values are the default values for the fields in

gometalinter/issue.go

Lines 72 to 80 in b242b54

type Issue struct {
Linter string `json:"linter"`
Severity Severity `json:"severity"`
Path IssuePath `json:"path"`
Line int `json:"line"`
Col int `json:"col"`
Message string `json:"message"`
formatTmpl *template.Template
}

The message format is

const DefaultIssueFormat = "{{.Path}}:{{.Line}}:{{if .Col}}{{.Col}}{{end}}:{{.Severity}}: {{.Message}} ({{.Linter}})"

So the 1 is the line number and warning is severity.

You can set a different format in the config, but it would apply to all linters.

commented

@dnephin yeah seems the locations you pointed out explain the situation.
Seems there is no easy immediate fix then 🤓