diff --git a/.golangci.example.yml b/.golangci.example.yml index 5fd1432e9dad..d8ce4b750619 100644 --- a/.golangci.example.yml +++ b/.golangci.example.yml @@ -155,8 +155,10 @@ linters-settings: # minimal code complexity to report, 30 by default (but we recommend 10-20) min-complexity: 10 godot: - # check all top-level comments, not only declarations - check-all: false + # comments to be checked: `declarations`, `toplevel`, or `all` + scope: declarations + # check that each sentence starts with a capital letter + capital: false godox: # report any comments starting with keywords, this is useful for TODO or FIXME comments that # might be left in the code accidentally and should be resolved before merging diff --git a/go.mod b/go.mod index 8010be910e21..288c0cabc37c 100644 --- a/go.mod +++ b/go.mod @@ -55,7 +55,7 @@ require ( github.com/ssgreg/nlreturn/v2 v2.1.0 github.com/stretchr/testify v1.6.1 github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2 - github.com/tetafro/godot v0.4.9 + github.com/tetafro/godot v1.3.0 github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e github.com/tomarrell/wrapcheck v0.0.0-20200807122107-df9e8bcb914d github.com/tommy-muehle/go-mnd v1.3.1-0.20200224220436-e6f9a994e8fa diff --git a/go.sum b/go.sum index 59fc55aa82c0..a8353c6caf54 100644 --- a/go.sum +++ b/go.sum @@ -72,6 +72,7 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-sql-driver/mysql v1.4.0 h1:7LxgVwFb2hIQtMm87NdgAVfXjnt4OePseqT1tKx+opk= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-toolsmith/astcast v1.0.0 h1:JojxlmI6STnFVG9yOImLeGREv8W2ocNUM+iOhR6jE7g= @@ -201,6 +202,7 @@ github.com/jingyugao/rowserrcheck v0.0.0-20191204022205-72ab7603b68a/go.mod h1:x github.com/jirfag/go-printf-func-name v0.0.0-20191110105641-45db9963cdd3 h1:jNYPNLe3d8smommaoQlK7LOA5ESyUJJ+Wf79ZtA7Vp4= github.com/jirfag/go-printf-func-name v0.0.0-20191110105641-45db9963cdd3/go.mod h1:HEWGJkRDzjJY2sqdDwxccsGicWEf9BQOZsq2tV+xzM0= github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= +github.com/jmoiron/sqlx v1.2.1-0.20190826204134-d7d95172beb5 h1:lrdPtrORjGv1HbbEvKWDUAy97mPpFm4B8hp77tcCUJY= github.com/jmoiron/sqlx v1.2.1-0.20190826204134-d7d95172beb5/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -240,6 +242,7 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/4= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -378,8 +381,8 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2 h1:Xr9gkxfOP0KQWXKNqmwe8vEeSUiUj4Rlee9CMVX2ZUQ= github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM= -github.com/tetafro/godot v0.4.9 h1:dSOiuasshpevY73eeI3+zaqFnXSBKJ3mvxbyhh54VRo= -github.com/tetafro/godot v0.4.9/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0= +github.com/tetafro/godot v1.3.0 h1:rKXb6aAz2AnwS98jYlU3snCFFXnIInQdaGiftNwpj+k= +github.com/tetafro/godot v1.3.0/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0= github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e h1:RumXZ56IrCj4CL+g1b9OL/oH0QnsF976bC8xQFYUD5Q= github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= diff --git a/pkg/config/config.go b/pkg/config/config.go index 5b73a36de349..d17ec3589ea5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -334,6 +334,10 @@ type WSLSettings struct { } type GodotSettings struct { + Scope string `mapstructure:"scope"` + Capital bool `mapstructure:"capital"` + + // Deprecated: use `Scope` instead CheckAll bool `mapstructure:"check-all"` } diff --git a/pkg/golinters/godot.go b/pkg/golinters/godot.go index 5139713c4afe..e752634297b1 100644 --- a/pkg/golinters/godot.go +++ b/pkg/golinters/godot.go @@ -28,12 +28,29 @@ func NewGodot() *goanalysis.Linter { nil, ).WithContextSetter(func(lintCtx *linter.Context) { cfg := lintCtx.Cfg.LintersSettings.Godot - settings := godot.Settings{CheckAll: cfg.CheckAll} + settings := godot.Settings{ + Scope: godot.Scope(cfg.Scope), + Period: true, + Capital: cfg.Capital, + } + + // Convert deprecated setting + if cfg.CheckAll { // nolint: staticcheck + settings.Scope = godot.TopLevelScope + } + + if settings.Scope == "" { + settings.Scope = godot.DeclScope + } analyzer.Run = func(pass *analysis.Pass) (interface{}, error) { var issues []godot.Issue for _, file := range pass.Files { - issues = append(issues, godot.Run(file, pass.Fset, settings)...) + iss, err := godot.Run(file, pass.Fset, settings) + if err != nil { + return nil, err + } + issues = append(issues, iss...) } if len(issues) == 0 { diff --git a/test/testdata/godot.go b/test/testdata/godot.go index 2412a0482d73..819ce941c72f 100644 --- a/test/testdata/godot.go +++ b/test/testdata/godot.go @@ -1,7 +1,7 @@ //args: -Egodot package testdata -// Godot checks top-level comments // ERROR "Top level comment should end in a period" +// Godot checks top-level comments // ERROR "Comment should end in a period" func Godot() { // nothing to do here }