-
-
Notifications
You must be signed in to change notification settings - Fork 394
staticcheck: add documentation text to select checks #1663
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
base: master
Are you sure you want to change the base?
Conversation
This change adds the `Text` field to the `Doc` field of the SA1002 analyzer. Signed-off-by: Charlotte Brandhorst-Satzkorn <[email protected]>
This change adds the `Text` field to the `Doc` field of the SA1012 analyzer. Signed-off-by: Charlotte Brandhorst-Satzkorn <[email protected]>
This change adds the `Text` field to the `Doc` field of the SA1014 analyzer. Signed-off-by: Charlotte Brandhorst-Satzkorn <[email protected]>
This change adds the `Text` field to the `Doc` field of the SA1020 analyzer. Signed-off-by: Charlotte Brandhorst-Satzkorn <[email protected]>
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 <[email protected]>
This change adds the `Text` field to the `Doc` field of the SA2003 analyzer. Signed-off-by: Charlotte Brandhorst-Satzkorn <[email protected]>
This change adds the `Text` field to the `Doc` field of the SA4010 analyzer. Signed-off-by: Charlotte Brandhorst-Satzkorn <[email protected]>
}, | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please wrap documentation at ~80 characters, see for example SA1004.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this be (*sync.WaitGroup).Add
?
This PR introduces documentation text for the following checks:
It 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 for SA2000.