Skip to content

update actions, and fix linting issues#450

Merged
tomasaschan merged 9 commits intospf13:masterfrom
thaJeztah:fix_linting
Mar 5, 2026
Merged

update actions, and fix linting issues#450
tomasaschan merged 9 commits intospf13:masterfrom
thaJeztah:fix_linting

Conversation

@thaJeztah
Copy link

@thaJeztah thaJeztah commented Sep 1, 2025

@thaJeztah thaJeztah force-pushed the fix_linting branch 4 times, most recently from 6f56b92 to 9e20f80 Compare September 2, 2025 08:10
@thaJeztah thaJeztah marked this pull request as ready for review September 2, 2025 08:19
@thaJeztah thaJeztah mentioned this pull request Sep 2, 2025
Copy link
Collaborator

@tomasaschan tomasaschan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I'm a huge fan of lining and enforcing it with checks, I'm not sure about all the changes. See below for details.

@thaJeztah
Copy link
Author

@tomasaschan sorry for the delay, I somehow missed your review. I rebased this one, and updated the actions to the latest versions (as some new versions were released). PTAL

@tomasaschan
Copy link
Collaborator

@thaJeztah My turn to apologize for the delay - I just recently came back from 9 months of parental leave and am still catching up with the world...

It seems this'll need another rebase. Once done, though, I think it should be good to go!

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Some of these were a slightly false positive, because flagSet.parseLongArg
uses a named output var which was already assigned to `err`, and `flagSet.fail()`
returns the error-as is; https://github.com/spf13/pflag/blob/10438578954bba2527fe5cae3684d4532b064bbe/flag.go#L935-L942

    flag.go:1033:9: Error return value of `f.fail` is not checked (errcheck)
            f.fail(err)
                  ^
    flag.go:1109:9: Error return value of `f.fail` is not checked (errcheck)
            f.fail(err)
                  ^

This patch just re-assigns it to `err` to keep the linters happy.

