Skip to content

Conversation

catzkorn
Copy link

@catzkorn catzkorn commented Jul 20, 2025

This PR introduces documentation text for the following checks:

  • SA1002
  • SA1012
  • SA1014
  • SA1020
  • SA2000
  • SA2003
  • SA4010

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.

catzkorn added 7 commits July 19, 2025 19:47
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.`,
Copy link
Owner

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.

Copy link
Owner

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.`,
Copy link
Owner

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.`,
Copy link
Owner

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`,
Copy link
Owner

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?

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 this pull request may close these issues.

2 participants