Code Monkey home page Code Monkey logo

gometalinter's Introduction

Go Meta Linter


gometalinter is DEPRECATED and the project will be archived on 2019-04-07. See #590 for discussion.

Switch to golangci-lint.


Build Status Gitter chat

The number of tools for statically checking Go source for errors and warnings is impressive.

This is a tool that concurrently runs a whole bunch of those linters and normalises their output to a standard format:

<file>:<line>:[<column>]: <message> (<linter>)

eg.

stutter.go:9::warning: unused global variable unusedGlobal (varcheck)
stutter.go:12:6:warning: exported type MyStruct should have comment or be unexported (golint)

It is intended for use with editor/IDE integration.

Installing

Binary Releases

To install the latest stable release:

curl -L https://git.io/vp6lP | sh

Alternatively you can install a specific version from the releases list.

Homebrew

brew tap alecthomas/homebrew-tap
brew install gometalinter

Editor integration

Supported linters

  • go vet - Reports potential errors that otherwise compile.
  • go tool vet --shadow - Reports variables that may have been unintentionally shadowed.
  • gotype - Syntactic and semantic analysis similar to the Go compiler.
  • gotype -x - Syntactic and semantic analysis in external test packages (similar to the Go compiler).
  • deadcode - Finds unused code.
  • gocyclo - Computes the cyclomatic complexity of functions.
  • golint - Google's (mostly stylistic) linter.
  • varcheck - Find unused global variables and constants.
  • structcheck - Find unused struct fields.
  • maligned - Detect structs that would take less memory if their fields were sorted.
  • errcheck - Check that error return values are used.
  • staticcheck - Statically detect bugs, both obvious and subtle ones.
  • dupl - Reports potentially duplicated code.
  • ineffassign - Detect when assignments to existing variables are not used.
  • interfacer - Suggest narrower interfaces that can be used.
  • unconvert - Detect redundant type conversions.
  • goconst - Finds repeated strings that could be replaced by a constant.
  • gosec - Inspects source code for security problems by scanning the Go AST.

Disabled by default (enable with --enable=<linter>):

  • testify - Show location of failed testify assertions.
  • test - Show location of test failures from the stdlib testing module.
  • gofmt -s - Checks if the code is properly formatted and could not be further simplified.
  • goimports - Checks missing or unreferenced package imports.
  • gochecknoinits - Report init functions, to reduce side effects in code.
  • gochecknoglobals - Report global vars, to reduce side effects in code.
  • lll - Report long lines (see --line-length=N).
  • misspell - Finds commonly misspelled English words.
  • nakedret - Finds naked returns.
  • unparam - Find unused function parameters.
  • safesql - Finds potential SQL injection vulnerabilities.

Additional linters can be added through the command line with --linter=NAME:COMMAND:PATTERN (see below).

Configuration file

gometalinter now supports a JSON configuration file called .gometalinter.json that can be placed at the root of your project. The configuration file will be automatically loaded from the working directory or any parent directory and can be overridden by passing --config=<file> or ignored with --no-config. The format of this file is determined by the Config struct in config.go.

The configuration file mostly corresponds to command-line flags, with the following exceptions:

  • Linters defined in the configuration file will overlay existing definitions, not replace them.
  • "Enable" defines the exact set of linters that will be enabled (default linters are disabled). --help displays the list of default linters with the exact names you must use.

Here is an example configuration file:

{
  "Enable": ["deadcode", "unconvert"]
}

If a .gometalinter.json file is loaded, individual options can still be overridden by passing command-line flags. All flags are parsed in order, meaning configuration passed with the --config flag will override any command-line flags passed before and be overridden by flags passed after.

Format key

The default Format key places the different fields of an Issue into a template. this corresponds to the --format option command-line flag.

Default Format:

Format: "{{.Path}}:{{.Line}}:{{if .Col}}{{.Col}}{{end}}:{{.Severity}}: {{.Message}} ({{.Linter}})"

Format Methods

  • {{.Path.Relative}} - equivalent to {{.Path}} which outputs a relative path to the file
  • {{.Path.Abs}} - outputs an absolute path to the file

Adding Custom linters

Linters can be added and customized from the config file using the Linters field. Linters supports the following fields:

  • Command - the path to the linter binary and any default arguments
  • Pattern - a regular expression used to parse the linter output
  • IsFast - if the linter should be run when the --fast flag is used
  • PartitionStrategy - how paths args should be passed to the linter command:
    • directories - call the linter once with a list of all the directories
    • files - call the linter once with a list of all the files
    • packages - call the linter once with a list of all the package paths
    • files-by-package - call the linter once per package with a list of the files in the package.
    • single-directory - call the linter once per directory

The config for default linters can be overridden by using the name of the linter.

Additional linters can be configured via the command line using the format NAME:COMMAND:PATTERN.

Example:

$ gometalinter --linter='vet:go tool vet -printfuncs=Infof,Debugf,Warningf,Errorf:PATH:LINE:MESSAGE' .

Comment directives

gometalinter supports suppression of linter messages via comment directives. The form of the directive is:

// nolint[: <linter>[, <linter>, ...]]

Suppression works in the following way:

  1. Line-level suppression

    A comment directive suppresses any linter messages on that line.

    eg. In this example any messages for a := 10 will be suppressed and errcheck messages for defer r.Close() will also be suppressed.

    a := 10 // nolint
    a = 2
    defer r.Close() // nolint: errcheck
  2. Statement-level suppression

    A comment directive at the same indentation level as a statement it immediately precedes will also suppress any linter messages in that entire statement.

    eg. In this example all messages for SomeFunc() will be suppressed.

    // nolint
    func SomeFunc() {
    }

Implementation details: gometalinter now performs parsing of Go source code, to extract linter directives and associate them with line ranges. To avoid unnecessary processing, parsing is on-demand: the first time a linter emits a message for a file, that file is parsed for directives.

Quickstart

Install gometalinter (see above).

Run it:

