From 0a77458f8945af297c05fd051c2c20e78137e32b Mon Sep 17 00:00:00 2001 From: Gustavo Alves <112630064+gfariasalves-ionos@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:39:59 +0200 Subject: [PATCH] remove colon suffix in `comment-spacings` rule (#981) --- RULES_DESCRIPTIONS.md | 5 +++-- rule/comment-spacings.go | 2 +- test/comment-spacings_test.go | 2 +- testdata/comment-spacings.go | 5 +++++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/RULES_DESCRIPTIONS.md b/RULES_DESCRIPTIONS.md index 8657524..057a57d 100644 --- a/RULES_DESCRIPTIONS.md +++ b/RULES_DESCRIPTIONS.md @@ -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 diff --git a/rule/comment-spacings.go b/rule/comment-spacings.go index 2b8240c..0a29b96 100644 --- a/rule/comment-spacings.go +++ b/rule/comment-spacings.go @@ -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) } } } diff --git a/test/comment-spacings_test.go b/test/comment-spacings_test.go index 9a430b0..e7abeb7 100644 --- a/test/comment-spacings_test.go +++ b/test/comment-spacings_test.go @@ -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"}}, ) } diff --git a/testdata/comment-spacings.go b/testdata/comment-spacings.go index 6d94137..92c832c 100644 --- a/testdata/comment-spacings.go +++ b/testdata/comment-spacings.go @@ -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"` +}