From f0a10a00c4ff012f328442fdd27426ca12ed03df Mon Sep 17 00:00:00 2001 From: okhowang <3352585+okhowang@users.noreply.github.com> Date: Sat, 8 Jan 2022 20:46:05 +0800 Subject: [PATCH] checkers: add fixable for commentFormatting (#1190) (#1191) 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 c849bdedd..f330b723a 100644 --- a/checkers/commentFormatting_checker.go +++ b/checkers/commentFormatting_checker.go @@ -111,5 +111,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") }