Skip to content

Commit

Permalink
passes/commentignore: Allow leading space (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
armsnyder authored Feb 4, 2022
1 parent 1263d1c commit f1c56bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions passes/AT001/testdata/src/a/comment_ignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@ import (
func fcommentignore() {
_ = r.TestCase{} //lintignore:AT001

_ = r.TestCase{} // lintignore:AT001

//lintignore:AT001
_ = r.TestCase{}

// lintignore:AT001
_ = r.TestCase{}

//lintignore:AT001,AT002
_ = r.TestCase{}

_ = r.TestCase{} //lintignore:AT001 // extra comment

_ = r.TestCase{} // lintignore:AT001 // extra comment

// lintignore:AT001 // extra comment
_ = r.TestCase{}

//lintignore:AT001 // extra comment
_ = r.TestCase{}

Expand All @@ -30,6 +40,11 @@ func fcommentignore() {
// extra comment
_ = r.TestCase{}

// extra comment
// lintignore:AT001
// extra comment
_ = r.TestCase{}

//lintignore:AT001
// extra comment
_ = r.TestCase{}
Expand Down
2 changes: 1 addition & 1 deletion passes/commentignore/ignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
}

// Remove // comment prefix
commentText := strings.TrimPrefix(comment.Text, "//")
commentText := strings.TrimLeft(strings.TrimPrefix(comment.Text, "//"), " ")

if strings.HasPrefix(commentText, commentIgnorePrefix) {
commentIgnore := strings.TrimPrefix(commentText, commentIgnorePrefix)
Expand Down

0 comments on commit f1c56bf

Please sign in to comment.