Skip to content

Commit

Permalink
fixing comment spacings (#789)
Browse files Browse the repository at this point in the history
* fixing comments spacing

* Updating comment spacing test cases

* adds test cases for multiline comments

---------

Co-authored-by: chavacava <salvadorcavadini+github@gmail.com>
  • Loading branch information
felipedavid and chavacava authored Feb 17, 2023
1 parent 4981346 commit 8c2cd33
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rule/comment-spacings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
17 changes: 17 additions & 0 deletions testdata/comment-spacings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

0 comments on commit 8c2cd33

Please sign in to comment.