mirror of
https://github.com/mgechev/revive.git
synced 2025-01-08 03:13:27 +02:00
remove colon suffix in comment-spacings
rule (#981)
This commit is contained in:
parent
f88f60da20
commit
0a77458f89
@ -183,14 +183,15 @@ _Description_: Spots comments of the form:
|
||||
_Configuration_: ([]string) list of exceptions. For example, to accept comments of the form
|
||||
```go
|
||||
//mypragma: activate something
|
||||
//+optional
|
||||
```
|
||||
You need to add `"mypragma"` in the configuration
|
||||
You need to add both `"mypragma:"` and `"+optional"` in the configuration
|
||||
|
||||
Example:
|
||||
|
||||
```toml
|
||||
[rule.comment-spacings]
|
||||
arguments =["mypragma","otherpragma"]
|
||||
arguments =["mypragma:", "+optional"]
|
||||
```
|
||||
## confusing-naming
|
||||
|
||||
|
@ -31,7 +31,7 @@ func (r *CommentSpacingsRule) configure(arguments lint.Arguments) {
|
||||
if !ok {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ import (
|
||||
|
||||
func TestCommentSpacings(t *testing.T) {
|
||||
testRule(t, "comment-spacings", &rule.CommentSpacingsRule{}, &lint.RuleConfig{
|
||||
Arguments: []any{"myOwnDirective"}},
|
||||
Arguments: []any{"myOwnDirective:", "+optional"}},
|
||||
)
|
||||
}
|
||||
|
5
testdata/comment-spacings.go
vendored
5
testdata/comment-spacings.go
vendored
@ -42,3 +42,8 @@ Should be valid
|
||||
|
||||
//nolint:staticcheck // nolint should be in the default list of acceptable comments.
|
||||
var b string
|
||||
|
||||
type c struct {
|
||||
//+optional
|
||||
d *int `json:"d,omitempty"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user