Repository: mgechev/revive (go)

Issue:
comment-spacings exceptions do not work if there's no colon after the exception
**Describe the bug**
Some projects like Kubebuilder have markers that do not follow the pattern `//name:`, example: `//+optional`. Due to https://github.com/mgechev/revive/blob/f88f60da20b2cdc9db2ad6ce5978da32531b0cda/rule/comment-spacings.go#L34 having a colon added at the end they don't work.

**To Reproduce**
Steps to reproduce the behavior:
1.  Write this config file:
```toml
[rule.comment-spacings]
  arguments = ["+optional"]
```

1. Write this test file:
```go
package main

import "fmt"

// example is an example struct
//+optional
type example struct {
	a int
}

func main() {
	a := example{a: 1}
	fmt.Println(a.a)
}
```

**Expected behavior**
I don't get an error

**Logs**
I get an error (logs from golangci-lint but the idea is the same):
```
comment-spacings: no space between comment delimiter and comment text (revive)
        //+optional
        ^
```

**Desktop (please complete the following information):**
 - OS: OpenSUSE Tumbleweed
 - Version of Go: 1.22


Pull request:
Remove added colon in `comment-spacings` rule
<!-- ### IMPORTANT ### -->
<!-- Please do not create a Pull Request without creating an issue first.** -->
<!-- If you're fixing a typo or improving the documentation, you may not have to open an issue. -->

<!-- ### CHECKLIST ### -->
**Please, describe in details what's your motivation for this PR:**

 Some projects like Kubebuilder have markers that do not follow the pattern //name:, e.g.: //+optional. Due to a colon added at the end of the values when parsing the arguments, revive complains about comments starting with the marker even if one adds it as an exception.

**Did you add tests?**

The current tests are still valid with the changes.

**Does your code follow the coding style of the rest of the repository?**

Yes.

<!-- Does the Travis build passes? -->

<!-- ### FOOTER (OPTIONAL) ### -->
<!-- If you're closing an issue, add "Closes #XXXX" in your comment. This way, the PR will be linked to the issue automatically. -->
Closes #980 

Patch:
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)
 		}
 	}
 }


Test patch:
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"`
+}