From dc12c8507ddbed68eb9eeff9f706a50f2efb414b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?okhowang=28=E7=8E=8B=E6=B2=9B=E6=96=87=29?= Date: Fri, 7 Jan 2022 15:03:54 +0800 Subject: [PATCH] checkers: add fixable for commentFormatting (#1190) Fixes #1190 --- checkers/commentFormatting_checker.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/checkers/commentFormatting_checker.go b/checkers/commentFormatting_checker.go index 74eff3b09..5b282365a 100644 --- a/checkers/commentFormatting_checker.go +++ b/checkers/commentFormatting_checker.go @@ -77,5 +77,9 @@ func (c *commentFormattingChecker) specialChar(r rune) bool { } func (c *commentFormattingChecker) warn(comment *ast.Comment) { - c.ctx.Warn(comment, "put a space between `//` and comment text") + c.ctx.WarnFixable(comment, linter.QuickFix{ + From: comment.Pos(), + To: comment.End(), + Replacement: []byte(strings.Replace(comment.Text, "//", "// ", 1)), + }, "put a space between `//` and comment text") }