dominikh / go-tools

Staticcheck - The advanced Go linter
https://staticcheck.dev
MIT License
6.15k stars 373 forks source link

Clarify multiline //lint:ignore directives' behaviours #889

Open ainar-g opened 3 years ago

ainar-g commented 3 years ago

(This is probably an upstream issue, as I wasn't able to find a good description of how multiline directives [pragmas? magic comments?] should work in Go, but the staticcheck directives are the ones I care about the most at the moment, so I'll post this in here.)

staticcheck's documentation should clarify if either of these is invalid or if there is any difference between them:

  1. if a != nil {
    	//lint:ignore SA1019 Ignore the deprecation warnings until the frontend learns to use the new API.
    	b = a.b
    }
  2. if a != nil {
    	//lint:ignore SA1019 Ignore the deprecation warnings until the
    	//frontend learns to use the new API.
    	b = a.b
    }
  3. if a != nil {
    	//lint:ignore SA1019 Ignore the deprecation warnings until the
    	// frontend learns to use the new API.
    	b = a.b
    }
dominikh commented 3 years ago

@ainar-g completely unrelated to this issue: for the past couple of months, the issues you have filed contain a lot of HTML, which makes it awkward to read them in a plain text email reader, as well as to edit:

Do you know why that's the case?

ainar-g commented 3 years ago

I do actually know why that's the case, and the reason is because I write them that way, heh. For multiple reasons, I've come to… dislike markup languages descended from Markdown recently, so I switched to using raw HTML, which most decent Markdown dialects allow, thankfully. It seems like GitHub encodes neither Markdown nor HTML into plain text when sending messages as E-mails, which is… sad.

I'll refrain from using HTML on GitHub, now that I know that. Thanks for the heads up and sorry for inconvenience. Should I rewrite the OP?

dominikh commented 3 years ago

Don't worry about the OP :)

dominikh commented 3 years ago

As for the directives and multi-line: a single directive consists of a single line, or in other words, a single // comment. That's definitely true for Staticcheck, and probably true for Go.

I'll leave this issue open to remind me to improve the docs.