defenseunicorns / pkg

Common Go modules maintained by Defense Unicorns
Apache License 2.0
5 stars 4 forks source link

Add `staticcheck` #41

Open Noxsios opened 5 months ago

Noxsios commented 5 months ago

Is your feature request related to a problem? Please describe.

https://staticcheck.dev/

Currently there are niceities that go vet and revive do not have that staticcheck provides, primarily finding and reporting on Deprecated features.

Describe the solution you'd like

Example:

// First30Last30 returns the source string that has been trimmed to 30 characters at the beginning and end.
func First30Last30(s string) string {
    if len(s) > 60 {
        return s[0:27] + "..." + s[len(s)-26:]
    }

    return s
}

// First30last30 returns the source string that has been trimmed to 30 characters at the beginning and end.
//
// Deprecated: Use First30Last30 instead.
func First30last30(s string) string {
    return First30Last30(s)
}

First30last30 should be named First30Last30. In VSCode with the Go extension, staticcheck properly reports the deprecated usage.

Screenshot 2024-03-26 at 12 01 24 PM

❯ staticcheck
main.go:12:12: helpers.First30last30 is deprecated: Use First30Last30 instead.  (SA1019)
Noxsios commented 3 months ago

This should actually be to add golangci-lint, similar to what exists now on Zarf.