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:
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
|
_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
|
||||||
|
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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"}},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
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.
|
//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"`
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user