diff --git a/.gitignore b/.gitignore index 57149669..896f0c3e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ /tools/goreleaser /tools/node_modules /tools/svg-term +/vendor/ /.vscode/ *.test .DS_Store diff --git a/go.mod b/go.mod index 451afa1d..9f02c74f 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( github.com/spf13/viper v1.6.1 github.com/stretchr/testify v1.5.1 github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2 - github.com/tetafro/godot v0.3.7 + github.com/tetafro/godot v0.4.2 github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e github.com/tommy-muehle/go-mnd v1.3.1-0.20200224220436-e6f9a994e8fa github.com/ultraware/funlen v0.0.2 diff --git a/go.sum b/go.sum index 56187cdb..b211f5da 100644 --- a/go.sum +++ b/go.sum @@ -312,8 +312,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.3.7 h1:+mecr7RKrUKB5UQ1gwqEMn13sDKTyDR8KNIquB9mm+8= -github.com/tetafro/godot v0.3.7/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0= +github.com/tetafro/godot v0.4.2 h1:Dib7un+rYJFUi8vN0Bk6EHheKy6fv6ZzFURHw75g6m8= +github.com/tetafro/godot v0.4.2/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/golinters/godot.go b/pkg/golinters/godot.go index 7e5b233a..5139713c 100644 --- a/pkg/golinters/godot.go +++ b/pkg/golinters/godot.go @@ -31,7 +31,7 @@ func NewGodot() *goanalysis.Linter { settings := godot.Settings{CheckAll: cfg.CheckAll} analyzer.Run = func(pass *analysis.Pass) (interface{}, error) { - var issues []godot.Message + var issues []godot.Issue for _, file := range pass.Files { issues = append(issues, godot.Run(file, pass.Fset, settings)...) } @@ -46,6 +46,9 @@ func NewGodot() *goanalysis.Linter { Pos: i.Pos, Text: i.Message, FromLinter: godotName, + Replacement: &result.Replacement{ + NewLines: []string{i.Replacement}, + }, } res[k] = goanalysis.NewIssue(&issue, pass) diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index 1ec78de2..634cdc28 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -263,6 +263,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { WithURL("https://github.com/ryancurrah/gomodguard"), linter.NewConfig(golinters.NewGodot()). WithPresets(linter.PresetStyle). + WithAutoFix(). WithURL("https://github.com/tetafro/godot"), linter.NewConfig(golinters.NewTestpackage(testpackageCfg)). WithPresets(linter.PresetStyle). diff --git a/test/testdata/fix/in/godot.go b/test/testdata/fix/in/godot.go new file mode 100644 index 00000000..01fc19e8 --- /dev/null +++ b/test/testdata/fix/in/godot.go @@ -0,0 +1,12 @@ +//args: -Egodot +package p + +/* +This comment won't be checked in default mode +*/ + +// This comment will be fixed +func godot(a, b int) int { + // Nothing to do here + return a + b +} diff --git a/test/testdata/fix/out/godot.go b/test/testdata/fix/out/godot.go new file mode 100644 index 00000000..5d78681b --- /dev/null +++ b/test/testdata/fix/out/godot.go @@ -0,0 +1,12 @@ +//args: -Egodot +package p + +/* +This comment won't be checked in default mode +*/ + +// This comment will be fixed. +func godot(a, b int) int { + // Nothing to do here + return a + b +}