staticcheck: add documentation text to select checks#1663
staticcheck: add documentation text to select checks#1663catzkorn wants to merge 7 commits intodominikh:masterfrom
Conversation
This change adds the `Text` field to the `Doc` field of the SA1002 analyzer. Signed-off-by: Charlotte Brandhorst-Satzkorn <charlotte@catzkorn.dev>
This change adds the `Text` field to the `Doc` field of the SA1012 analyzer. Signed-off-by: Charlotte Brandhorst-Satzkorn <charlotte@catzkorn.dev>
This change adds the `Text` field to the `Doc` field of the SA1014 analyzer. Signed-off-by: Charlotte Brandhorst-Satzkorn <charlotte@catzkorn.dev>
This change adds the `Text` field to the `Doc` field of the SA1020 analyzer. Signed-off-by: Charlotte Brandhorst-Satzkorn <charlotte@catzkorn.dev>
This change adds the `Text` field to the `Doc` field of the SA2000 analyzer. This change also updates the format of the method reference in the `Title` string to be consistent with other parts of the staticcheck documentation and the Go community conventions. Signed-off-by: Charlotte Brandhorst-Satzkorn <charlotte@catzkorn.dev>
This change adds the `Text` field to the `Doc` field of the SA2003 analyzer. Signed-off-by: Charlotte Brandhorst-Satzkorn <charlotte@catzkorn.dev>
This change adds the `Text` field to the `Doc` field of the SA4010 analyzer. Signed-off-by: Charlotte Brandhorst-Satzkorn <charlotte@catzkorn.dev>
| }, | ||
| Doc: &lint.RawDocumentation{ | ||
| Title: `Invalid format in \'time.Parse\'`, | ||
| Text: `\'time.Parse\' requires a layout string that uses Go's reference time: \'Mon Jan 2 15:04:05 MST 2006\' (Unix date format). The layout must represent this date and time exactly. See https://pkg.go.dev/time#pkg-constants for layout examples.`, |
There was a problem hiding this comment.
Please wrap documentation at ~80 characters, see for example SA1004.
There was a problem hiding this comment.
Use \" instead of \' to quote the reference time so we get quotes in CLI output.
| }, | ||
| Doc: &lint.RawDocumentation{ | ||
| Title: `The result of \'append\' will never be observed anywhere`, | ||
| Text: `Calls to \'append\' produce a new slice value that must be used. When the result of \'append\' is assigned to a variable that is never subsequently read, or is immediately overwritten, the append operation has no effect.`, |
There was a problem hiding this comment.
immediately overwritten
doesn't have to be immediate, just before it's read.
append operation has no effect
It may have an effect, but it usually won't be the desired one.
| }, | ||
| Doc: &lint.RawDocumentation{ | ||
| Title: `Deferred \'Lock\' right after locking, likely meant to defer \'Unlock\' instead`, | ||
| Text: `Deferring \'Lock\' immediately after locking will cause a deadlock. Use \'Unlock\' instead.`, |
There was a problem hiding this comment.
It doesn't necessarily cause a deadlock (and there are indeed possible false positives with this check if you write hard to follow code).
At the end of the day, this check just flags a probable typo, I'm not sure what we could document about that.
| }, | ||
| Doc: &lint.RawDocumentation{ | ||
| Title: `\'sync.WaitGroup.Add\' called inside the goroutine, leading to a race condition`, | ||
| Title: `\'sync.(*WaitGroup).Add\' called inside the goroutine, leading to a race condition`, |
There was a problem hiding this comment.
Wouldn't this be (*sync.WaitGroup).Add?
|
Ping. |
This PR introduces documentation text for the following checks:
It also updates the format of the method reference in the
Titlestring to be consistent with other parts of the staticcheck documentation and the Go community conventions for SA2000.