From 8c2cd3331558b8ca1c1315525b8ffab878d41dd2 Mon Sep 17 00:00:00 2001 From: Felipe David Date: Fri, 17 Feb 2023 17:03:11 -0300 Subject: [PATCH] fixing comment spacings (#789) * fixing comments spacing * Updating comment spacing test cases * adds test cases for multiline comments --------- Co-authored-by: chavacava --- rule/comment-spacings.go | 8 +++++++- testdata/comment-spacings.go | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/rule/comment-spacings.go b/rule/comment-spacings.go index abe2ad7..e0898c3 100644 --- a/rule/comment-spacings.go +++ b/rule/comment-spacings.go @@ -47,7 +47,13 @@ func (r *CommentSpacingsRule) Apply(file *lint.File, args lint.Arguments) []lint continue // nothing to do } - isOK := commentLine[2] == ' ' + isMultiLineComment := commentLine[1] == '*' + isOK := commentLine[2] == '\n' + if isMultiLineComment && isOK { + continue + } + + isOK = (commentLine[2] == ' ') || (commentLine[2] == '\t') if isOK { continue } diff --git a/testdata/comment-spacings.go b/testdata/comment-spacings.go index a5465fa..5b1d281 100644 --- a/testdata/comment-spacings.go +++ b/testdata/comment-spacings.go @@ -22,3 +22,20 @@ type hello struct { var a string //myOwnDirective: do something + +/* +Should be valid +*/ + +// Tabs between comment delimeter and comment text should be fine + +// MATCH:34 /no space between comment delimiter and comment text/ + +/*Not valid + */ + +/* valid + */ + +/* valid + */