Many other unhandled errors were either "neglectable" (e.g. errors from
`fmt.Printf`), and some unhandled errors would likely cause tests to fail
later on, but it doesn't hurt to be explicit and to explicitly mark unhandled
errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    duration_slice.go:49:12: S1025: should use String() instead of fmt.Sprintf (staticcheck)
            out[i] = fmt.Sprintf("%s", d)
                     ^
    duration_slice.go:59:9: S1025: should use String() instead of fmt.Sprintf (staticcheck)
        return fmt.Sprintf("%s", val)
               ^
    flag.go:658:10: QF1004: could use strings.ReplaceAll instead (staticcheck)
            return strings.Replace(s, "\n", "\n"+strings.Repeat(" ", i), -1)
                   ^
    flag.go:676:10: QF1004: could use strings.ReplaceAll instead (staticcheck)
            return strings.Replace(s, "\n", r, -1)
                   ^
    flag.go:688:10: QF1004: could use strings.ReplaceAll instead (staticcheck)
        r = r + strings.Replace(l, "\n", "\n"+strings.Repeat(" ", i), -1)
                ^
    flag_test.go:641:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
        if flag == nil {
           ^
    flag_test.go:644:10: SA5011: possible nil pointer dereference (staticcheck)
        if flag.Name != "boola" {
                ^
    flag_test.go:654:2: SA4006: this value of flag is never used (staticcheck)
        flag = f.ShorthandLookup("ab")
        ^
    ipnet_slice_test.go:16:2: S1008: should use 'return c1.String() == c2.String()' instead of 'if c1.String() == c2.String() { return true }; return false' (staticcheck)
        if c1.String() == c2.String() {
        ^
    string_array.go:33:2: S1001: should use copy(to, from) instead of a loop (staticcheck)
        for i, d := range val {
        ^
    string_array.go:42:2: S1001: should use copy(to, from) instead of a loop (staticcheck)
        for i, d := range *s.value {
        ^
    flag.go:658:10: QF1004: could use strings.ReplaceAll instead (staticcheck)
            return strings.Replace(s, "\n", "\n"+strings.Repeat(" ", i), -1)
                   ^
    flag.go:676:10: QF1004: could use strings.ReplaceAll instead (staticcheck)
            return strings.Replace(s, "\n", r, -1)
                   ^
    flag_test.go:757:12: QF1004: could use strings.ReplaceAll instead (staticcheck)
            result = strings.Replace(result, sep, to, -1)
                     ^
    flag_test.go:757:12: QF1004: could use strings.ReplaceAll instead (staticcheck)
            result = strings.Replace(result, sep, to, -1)
                     ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    bool_test.go:29:22: unnecessary conversion (unconvert)
        return triStateValue(*v)
                            ^
    count.go:16:18: unnecessary conversion (unconvert)
            *i = countValue(*i + 1)
                           ^
    uint64.go:30:15: unnecessary conversion (unconvert)
        return uint64(v), nil
                     ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    flag_test.go:754:52: replaceSeparators - to always receives "." (unparam)
    func replaceSeparators(name string, from []string, to string) string {
                                                       ^
    flag_test.go:1182:24: parseReturnStderr - t is unused (unparam)
    func parseReturnStderr(t *testing.T, f *FlagSet, args []string) (string, error) {
                           ^
    ip_slice.go:73:56: (*ipSliceValue).fromString - result 1 (error) is always nil (unparam)
    func (s *ipSliceValue) fromString(val string) (net.IP, error) {
                                                           ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
   bool_func_test.go:53:48: unused-parameter: parameter 's' seems to be unused, consider removing or renaming it as _ (revive)
            fset.BoolFunc("flag1", "usage message", func(s string) error { return nil })
                                                         ^
    bool_func_test.go:67:72: unused-parameter: parameter 's' seems to be unused, consider removing or renaming it as _ (revive)
            fset.BoolFunc("flag2", "usage message with `name` placeholder", func(s string) error { return nil })
                                                                                 ^
    flag_test.go:763:27: unused-parameter: parameter 'f' seems to be unused, consider removing or renaming it as _ (revive)
    func wordSepNormalizeFunc(f *FlagSet, name string) NormalizedName {
                              ^
    flag_test.go:821:31: unused-parameter: parameter 'f' seems to be unused, consider removing or renaming it as _ (revive)
    func aliasAndWordSepFlagNames(f *FlagSet, name string) NormalizedName {
                                  ^
    flag_test.go:1390:27: unused-parameter: parameter 'f' seems to be unused, consider removing or renaming it as _ (revive)
        fs.SetNormalizeFunc(func(f *FlagSet, name string) NormalizedName {
                                 ^
    func_test.go:67:44: unused-parameter: parameter 's' seems to be unused, consider removing or renaming it as _ (revive)
            fset.Func("flag1", "usage message", func(s string) error { return nil })
                                                     ^

    golangflag.go:74:6: exported: func name will be used as pflag.PFlagFromGoFlag by other packages, and that stutters; consider calling this FromGoFlag (revive)
    func PFlagFromGoFlag(goflag *goflag.Flag) *Flag {
         ^
    ipnet_slice_test.go:11:14: unused-parameter: parameter 'ip' seems to be unused, consider removing or renaming it as _ (revive)
    func getCIDR(ip net.IP, cidr *net.IPNet, err error) net.IPNet {
                 ^
    time.go:54:9: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
        } else {
            return d.Time.Format(time.RFC3339Nano)
        }

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- set default permissions to "content: read" as actions in this repository
  don't require write acccess.
- set a guardrails timeout; this should not be needed normally, but
  GitHub's default timeout is 6 Hours, and prevents runaway actions
  that may happen occasionally on GitHub service outages.
- remove filter for branch name and run on pull-requests, push events
- add "stable" and "oldstable" Go versions to the matrix; these always
  point to the currently maintained versions of Go (currently Go1.25
  and Go1.24). Using the fixed ("oldstable", "stable") keywords reduces
  maintainance and helps marking checks as "required" in branch protection,
  as such options are using the name generated from the matrix.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Author

@tomasaschan rebased, and congratulations!

I just recently came back from 9 months of parental leave and am still catching up with the world...

@tomasaschan tomasaschan merged commit 3d32e71 into spf13:master Mar 5, 2026
8 checks passed
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