1
0
mirror of https://github.com/mgechev/revive.git synced 2025-01-24 03:47:45 +02:00

remove colon suffix in comment-spacings rule (#981)

This commit is contained in:
Gustavo Alves 2024-04-19 16:39:59 +02:00 committed by GitHub
parent f88f60da20
commit 0a77458f89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 4 deletions

View File

@ -183,14 +183,15 @@ _Description_: Spots comments of the form:
_Configuration_: ([]string) list of exceptions. For example, to accept comments of the form _Configuration_: ([]string) list of exceptions. For example, to accept comments of the form
```go ```go
//mypragma: activate something //mypragma: activate something
//+optional
``` ```
You need to add `"mypragma"` in the configuration You need to add both `"mypragma:"` and `"+optional"` in the configuration
Example: Example:
```toml ```toml
[rule.comment-spacings] [rule.comment-spacings]
arguments =["mypragma","otherpragma"] arguments =["mypragma:", "+optional"]
``` ```
## confusing-naming ## confusing-naming

View File

@ -31,7 +31,7 @@ func (r *CommentSpacingsRule) configure(arguments lint.Arguments) {
if !ok { if !ok {
panic(fmt.Sprintf("invalid argument %v for %s; expected string but got %T", arg, r.Name(), arg)) panic(fmt.Sprintf("invalid argument %v for %s; expected string but got %T", arg, r.Name(), arg))
} }
r.allowList = append(r.allowList, `//`+allow+`:`) r.allowList = append(r.allowList, `//`+allow)
} }
} }
} }

View File

@ -9,6 +9,6 @@ import (
func TestCommentSpacings(t *testing.T) { func TestCommentSpacings(t *testing.T) {
testRule(t, "comment-spacings", &rule.CommentSpacingsRule{}, &lint.RuleConfig{ testRule(t, "comment-spacings", &rule.CommentSpacingsRule{}, &lint.RuleConfig{
Arguments: []any{"myOwnDirective"}}, Arguments: []any{"myOwnDirective:", "+optional"}},
) )
} }

View File

@ -42,3 +42,8 @@ Should be valid
//nolint:staticcheck // nolint should be in the default list of acceptable comments. //nolint:staticcheck // nolint should be in the default list of acceptable comments.
var b string var b string
type c struct {
//+optional
d *int `json:"d,omitempty"`
}