golangci / golangci-lint

Fast linters runner for Go
https://golangci-lint.run
GNU General Public License v3.0
15.68k stars 1.39k forks source link

Feature: new out-format for vim-quickfix #895

Closed kyoh86 closed 3 years ago

kyoh86 commented 4 years ago

Please include the following information:

Version of golangci-lint ```console $ golangci-lint --version golangci-lint has version 1.21.0 built from 645e794 on 2019-10-15T18:16:56Z ```
Config file ```console $ cat .golangci.yml linters: enable: - unparam - scopelint - golint - gochecknoinits - bodyclose - depguard - dogsled - dupl - gochecknoinits - gocognit - goconst - gocritic - gocyclo - godox - gofmt - goimports - golint - gosec - maligned - misspell - nakedret - prealloc - stylecheck - unconvert - whitespace linters-settings: gocritic: disabled-checks: - elseif ```
Go environment ```console $ go version && go env go version go1.13.5 linux/amd64 ```
Verbose output of running ```console $ golangci-lint run -v INFO [config_reader] Config search paths: [./ /home/kyoh86/Projects/github.com/kyoh86/gogh /home/kyoh86/Projects/github.com/kyoh86 /home/kyoh86/Projects/github.com /home/kyoh86/Projects /home/kyoh86 /home /] INFO [config_reader] Used config file .golangci.yml INFO [lintersdb] Active 33 linters: [bodyclose deadcode depguard dogsled dupl errcheck gochecknoinits gocognit goconst gocritic gocyclo godox gofmt goimports golint gosec gosimple govet ineffassign maligned misspell nakedret prealloc scopelint staticcheck structcheck stylecheck typec heck unconvert unparam unused varcheck whitespace] INFO [loader] Go packages loading at mode 575 (types_sizes|compiled_files|deps|imports|name|exports_file|files) took 153.014097ms INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 5.028859ms INFO [runner/unused/goanalysis] analyzers took 0s with no stages INFO [runner/goanalysis_metalinter/goanalysis] analyzers took 0s with no stages INFO [runner/max_same_issues] 1/4 issues with text "`charactor` is a misspelling of `character`" were hidden, use --max-same-issues INFO [runner/max_same_issues] 1/4 issues with text "unnecessary trailing newline" were hidden, use --max-same-issues INFO [runner] Issues before processing: 196, after processing: 22 INFO [runner] Processors filtering stat (out/in): path_prettifier: 196/196, nolint: 32/32, uniq_by_line: 25/32, exclude-rules: 32/32, path_shortener: 22/22, cgo: 196/196, skip_files: 196/196, autogenerated_exclude: 196/196, exclude: 32/196, max_same_issues: 22/24, source_code: 22/22, max_per_file_from_linter: 24/25, max_from_linter: 22/22, filename_unadjuster: 196/196, skip_dirs: 196/196, identifier_marker: 196/196, diff: 25/25 INFO [runner] processing took 17.376086ms with stages: exclude: 7.484844ms, identifier_marker: 5.247309ms, nolint: 2.973583ms, path_prettifier: 960.599µs, autogenerated_exclude: 318.277µs, source_code: 157.936µs, skip_dirs: 146.441µs, max_same_issues: 42.899µs, cgo: 12.292µs, uniq_by _line: 10.535µs, filename_unadjuster: 6.533µs, max_from_linter: 5.605µs, path_shortener: 5.505µs, max_per_file_from_linter: 2.994µs, diff: 267ns, skip_files: 256ns, exclude-rules: 211ns INFO [runner] linters took 107.838362ms with stages: unused: 64.220035ms, goanalysis_metalinter: 26.045003ms command/where_test.go:97: unnecessary trailing newline (whitespace) } sh/assets.go:14: File is not `gofmt`-ed with `-s` (gofmt) "/src": []string{ config/path_list_test.go:15: unnecessary leading newline (whitespace) func TestPathListOption(t *testing.T) { config/get.go:24: G101: Potential hardcoded credentials (gosec) envGoghGitHubToken = "GOGH_GITHUB_TOKEN" config/accessor.go:13:2: error var EmptyValue should have name of the form ErrFoo (golint) EmptyValue = errors.New("empty value") ^ config/accessor.go:14:2: error var RemoveFromMonoOption should have name of the form ErrFoo (golint) RemoveFromMonoOption = errors.New("removing from mono option") ^ config/accessor.go:15:2: error var InvalidOptionName should have name of the form ErrFoo (golint) InvalidOptionName = errors.New("invalid option name") ^ config/accessor.go:16:2: error var TokenMustNotSave should have name of the form ErrFoo (golint) TokenMustNotSave = errors.New("token must not save") ^ config/accessor.go:48:1: don't use `init` function (gochecknoinits) func init() { ^ config/accessor_test.go:18:22: string `token1` has 3 occurrences, make it a constant (goconst) cfg.GitHub.Token = "token1" ^ config/accessor_test.go:19:21: string `hostx1` has 3 occurrences, make it a constant (goconst) cfg.GitHub.Host = "hostx1" ^ config/accessor_test.go:20:21: string `kyoh86` has 3 occurrences, make it a constant (goconst) cfg.GitHub.User = "kyoh86" ^ config/accessor_test.go:21:19: string `trace` has 3 occurrences, make it a constant (goconst) cfg.Log.Level = "trace" ^ gogh/formatter_test.go:130: unnecessary trailing newline (whitespace) } gogh/local_test.go:71: unnecessary trailing newline (whitespace) } gogh/local.go:23:2: error var ProjectNotFound should have name of the form ErrFoo (golint) ProjectNotFound = errors.New("project not found") ^ gogh/local.go:24:2: comment on exported var `ProjectAlreadyExists` should be of the form `ProjectAlreadyExists ...` (golint) // ProjectNotFound is the error will be raised when a project already exists. ^ gogh/local.go:25:2: error var ProjectAlreadyExists should have name of the form ErrFoo (golint) ProjectAlreadyExists = errors.New("project already exists") ^ gogh/local_test.go:66:68: `charactor` is a misspelling of `character` (misspell) t.Run("expect to fail to parse project name that contains invalid charactor", func(t *testing.T) { ^ gogh/repo_test.go:85:47: `charactor` is a misspelling of `character` (misspell) t.Run("fail when owner name contains invalid charactor", func(t *testing.T) { ^ gogh/repo_test.go:103:49: `charactor` is a misspelling of `character` (misspell) t.Run("fail when project name contains invalid charactor", func(t *testing.T) { ^ gogh/repo.go:176:22: response body must be closed (bodyclose) res, err := http.Get(url.String()) ^ INFO File cache stats: 11 entries of total size 56.8KiB INFO Memory: 4 samples, avg is 69.4MB, max is 69.9MB INFO Execution took 281.881252ms ```

summary

I want to get a quickfix-list for vim with golangci-lint. quickfix-list is formatted as errorformat. It's supported by a go-library: https://github.com/reviewdog/errorformat

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

telemachus commented 2 years ago

FYI, there's no need to adjust golangci-lint's output.

Instead, you can adjust the errorformat that Vim or Neovim expect.

E.g., this setting uses the first line of golangci-lint's output to populate the quickfix and ignores the rest of the lines (which aren't needed in this context).

See :help errorformat for more details.

errorformat=%A%f:%l:%c:\ %m,%-G%.%#