$ cd example
$ gometalinter ./...
stutter.go:13::warning: unused struct field MyStruct.Unused (structcheck)
stutter.go:9::warning: unused global variable unusedGlobal (varcheck)
stutter.go:12:6:warning: exported type MyStruct should have comment or be unexported (golint)
stutter.go:16:6:warning: exported type PublicUndocumented should have comment or be unexported (golint)
stutter.go:8:1:warning: unusedGlobal is unused (deadcode)
stutter.go:12:1:warning: MyStruct is unused (deadcode)
stutter.go:16:1:warning: PublicUndocumented is unused (deadcode)
stutter.go:20:1:warning: duplicateDefer is unused (deadcode)
stutter.go:21:15:warning: error return value not checked (defer a.Close()) (errcheck)
stutter.go:22:15:warning: error return value not checked (defer a.Close()) (errcheck)
stutter.go:27:6:warning: error return value not checked (doit()           // test for errcheck) (errcheck)
stutter.go:29::error: unreachable code (vet)
stutter.go:26::error: missing argument for Printf("%d"): format reads arg 1, have only 0 args (vet)

Gometalinter also supports the commonly seen <path>/... recursive path format. Note that this can be very slow, and you may need to increase the linter --deadline to allow linters to complete.

FAQ

Exit status

gometalinter sets two bits of the exit status to indicate different issues:

Bit Meaning
0 A linter generated an issue.
1 An underlying error occurred; eg. a linter failed to execute. In this situation a warning will also be displayed.

eg. linter only = 1, underlying only = 2, linter + underlying = 3

What's the best way to use gometalinter in CI?

There are two main problems running in a CI:

  1. Linters break, causing gometalinter --install --update to error (this is no longer an issue as all linters are vendored).
  2. gometalinter adds a new linter.

I have solved 1 by vendoring the linters.

For 2, the best option is to disable all linters, then explicitly enable the ones you want:

gometalinter --disable-all --enable=errcheck --enable=vet --enable=vetshadow ...

How do I make gometalinter work with Go 1.5 vendoring?

gometalinter has a --vendor flag that just sets GO15VENDOREXPERIMENT=1, however the underlying tools must support it. Ensure that all of the linters are up to date and built with Go 1.5 (gometalinter --install --force) then run gometalinter --vendor .. That should be it.

Why does gometalinter --install install a fork of gocyclo?

I forked gocyclo because the upstream behaviour is to recursively check all subdirectories even when just a single directory is specified. This made it unusably slow when vendoring. The recursive behaviour can be achieved with gometalinter by explicitly specifying <path>/.... There is a pull request open.

Many unexpected errors are being reported

If you see a whole bunch of errors being reported that you wouldn't expect, such as compile errors, this typically means that something is wrong with your Go environment. Try go install and fix any issues with your go installation, then try gometalinter again.

Gometalinter is not working

That's more of a statement than a question, but okay.

Sometimes gometalinter will not report issues that you think it should. There are three things to try in that case:

1. Update to the latest build of gometalinter and all linters

curl -L https://git.io/vp6lP | sh

If you're lucky, this will fix the problem.

2. Analyse the debug output

If that doesn't help, the problem may be elsewhere (in no particular order):

  1. Upstream linter has changed its output or semantics.
  2. gometalinter is not invoking the tool correctly.
  3. gometalinter regular expression matches are not correct for a linter.
  4. Linter is exceeding the deadline.

To find out what's going on run in debug mode:

gometalinter --debug

This will show all output from the linters and should indicate why it is failing.

3. Report an issue.

Failing all else, if the problem looks like a bug please file an issue and include the output of gometalinter --debug.

How do I filter issues between two git refs?

revgrep can be used to filter the output of gometalinter to show issues on lines that have changed between two git refs, such as unstaged changes, changes in HEAD vs master and between master and origin/master. See the project's documentation and -help usage for more information.

go get -u github.com/bradleyfalzon/revgrep/...
gometalinter |& revgrep               # If unstaged changes or untracked files, those issues are shown.
gometalinter |& revgrep               # Else show issues in the last commit.
gometalinter |& revgrep master        # Show issues between master and HEAD (or any other reference).
gometalinter |& revgrep origin/master # Show issues that haven't been pushed.

Checkstyle XML format

gometalinter supports checkstyle compatible XML output format. It is triggered with --checkstyle flag:

gometalinter --checkstyle

Checkstyle format can be used to integrate gometalinter with Jenkins CI with the help of Checkstyle Plugin.

gometalinter's People

Contributors

akolosov avatar alecthomas avatar bhcleek avatar bradleyfalzon avatar casimir avatar dnephin avatar dominikh avatar emead avatar ewohltman avatar fln avatar garethlewin avatar jeffwillette avatar justincampbell avatar kulti avatar leighmcculloch avatar mvdan avatar nl5887 avatar palsivertsen avatar pierrre avatar pocke avatar powerman avatar prateek avatar richpoirier avatar rliebz avatar rofrol avatar temoto avatar thajeztah avatar thomasheller avatar yasushi-saito avatar zmb3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gometalinter's Issues

go vet should not be installed

If I'm not mistaken, go vet comes with the go installation, and is tied to the installed go version.

There's no need to install it explicitly.

-i flag duplicated

The Short('i') flag introduced in #71 for the includeFlag overwrites the 'installFlag' short option, resulting in -i no longer working for --install

One of these needs to have its short flag renamed.

errcheck linter does not show full file path

Inside github.com/signalfx/golib, when I execute time gometalinter -Dgotype --deadline 60s ./...

I see

tcpport.go:20:2:warning: error return value not checked (l.Close()) (errcheck)

I expected to see:

nettest/tcpport.go:20:2:warning: error return value not checked (l.Close()) (errcheck)

errcheck no longer works

Hi,

I'm not sure if I did something wrong or gometalinter do not run errcheck on files

My output from example folder:

gometalinter .
stutter.go:22::error: Repeating defer a.Close() inside function duplicateDefer
stutter.go:9::warning: unused global variable unusedGlobal
stutter.go:13::warning: unused struct field MyStruct.Unused
stutter.go:12:6:warning: exported type MyStruct should have comment or be unexported
stutter.go:16:6:warning: exported type PublicUndocumented should have comment or be unexported
stutter.go:29::error: unreachable code
stutter.go:26::error: missing argument for Printf("%d"): format reads arg 1, have only 0 args

It should show error/warning also for line 27.
Can be related to kisielk/errcheck#45

main.go:147: too many arguments in call to kingpin.Flag

C:\Users\bbigras>go get -u github.com/alecthomas/gometalinter
# github.com/alecthomas/gometalinter
d:\dev\go\gopath\src\github.com\alecthomas\gometalinter\main.go:147: too many arguments in call to kingpin.Flag("sort", fmt.Sprintf("Sort output by any of %s.",
 strings.Join(sortKeys, ", "))).Default("none").parserMixin.Enums

GetFileAttributesEx .\*.go warnings

When running gometalinter ./... over a package, I get the following warnings for each directory:

GetFileAttributesEx .\*.go: The filename, directory name, or volume label syntax is incorrect.:1::warning: file is not goimported (goimports)
GetFileAttributesEx .\*.go: The filename, directory name, or volume label syntax is incorrect.:1::warning: file is not gofmted (gofmt)

All my files are gofmted and goimported, it seems it barks this over directories or the *.go pattern...

Go 1.5 on Win10

Add license file

I want to use/reuse/fork gometalinter but cannot for my company because there is no LICENSE file. While gometalinter cannot guarantee the license of the things it uses, it would be good if it had a LICENSE for the contained code. I recommend apache 2.0 or MIT, but it's up to you.

Update imports to use `golang.org/x`

running gometalinter --install produces the following:

Installing golint -> go get github.com/golang/lint/golint
# github.com/golang/lint
gocode/src/github.com/golang/lint/lint.go:206: cannot use gcImporter (type func(map[string]*"golang.org/x/tools/go/types".Package, string) (*"golang.org/x/tools/go/types".Package, error)) as type "code.google.com/p/go.tools/go/types".Importer in field value
gometalinter: error: failed to install golint: exit status 2
Installing gotype -> go get code.google.com/p/go.tools/cmd/gotype
Installing errcheck -> go get github.com/kisielk/errcheck
# github.com/kisielk/errcheck/lib
gocode/src/github.com/kisielk/errcheck/lib/errcheck.go:139: impossible type switch case: c.pkg.Info.Types[call].Type (type "golang.org/x/tools/go/types".Type) cannot have dynamic type *"code.google.com/p/go.tools/go/types".Named (wrong type for Underlying method)
    have Underlying() "code.google.com/p/go.tools/go/types".Type
    want Underlying() "golang.org/x/tools/go/types".Type
gocode/src/github.com/kisielk/errcheck/lib/errcheck.go:142: impossible type switch case: c.pkg.Info.Types[call].Type (type "golang.org/x/tools/go/types".Type) cannot have dynamic type *"code.google.com/p/go.tools/go/types".Tuple (wrong type for Underlying method)
    have Underlying() "code.google.com/p/go.tools/go/types".Type
    want Underlying() "golang.org/x/tools/go/types".Type
gocode/src/github.com/kisielk/errcheck/lib/errcheck.go:169: impossible type assertion:
    *"code.google.com/p/go.tools/go/types".Builtin does not implement "golang.org/x/tools/go/types".Object (wrong type for Parent method)
        have Parent() *"code.google.com/p/go.tools/go/types".Scope
        want Parent() *"golang.org/x/tools/go/types".Scope
gometalinter: error: failed to install errcheck: exit status 2
Installing defercheck -> go get github.com/opennota/check/cmd/defercheck
Installing varcheck -> go get github.com/opennota/check/cmd/varcheck
# honnef.co/go/importer
gocode/src/honnef.co/go/importer/importer.go:72: cannot use imp.Imports (type map[string]*"code.google.com/p/go.tools/go/types".Package) as type map[string]*"golang.org/x/tools/go/types".Package in argument to gcimporter.Import
gocode/src/honnef.co/go/importer/importer.go:72: cannot assign *"golang.org/x/tools/go/types".Package to pkg (type *"code.google.com/p/go.tools/go/types".Package) in multiple assignment
gocode/src/honnef.co/go/importer/importer.go:150: cannot use imp.Imports (type map[string]*"code.google.com/p/go.tools/go/types".Package) as type map[string]*"golang.org/x/tools/go/types".Package in argument to gcimporter.Import
gocode/src/honnef.co/go/importer/importer.go:152: cannot use gcPkg (type *"golang.org/x/tools/go/types".Package) as type *"code.google.com/p/go.tools/go/types".Package in argument to imported
gocode/src/honnef.co/go/importer/importer.go:154: cannot use gcPkg (type *"golang.org/x/tools/go/types".Package) as type *"code.google.com/p/go.tools/go/types".Package in return argument
gometalinter: error: failed to install varcheck: exit status 2
Installing structcheck -> go get github.com/opennota/check/cmd/structcheck
# honnef.co/go/importer
gocode/src/honnef.co/go/importer/importer.go:72: cannot use imp.Imports (type map[string]*"code.google.com/p/go.tools/go/types".Package) as type map[string]*"golang.org/x/tools/go/types".Package in argument to gcimporter.Import
gocode/src/honnef.co/go/importer/importer.go:72: cannot assign *"golang.org/x/tools/go/types".Package to pkg (type *"code.google.com/p/go.tools/go/types".Package) in multiple assignment
gocode/src/honnef.co/go/importer/importer.go:150: cannot use imp.Imports (type map[string]*"code.google.com/p/go.tools/go/types".Package) as type map[string]*"golang.org/x/tools/go/types".Package in argument to gcimporter.Import
gocode/src/honnef.co/go/importer/importer.go:152: cannot use gcPkg (type *"golang.org/x/tools/go/types".Package) as type *"code.google.com/p/go.tools/go/types".Package in argument to imported
gocode/src/honnef.co/go/importer/importer.go:154: cannot use gcPkg (type *"golang.org/x/tools/go/types".Package) as type *"code.google.com/p/go.tools/go/types".Package in return argument
gometalinter: error: failed to install structcheck: exit status 2

I'll submit a PR separately.

'examples' missed

As README.md tolds: cd $GOPATH/src/github.com/alecthomas/gometalinter/example -- but there is no one.

output file names are not relative to the current directory

When I run gometalinter inside a project directory, the file names in its output are relative to my $GOPATH/src/ instead of to the current directory:

; echo $GOPATH
/home/alcortes/room/workspaces/go
; pwd
/home/alcortes/room/workspaces/go/src/alcortes/summerfield/ch4/ex4.4.1
; ls
guess_separator.go  guess_separator_internal_test.go  README.md  SCRIPTS  test_00_tabs.txt
; gometalinter 
alcortes/summerfield/ch4/ex4.4.1/guess_separator.go:33:13:warning: error return value not checked (file.Close()) (errcheck)
alcortes/summerfield/ch4/ex4.4.1/guess_separator_internal_test.go:22:18:warning: error return value not checked (buf.WriteString(lines[i] + "\n")) (errcheck)
alcortes/summerfield/ch4/ex4.4.1/guess_separator_internal_test.go:143:10:warning: error return value not checked (m.Seek(0, 0)) (errcheck)

Shouldn't it be something like this instead?

; gometalinter 
guess_separator.go:33:13:warning: error return value not checked (file.Close()) (errcheck)
guess_separator_internal_test.go:22:18:warning: error return value not checked (buf.WriteString(lines[i] + "\n")) (errcheck)
guess_separator_internal_test.go:143:10:warning: error return value not checked (m.Seek(0, 0)) (errcheck)

structcheck *.go different than structcheck .

Calling structcheck *.go is different than calling structcheck ., which is causing issues running the meta linter.

Particularly, if you have a struct defined in one file and in another file inside the same package you add a method to that struct, then structcheck *.go (and gometalinter) will report undeclared name on that method while structcheck . will report no errors.

dupl.exe panics, leaves orphaned process.

On my Windows7 machine for some reason dupl -plumbing -t 50 ./*.go panics immediately, but hangs rather than exiting. stderr just outputs "panic: ". gometalinter's deadline should fix this by forcing dupl to die, but for some reason it doesn't, so dupl and its conhost remain orphaned in processes forever. Particularly noticeable when using the sublimetext integration, since it supresses the error message.Debug output below:

C:\Users\adsmith\workspace\go\src\github.com\darimart\darimart\utilities>gometalinter -D gotype --debug
DEBUG: linting path .
DEBUG: linter gofmt disabled
DEBUG: linter gotype disabled
DEBUG: linter goimports disabled
DEBUG: linter testify disabled
DEBUG: linter test disabled
DEBUG: linting with aligncheck: aligncheck . (on .)
DEBUG: linting with vetshadow: go tool vet --shadow ./*.go (on .)
DEBUG: linting with gocyclo: gocyclo -over {mincyclo} . (on .)
DEBUG: executing cmd /C "go tool vet --shadow ./*.go"
DEBUG: linting with errcheck: errcheck -abspath . (on .)
DEBUG: linting with vet: go tool vet ./*.go (on .)
DEBUG: linting with varcheck: varcheck . (on .)
DEBUG: linting with ineffassign: ineffassign -n . (on .)
DEBUG: linting with golint: golint -min_confidence {min_confidence} . (on .)
DEBUG: linting with dupl: dupl -plumbing -threshold {duplthreshold} ./*.go (on .)
DEBUG: linting with structcheck: structcheck {tests=-t} . (on .)
DEBUG: executing cmd /C "aligncheck ."
DEBUG: linting with deadcode: deadcode . (on .)
DEBUG: executing cmd /C "gocyclo -over 10 ."
DEBUG: executing cmd /C "ineffassign -n ."
DEBUG: executing cmd /C "go tool vet ./*.go"
DEBUG: executing cmd /C "golint -min_confidence 0.800000 ."
DEBUG: executing cmd /C "errcheck -abspath ."
DEBUG: executing cmd /C "dupl -plumbing -threshold 50 ./*.go"
DEBUG: executing cmd /C "varcheck ."
DEBUG: executing cmd /C "structcheck  ."
DEBUG: executing cmd /C "deadcode ."
DEBUG: deadcode hits 0: ^deadcode: (?P<path>[^:]+):(?P<line>\d+):(?P<col>\d+):\s*(?P<message>.*)$
DEBUG: deadcode linter took 370.037ms
DEBUG: gocyclo hits 0: ^(?P<cyclo>\d+)\s+\S+\s(?P<function>\S+)\s+(?P<path>[^:]+):(?P<line>\d+):(\d+)$
DEBUG: gocyclo linter took 385.0385ms
DEBUG: golint hits 0: ^(?P<path>[^\s][^:]+?\.go):(?P<line>\d+):(?P<col>\d+):\s*(?P<message>.*)$
DEBUG: golint linter took 394.0394ms
DEBUG: ineffassign hits 0: ^(?P<path>[^\s][^:]+?\.go):(?P<line>\d+):(?P<col>\d+):\s*(?P<message>.*)$
DEBUG: ineffassign linter took 396.0396ms
DEBUG: warning: varcheck . returned exit status 1
DEBUG: warning: aligncheck . returned exit status 1
DEBUG: varcheck hits 0: ^(?:[^:]+: )?(?P<path>[^:]+):(?P<line>\d+):(?P<col>\d+):\s*(?P<message>\w+)$
DEBUG: varcheck linter took 428.0428ms
DEBUG: aligncheck hits 0: ^(?:[^:]+: )?(?P<path>[^:]+):(?P<line>\d+):(?P<col>\d+):\s*(?P<message>.+)$
DEBUG: aligncheck linter took 429.0429ms
DEBUG: structcheck hits 0: ^(?:[^:]+: )?(?P<path>[^:]+):(?P<line>\d+):(?P<col>\d+):\s*(?P<message>.+)$
DEBUG: structcheck linter took 434.0434ms
DEBUG: warning: errcheck -abspath . returned exit status 2
DEBUG: errcheck hits 0: ^(?P<path>[^:]+):(?P<line>\d+):(?P<col>\d+)\t(?P<message>.*)$
DEBUG: errcheck linter took 440.044ms
DEBUG: warning: go tool vet --shadow ./*.go returned exit status 1
DEBUG: vetshadow hits 0: ^(?P<path>[^\s][^:]+?\.go):(?P<line>\d+):\s*(?P<message>.*)$
DEBUG: vetshadow linter took 445.0445ms
DEBUG: warning: go tool vet ./*.go returned exit status 1
DEBUG: vet hits 0: ^(?P<path>[^\s][^:]+?\.go):(?P<line>\d+):\s*(?P<message>.*)$
DEBUG: vet linter took 492.0492ms
WARNING: warning: deadline exceeded by linter dupl on . (try increasing --deadline)
DEBUG: total elapsed time 5.0015001s

and when run directly:

C:\Users\adsmith\workspace\go\src\github.com\darimart\darimart\utilities>dupl -plumbing -t 50 ./*.go
panic:

Recursive gometalinting

I'm missing something like gometalinter ./.... Instead, I need to run gometalinter on each of my submodules. Am I missing something or is this the way to be?

Support min_confidence flag for golint

golint --help
Usage of golint:
    golint [flags] # runs on package in current directory
    golint [flags] package
    golint [flags] directory
    golint [flags] files... # must be a single package
Flags:
  -min_confidence float
        minimum confidence of a problem to print it (default 0.8)

Question: how to specify an explicit list of linters?

I couldn't find it on the help page, please feel free to close if this is a duplicate. Basically I'm searching for an option to explicitly define linters. So gometalinters should only invoke certain linters. These should be passed via a flag option. Is it possible? An example usage I would like to have (if possible):

gometalinter --enabled-linters="govet,golint" ./...

There is an option called --linter but it only allows to specify a single linter. The option --enable just enables previously disabled linters. I would want probably something which doesn't rely on any kind of config, and if there is any need of config I should pass them via a flag.

Btw, I need this so I can integrate this into vim-go. Currently gometalinter calls all possible linters and because vim-go is blocking by default it's just to slow. I want to have a predefined set of linters which I'm going to add it and a way to pass linters as a configuration to vim.

install errors - golint ?

$  gometalinter --install --update
Installing:
  ineffassign
  gotype
  varcheck
  aligncheck
  gocyclo
  defercheck
  structcheck
  deadcode
  dupl
  gometalinter
  golint
  goimports
  errcheck
->
  go get -u github.com/gordonklaus/ineffassign \
    golang.org/x/tools/cmd/gotype \
    github.com/opennota/check/cmd/varcheck \
    github.com/opennota/check/cmd/aligncheck \
    github.com/alecthomas/gocyclo \
    github.com/opennota/check/cmd/defercheck \
    github.com/opennota/check/cmd/structcheck \
    github.com/remyoudompheng/go-misc/deadcode \
    github.com/mibk/dupl \
    github.com/alecthomas/gometalinter \
    github.com/golang/lint/golint \
    golang.org/x/tools/cmd/goimports \
    github.com/kisielk/errcheck
# cd /Users/elliott/go/src/github.com/golang/lint; git pull --ff-only
From https://github.com/golang/lint
   7b7f436..32a8716  master     -> origin/master
fatal: Not possible to fast-forward, aborting.
package github.com/golang/lint/golint: exit status 128
gometalinter: error: failed to install ineffassign
  gotype
  varcheck
  aligncheck
  gocyclo
  defercheck
  structcheck
  deadcode
  dupl
  gometalinter
  golint
  goimports
  errcheck: exit status 1: exit status 1

using go version go1.5.1 darwin/amd64

Pre-install on Travis?

I'm the primary human responsible for build environment images at Travis CI, and I'm also a happy gometalinter user. I'm considering pre-installing gometalinter & tools on the base image for the Ubuntu Trusty beta, and possibly backporting it to the Ubuntu Precise golang image. Questions include:

  • Is this a bad idea?
  • Is the addition of tagging releases possible, or can/should master always be considered stable?

Related PR to cookbooks that will implement the change: travis-ci/travis-cookbooks#603

Can we not use 'unstable' kingpin...?

github.com/alecthomas/gometalinter (download)
Fetching https://gopkg.in/alecthomas/kingpin.v2-unstable?go-get=1
Parsing meta tags from https://gopkg.in/alecthomas/kingpin.v2-unstable?go-get=1 (status code 200)
get "gopkg.in/alecthomas/kingpin.v2-unstable": found meta tag main.metaImport{Prefix:"gopkg.in/alecthomas/kingpin.v2-unstable", VCS:"git", RepoRoot:"https://gopkg.in/alecthomas/kingpin.v2-unstable"} at https://gopkg.in/alecthomas/kingpin.v2-unstable?go-get=1
gopkg.in/alecthomas/kingpin.v2-unstable (download)
github.com/alecthomas/template (download)
github.com/alecthomas/units (download)
github.com/alecthomas/template/parse
github.com/alecthomas/template
gopkg.in/alecthomas/kingpin.v2-unstable
github.com/alecthomas/gometalinter
# github.com/alecthomas/gometalinter
gopath/src/github.com/alecthomas/gometalinter/main.go:333: undefined: kingpin.FatalIfError
gopath/src/github.com/alecthomas/gometalinter/main.go:416: undefined: kingpin.FatalIfError
gopath/src/github.com/alecthomas/gometalinter/main.go:491: undefined: kingpin.FatalIfError
gopath/src/github.com/alecthomas/gometalinter/main.go:496: undefined: kingpin.FatalIfError

go get of meta linter presently not working due to another change in unstable.

Invalid output for files that cannot be parsed

Given the following file named test.go, containing:

test

Running gometalitnter provides the following output:

test.go:1:1:warning: expected 'package', found 'IDENT' test (golint)
test.go:1:1:warning: expected 'package', found 'IDENT' test (deadcode)
 test.go:1:1:warning: expected 'package', found 'IDENT' test (go-nyet)
2015/05/05 14:4::warning: unused global variable 28 cannot import package . (varcheck)
    test.go:1::warning: unused global variable 1: expected 'package', found 'IDENT' test (varcheck)
    test.go:1::warning: unused global variable 1: expected 'package', found 'IDENT' test (varcheck)
2015/05/05 14:4::error: 28 cannot import package . (defercheck)
    test.go:1::error: 1: expected 'package', found 'IDENT' test (defercheck)
    test.go:1::error: 1: expected 'package', found 'IDENT' test (defercheck)
2015/05/05 14:4::warning: unused struct field 28 cannot import package . (structcheck)
    test.go:1::warning: unused struct field 1: expected 'package', found 'IDENT' test (structcheck)
    test.go:1::warning: unused struct field 1: expected 'package', found 'IDENT' test (structcheck)
test.go:1:1:error: expected 'package', found 'IDENT' test (gotype)
test.go:1::error: 1: expected 'package', found 'IDENT' test (vet)

Similar outputs are given with contents that cannot be parsed, such as:

package main

test

func main() {
}

First of all, some lines contain the current date, instead of the file name, some are appear to be indented.

Also, in the case of a parsing error, I don't think there's a need to run the other tools, since they appear to provide the same error messages.

dupl command line seems wrong

Running gometalinter produces no results for dupl.

When I run with -v I see linting with dupl: dupl -plumbing -threshold {duplthreshold} {path}/*.go (on .)

If I run on the command line dupl -plumbing -threshold 50 ./*.go I see no results.

However, if I run the command dupl -plumbing -threshold 50 . I see two results in different files.

I think the correct dupl command to run is dupl -plumbing -threshold 50 .

Add option to exclude paths when recursing

With official vendoring taking the unfortunate path of ./vendor/ rather than using a hidden (.-prefixed) dir, it would be beneficial to have an option that allows excluding paths from recursion. Perhaps this should default to vendor.

Group output

Hi,

I know you print output now when only you find an issues but maybe at future you can add option (with additional flag) to make output more human readable.
Like group by severity and/or file name, when grouped by name sort by line number etc.

gometalinter fails on empty directory

The other linters work with empty directories, but it looks like gofmt and goimports fail on directories without *.go files. Can these linters not run on directories without *.go files?

< gometalinter .
stat ./*.go: no such file or directory:1::error: file is not gofmted (gofmt)
stat ./*.go: no such file or directory:1::error: file is not goimported (goimports)

gometalinter is very flaky on multipackage projects

When running gometalinter on a bigger project with multiple subpackages, it seems to run on the same package multiple times and ignore other ones.
I guess there is a bug in the go routine spawning.

gometalinter --debug ./... 2>&1 | grep varcheck | grep executing | sort
DEBUG: executing varcheck utils
DEBUG: executing varcheck utils/fe
DEBUG: executing varcheck utils/ggeocode
DEBUG: executing varcheck utils/hash
DEBUG: executing varcheck utils/hash  <<<<<
DEBUG: executing varcheck utils/logger
DEBUG: executing varcheck utils/progress
DEBUG: executing varcheck utils/slugs
DEBUG: executing varcheck utils/stopwatch
DEBUG: executing varcheck utils/validations
gometalinter --debug ./... 2>&1 | grep varcheck | grep executing | sort
DEBUG: executing varcheck utils
DEBUG: executing varcheck utils <<<<<
DEBUG: executing varcheck utils <<<<<
DEBUG: executing varcheck utils/fe
DEBUG: executing varcheck utils/ggeocode
DEBUG: executing varcheck utils/hash
DEBUG: executing varcheck utils/logger
DEBUG: executing varcheck utils/progress
DEBUG: executing varcheck utils/slugs
DEBUG: executing varcheck utils/stopwatch

This causes issues being reported in one run but not on the next.

gometalinter --install --update Fails On Windows

gometalinter --install --update fails on Windows: https://ci.appveyor.com/project/joefitzgerald/gometalinter-linter/build/6

go get -u github.com/alecthomas/gometalinter
gometalinter --install --update
Installing:
  varcheck
  gocyclo
  ineffassign
  gometalinter
  golint
  errcheck
  structcheck
  aligncheck
  deadcode
  dupl
  gotype
  goimports
  defercheck
->
  go get -u github.com/opennota/check/cmd/varcheck \
    github.com/alecthomas/gocyclo \
    github.com/gordonklaus/ineffassign \
    github.com/alecthomas/gometalinter \
    github.com/golang/lint/golint \
    github.com/kisielk/errcheck \
    github.com/opennota/check/cmd/structcheck \
    github.com/opennota/check/cmd/aligncheck \
    github.com/remyoudompheng/go-misc/deadcode \
    github.com/mibk/dupl \
    golang.org/x/tools/cmd/gotype \
    golang.org/x/tools/cmd/goimports \
    github.com/opennota/check/cmd/defercheck
package /: unrecognized import path "/"
gometalinter: error: failed to install varcheck
  gocyclo
  ineffassign
  gometalinter
  golint
  errcheck
  structcheck
  aligncheck
  deadcode
  dupl
  gotype
  goimports
  defercheck: exit status 1: exit status 1

Oddly, installing each manually works:

c:\gopath\bin>go get -u github.com/alecthomas/gometalinter
c:\gopath\bin>go get -u github.com/opennota/check/cmd/varcheck
c:\gopath\bin>go get -u github.com/opennota/check/cmd/defercheck
c:\gopath\bin>go get -u github.com/opennota/check/cmd/structcheck
c:\gopath\bin>go get -u github.com/alecthomas/gocyclo
c:\gopath\bin>go get -u github.com/gordonklaus/ineffassign
c:\gopath\bin>go get -u github.com/golang/lint/golint
c:\gopath\bin>go get -u github.com/kisielk/errcheck
c:\gopath\bin>go get -u github.com/remyoudompheng/go-misc/deadcode
c:\gopath\bin>go get -u github.com/mibk/dupl
c:\gopath\bin>go get -u golang.org/x/tools/cmd/gotype
c:\gopath\bin>go get -u golang.org/x/tools/cmd/goimports
c:\gopath\bin>go get -u github.com/opennota/check/cmd/aligncheck

Does this look like anything obvious? I'd be happy to help you set up Windows CI (e.g. https://github.com/joefitzgerald/gometalinter-linter/blob/master/appveyor.yml).

I wonder if it would be more beneficially to get tools individually, rather than as one large list? This would very much aid in determining the failing tool.

Using gometalinter with CircleCI

Has anyone tried to use gometalinter within a CircleCI job?

This is my circle.yml:

dependencies:
    pre:
        - go get -u github.com/alecthomas/gometalinter
        - gometalinter --install

test:
    override:
        - gometalinter .
        - gometalinter ./cmd/rqlite-cli
        - gometalinter ./command
        - gometalinter ./db
        - gometalinter ./interfaces
        - gometalinter ./log
        - gometalinter ./server
        - go test -timeout 60s -v ./...
        - GORACE="halt_on_error=1" go test -race -timeout 120s -v ./...

The dependencies installation runs successfully:

$ go get -u github.com/alecthomas/gometalinter Exit code: 0
gometalinter --install

Installing errcheck -> go get github.com/alecthomas/errcheck
Installing varcheck -> go get github.com/opennota/check/cmd/varcheck
Installing structcheck -> go get github.com/opennota/check/cmd/structcheck
Installing vet -> go get golang.org/x/tools/cmd/vet
Installing gocyclo -> go get github.com/alecthomas/gocyclo
Installing go-nyet -> go get github.com/barakmich/go-nyet
Installing golint -> go get github.com/golang/lint/golint
Installing gotype -> go get golang.org/x/tools/cmd/gotype
Installing defercheck -> go get github.com/opennota/check/cmd/defercheck
Installing deadcode -> go get github.com/remyoudompheng/go-misc/deadcode 

It starts to fail when using gometalinter:

main.go:26:2:error: could not import github.com/otoolep/rqlite/log (can't find import: github.com/otoolep/rqlite/log) (gotype)
main.go:27:2:error: could not import github.com/otoolep/rqlite/server (can't find import: github.com/otoolep/rqlite/server) (gotype)
main.go:61:3:error: undeclared name: log (gotype)
main.go:64:4:error: undeclared name: log (gotype)
main.go:70:4:error: undeclared name: log (gotype)
main.go:77:2:error: undeclared name: log (gotype)
main.go:82:3:error: undeclared name: log (gotype)
main.go:83:3:error: undeclared name: log (gotype)
main.go:90:3:error: undeclared name: log (gotype)
main.go:97:7:error: undeclared name: server (gotype)
 main.go:27::warning: unused struct field 2: could not import github.com/otoolep/rqlite/server (/home/ubuntu/.go_workspace/src/github.com/otoolep/rqlite/server/server.go:20:2: could not import github.com/otoolep/rqlite/command (/home/ubuntu/.go_workspace/src/github.com/otoolep/rqlite/command/execute_command.go:5:2: could not import github.com/otoolep/rqlite/db (/home/ubuntu/.go_workspace/src/github.com/otoolep/rqlite/db/db.go:9:4: could not import github.com/mattn/go-sqlite3 (/home/ubuntu/.go_workspace/src/github.com/mattn/go-sqlite3/sqlite3_other.go:14:8: could not import C (build.Import failed: cannot find package "C" in any of: (structcheck)

main.go:27::warning: unused global variable 2: could not import github.com/otoolep/rqlite/server (/home/ubuntu/.go_workspace/src/github.com/otoolep/rqlite/server/server.go:20:2: could not import github.com/otoolep/rqlite/command (/home/ubuntu/.go_workspace/src/github.com/otoolep/rqlite/command/execute_command.go:5:2: could not import github.com/otoolep/rqlite/db (/home/ubuntu/.go_workspace/src/github.com/otoolep/rqlite/db/db.go:9:4: could not import github.com/mattn/go-sqlite3 (/home/ubuntu/.go_workspace/src/github.com/mattn/go-sqlite3/backup.go:12:8: could not import C (build.Import failed: cannot find package "C" in any of: (varcheck) gometalinter . returned exit code 1

Seems like gometalinter is not executed within a GOPATH. Does anyone have an idea?

You can find the full build here: https://circleci.com/gh/oscillatingworks/rqlite/3

Add flag for exiting with status 0 even in the presence of errors

When running gometalinter as part of a test suite I need to detect if the command ran successfully or not. Currently this is a bit problematic since gometalinter exits with a non-zero exit code in the presence of errors. That's usually fine, but for my use case I would like that to be treated as success, since I will be parsing the output anyway and I would only consider it an error if the command did not run successfully.

Thus my suggestion is to add a flag which, if given, will cause gometalinter to exit with status code 0 even if errors are reported, as long as there were no problems running the linters. I am happy to submit a PR implementing this if it is something you find useful.

vendor

gometalinter will support the import package in vendor feature in the future?

Output is not consistent

If I run the same command multiple time on my package github.com/pierrre/imageserver, I get:

➜  imageserver git:(feature/native) gometalinter ./...
/home/pierre/.gimme/versions/go1.5.1.src/src/image/gif/reader.go:198:10:warning: error return value not checked (defer lzwr.Close()) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/gif/writer.go:258:4:warning: error return value not checked (lzww.Close()) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/gif/writer.go:265:5:warning: error return value not checked (lzww.Close()) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/gif/writer.go:270:2:warning: error return value not checked (lzww.Close()) (errcheck)
➜  imageserver git:(feature/native) gometalinter ./...
examples/advanced/advanced_test.go:14::warning: cyclomatic complexity 15 of function TestServer() is high (> 10) (gocyclo)
graphicsmagick/graphicsmagick.go:152::warning: cyclomatic complexity 19 of function (*Server).buildArgumentsResize() is high (> 10) (gocyclo)
image/nfntresize/nfntresize_test.go:14::warning: cyclomatic complexity 11 of function TestProcessor() is high (> 10) (gocyclo)
graphicsmagick/graphicsmagick.go:83::warning: cyclomatic complexity 12 of function (*Server).process() is high (> 10) (gocyclo)
./image_benchmark_test.go:54::warning: duplicate of ./image_benchmark_test.go:88-104 (dupl)
./image_benchmark_test.go:88::warning: duplicate of ./image_benchmark_test.go:54-70 (dupl)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/jpeg/reader.go:107:6:warning: struct decoder could have size 13288 (currently 13296) (aligncheck)
_test/benchmark.go:22::error: declaration of im shadows declaration at _test/benchmark.go:11: (vetshadow)
nfntresize/validate.go:19::error: declaration of params shadows declaration at nfntresize/validate.go:17: (vetshadow)
validate.go:19::error: declaration of params shadows declaration at validate.go:17: (vetshadow)
cache/_test/benchmark.go:22::error: declaration of im shadows declaration at cache/_test/benchmark.go:11: (vetshadow)
image/nfntresize/validate.go:19::error: declaration of params shadows declaration at image/nfntresize/validate.go:17: (vetshadow)
➜  imageserver git:(feature/native) gometalinter ./...
./image_benchmark_test.go:54::warning: duplicate of ./image_benchmark_test.go:88-104 (dupl)
./image_benchmark_test.go:88::warning: duplicate of ./image_benchmark_test.go:54-70 (dupl)
_test/benchmark.go:22::error: declaration of im shadows declaration at _test/benchmark.go:11: (vetshadow)
validate.go:19::error: declaration of params shadows declaration at validate.go:17: (vetshadow)
nfntresize/validate.go:19::error: declaration of params shadows declaration at nfntresize/validate.go:17: (vetshadow)
cache/_test/benchmark.go:22::error: declaration of im shadows declaration at cache/_test/benchmark.go:11: (vetshadow)
image/nfntresize/validate.go:19::error: declaration of params shadows declaration at image/nfntresize/validate.go:17: (vetshadow)
➜  imageserver git:(feature/native) gometalinter ./...
cache/cache.go:31:2:warning: error return value not checked (c.Cache.Set(key, image, params)) (errcheck)
cache/cache.go:45:3:warning: error return value not checked (a.Cache.Set(key, image, params)) (errcheck)
cache/server.go:75:3:warning: error return value not checked (io.WriteString(h, params.String())) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/png/reader.go:144:2:warning: error return value not checked (d.crc.Write(d.tmp[:13])) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/png/reader.go:229:2:warning: error return value not checked (d.crc.Write(d.tmp[:n])) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/png/reader.go:262:2:warning: error return value not checked (d.crc.Write(d.tmp[:n])) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/png/reader.go:308:3:warning: error return value not checked (d.crc.Write(d.tmp[4:8])) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/png/reader.go:314:2:warning: error return value not checked (d.crc.Write(p[:n])) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/png/reader.go:325:8:warning: error return value not checked (defer r.Close()) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/png/reader.go:695:2:warning: error return value not checked (d.crc.Write(d.tmp[4:8])) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/png/reader.go:737:3:warning: error return value not checked (d.crc.Write(ignored[:n])) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/png/writer.go:97:2:warning: error return value not checked (crc.Write(e.header[4:8])) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/png/writer.go:98:2:warning: error return value not checked (crc.Write(b)) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/png/writer.go:281:8:warning: error return value not checked (defer zw.Close()) (errcheck)
httpsource/httpsource.go:35:8:warning: error return value not checked (defer response.Body.Close()) (errcheck)
params.go:134:2:warning: error return value not checked (buf.WriteString("map[")) (errcheck)
params.go:137:4:warning: error return value not checked (buf.WriteString(" ")) (errcheck)
params.go:139:3:warning: error return value not checked (buf.WriteString(key)) (errcheck)
params.go:140:3:warning: error return value not checked (buf.WriteString(":")) (errcheck)
params.go:141:3:warning: error return value not checked (buf.WriteString(fmt.Sprint(params[key]))) (errcheck)
params.go:143:2:warning: error return value not checked (buf.WriteString("]")) (errcheck)
graphicsmagick/graphicsmagick.go:121:8:warning: error return value not checked (defer os.RemoveAll(tempDir)) (errcheck)
graphicsmagick/graphicsmagick.go:341:3:warning: error return value not checked (cmd.Process.Kill()) (errcheck)
http/handler.go:141:3:warning: error return value not checked (io.WriteString(h, params.String())) (errcheck)
cache/redis/redis.go:39:8:warning: error return value not checked (defer conn.Close()) (errcheck)
cache/redis/redis.go:65:8:warning: error return value not checked (defer conn.Close()) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/gif/reader.go:198:10:warning: error return value not checked (defer lzwr.Close()) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/gif/writer.go:258:4:warning: error return value not checked (lzww.Close()) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/gif/writer.go:265:5:warning: error return value not checked (lzww.Close()) (errcheck)
/home/pierre/.gimme/versions/go1.5.1.src/src/image/gif/writer.go:270:2:warning: error return value not checked (lzww.Close()) (errcheck)
graphicsmagick/graphicsmagick.go:152::warning: cyclomatic complexity 19 of function (*Server).buildArgumentsResize() is high (> 10) (gocyclo)
graphicsmagick/graphicsmagick.go:83::warning: cyclomatic complexity 12 of function (*Server).process() is high (> 10) (gocyclo)
./image_benchmark_test.go:54::warning: duplicate of ./image_benchmark_test.go:88-104 (dupl)
./image_benchmark_test.go:88::warning: duplicate of ./image_benchmark_test.go:54-70 (dupl)
image/nfntresize/nfntresize_test.go:14::warning: cyclomatic complexity 11 of function TestProcessor() is high (> 10) (gocyclo)
examples/advanced/advanced_test.go:14::warning: cyclomatic complexity 15 of function TestServer() is high (> 10) (gocyclo)

ineffassign not picked up

On a private repository, running gometalinter --debug . produces

...
DEBUG: linting with ineffassign: ineffassign -n {path} (on .)
...
DEBUG: executing ineffassign -n .
...
DEBUG: warning: ineffassign -n . returned exit status 1
DEBUG: ineffassign hits 0: ^(?P<path>[^:]+):(?P<line>\d+):(?P<col>\d+)\s+(?P<message>.*)$
DEBUG: ineffassign linter took 94.225049ms
...

When I run the command by itself I see the following:

< ineffassign -n .
/Users/jack/.go/src/github.com/signalfuse/myrepo/cmd/ingest/packed.go:230:2: i assigned and not used
/Users/jack/.go/src/github.com/signalfuse/myrepo/cmd/ingest/datum/packed_test.go:108:2: b assigned and not used

exclude flag still exits with non-zero status

I'm using the --exclude flag to ignore some issues that I don't care about, like
warning: error return value not checked (defer body.Close()) (errcheck)

However, gometalinter still exits with a non-zero status when an excluded issue is encountered. The workaround is to pipe the output to grep and search for the words 'error' or 'warning', but this is not ideal. It would be better for gometalinter to return 0 when it doesn't print any issues.

Gometalinter improvements or terrible ideas

Hi,

I wrote https://github.com/cep21/goverify as part of my company's build process and would like to just replace it with gometalinter and think I could with a few improvements. It is more macro based (https://github.com/cep21/goverify/blob/master/macros.go) with a goverify.json file configuring runs (https://github.com/signalfx/metricproxy/blob/master/goverify.json) where people run goverify -fix before a commit and the build script itself runs goverify and I can simply check the return code for failure. Do you think the following improvements would belong inside gometalinter or do they not fully fit with gometalinter and I should keep goverify?

  1. Add support for gofmt, goimports, and minimum code coverage .
  2. Add a -fix flag for auto correcting format and imports
  3. Add support for a gometalinter.json file that, if exists, specifies default arguments for gometalinter
  4. Add support for ignoring directories or files when doing a ./... recursive directory argument
  5. Add support for ignoring error messages/error code for messages that match a set of regexes. For example, allow me to ignore golint errors that match regex ["GetID"].

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.