alecthomas / gometalinter

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The order of CLI flags aren't respected in combination with the config

Dynom opened this issue · comments

For introducing gometalinter to a project, I want to run gometalinter --errors. So that it only report errors on CI and use a version with warnings locally.

Unfortunately when I specify (in .gometalinter.json) Errors: false, I can't override it as a flag. In contrary to what the documentation specifies.

So a .gometalinter.json like:

{
  "EnableAll": false,
  "Errors": false,
  "Enable": [
    "deadcode",
    "dupl",
    "..."
  ]
}

Still reports warnings when run like:

$ gometalinter --errors ./...

Inspired by the following:

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.

I've also tried:

$ gometalinter --config=.gometalinter.json --errors ./...

Version: gometalinter version 2.0.12 built from 102ac98 on 2018-12-16T00:58:32Z

I think I spotted why it doesn't work as advertised.

The default config is loaded as an "Action" of sorts: https://github.com/alecthomas/gometalinter/blob/master/main.go#L200. But that line adds it to an action queue, it doesn't actually invoke the "action". The line after it loads the defaults.

I'm not sure when the "Actions" are actually executed (with Parse()?), but it seems to be later, which means the defaults become last.