Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't add whitespaceto //NOSONAR comments #268

Merged
merged 1 commit into from Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion format/format.go
Expand Up @@ -305,10 +305,11 @@ func (f *fumpter) lineEnd(line int) token.Pos {
// //sys(nb)? | syscall function wrapper prototypes
// //nolint | nolint directive for golangci
// //noinspection | noinspection directive for GoLand and friends
// //NOSONAR | NOSONAR directive for SonarQube
//
// Note that the "some-words:" matching expects a letter afterward, such as
// "go:generate", to prevent matching false positives like "https://site".
var rxCommentDirective = regexp.MustCompile(`^([a-z-]+:[a-z]+|line\b|export\b|extern\b|sys(nb)?\b|no(lint|inspection)\b)`)
var rxCommentDirective = regexp.MustCompile(`^([a-z-]+:[a-z]+|line\b|export\b|extern\b|sys(nb)?\b|no(lint|inspection)\b)|NOSONAR\b`)

func (f *fumpter) applyPre(c *astutil.Cursor) {
f.splitLongLine(c)
Expand Down
8 changes: 8 additions & 0 deletions testdata/script/comment-spaced.txtar
Expand Up @@ -24,6 +24,10 @@ package p

//nolint:somelinter // explanation

//NOSONAR

//NOSONAR // explanation

//noinspection ALL

//noinspection foo,bar
Expand Down Expand Up @@ -87,6 +91,10 @@ package p

//nolint:somelinter // explanation

//NOSONAR

//NOSONAR // explanation

//noinspection ALL

//noinspection foo,bar
Expand Down