Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comment-spacings exceptions do not work if there's no colon after the exception #980

Closed
gfariasalves-ionos opened this issue Apr 15, 2024 · 2 comments · Fixed by #981
Closed

Comments

@gfariasalves-ionos
Copy link
Contributor

gfariasalves-ionos commented Apr 15, 2024

Describe the bug
Some projects like Kubebuilder have markers that do not follow the pattern //name:, example: //+optional. Due to

r.allowList = append(r.allowList, `//`+allow+`:`)
having a colon added at the end they don't work.

To Reproduce
Steps to reproduce the behavior:

  1. Write this config file:
[rule.comment-spacings]
  arguments = ["+optional"]
  1. Write this test file:
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
@chavacava
Copy link
Collaborator

Hi @gfariasalves-ionos, thanks for reporting the issue.
As you already pointed out, removing the : from line 34 of the rule will fix the problem.
(PR are welcome)

@gfariasalves-ionos
Copy link
Contributor Author

I'll create one :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants