godot: add autofix mode
This commit is contained in:
parent
09df97a5bf
commit
7c2871c596
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,6 +11,7 @@
|
||||
/tools/goreleaser
|
||||
/tools/node_modules
|
||||
/tools/svg-term
|
||||
/vendor/
|
||||
/.vscode/
|
||||
*.test
|
||||
.DS_Store
|
||||
|
2
go.mod
2
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
|
||||
|
4
go.sum
4
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=
|
||||
|
@ -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)
|
||||
|
@ -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).
|
||||
|
12
test/testdata/fix/in/godot.go
vendored
Normal file
12
test/testdata/fix/in/godot.go
vendored
Normal file
@ -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
|
||||
}
|
12
test/testdata/fix/out/godot.go
vendored
Normal file
12
test/testdata/fix/out/godot.go
vendored
Normal file
@ -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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user