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 false positives for nolint directives #808

Closed
abemedia opened this issue Mar 20, 2023 · 4 comments · Fixed by #986
Closed

comment-spacings false positives for nolint directives #808

abemedia opened this issue Mar 20, 2023 · 4 comments · Fixed by #986
Assignees
Labels

Comments

@abemedia
Copy link

Describe the bug
I'm using revive with golangci-lint and since the latest update I'm getting errors like this:

api/common/validate/validate.go:15:1: comment-spacings: no space between comment delimiter and comment text (revive)
//nolint:gochecknoglobals

I've updated the config to contain nolint in the comment-spacings arguments to make it go away but it's odd as this was not happening before.

To Reproduce
Steps to reproduce the behavior:

  1. I updated golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
  1. I run it with the following flags & configuration file:
golangci-lint run
linters:
  disable-all: true
  enable:
    - revive
linters-settings:
  revive:
    rules:
      - name: comment-spacings
        disabled: false

Desktop (please complete the following information):

  • OS: Ubuntu 22.04.2 LTS
  • go version go1.20.2 linux/amd64
@chavacava
Copy link
Collaborator

Hi @abemedia, thanks for filling the issue.

My understanding of the issue is you ask for nolint be part of the default accepted directives (alongside with go and revive). Is my understanding OK? If yes, feel free to make a PR.

@thaJeztah
Copy link

I don't think a hard-coded list should be used for these. Comments without a space are meant for "machine-readable" comments (such as //nolint:). Such comments are valid, but must follow the format described in golang/go#37974 (comment)

//[a-z0-9]+:[a-z0-9]

(// (comment), followed by a "namespace" ([a-z0-9]+), a colon (:), and some text ([a-z0-9]. after it)

See;

@chavacava
Copy link
Collaborator

Il will try to do a PR on this subject in the next days. My idea is to go ahead with the proposition by @thaJeztah (i.e. replacing the hard coded list with a regex)

@chavacava chavacava self-assigned this May 9, 2023
@thaJeztah
Copy link

Thanks! Sorry for commenting with suggestions without doing the actual work; couldn't find the bandwidth to get familiar with the codebase and to make the changes, but very much appreciate the project! (it definitely caught some issues here-and-there in codebases I work on ❤️)

@mgechev mgechev added the bug label May 15, 2023
@chavacava chavacava mentioned this issue May 10, 2024
chavacava added a commit that referenced this issue May 10, 2024
fix #808 by using the official regexp for directives
---------

Co-authored-by: chavacava <salvador.cavadini@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants