Skip to content

tools: golangci lint#2512

Open
kerolasa wants to merge 4 commits intopublicsuffix:mainfrom
kerolasa:kerolasa/golangci-lint
Open

tools: golangci lint#2512
kerolasa wants to merge 4 commits intopublicsuffix:mainfrom
kerolasa:kerolasa/golangci-lint

Conversation

@kerolasa
Copy link
Copy Markdown
Contributor

This pull request addresses all golangci-lint warnings in this repository. One could say some of the changes are overly pedantic, but that should be fine. It is better to get rid of all the warnings, so that the lint tooling can catch regressions if and when they happen. The golangci-lint i used is v2.

@kerolasa
Copy link
Copy Markdown
Contributor Author

The No suffix blocks changed test failure might need to be ignored. This change does not attempt to change public suffixes.

@weppos weppos self-assigned this Jul 8, 2025
@weppos weppos added the go Pull requests that update Go code label Jul 8, 2025
@weppos
Copy link
Copy Markdown
Member

weppos commented Jul 8, 2025

Hi @kerolasa, thanks for the PR. I think we need to add the golangci lint to the CI workflow, to ensure the compliance is verified and preserved. It will also codify the settings and the version, because I can't see them in this commit.

Can you please:

  • Add a psltool workflow that includes (a single for now) golangci-lint task)? (I see the Go tool tests are currently mixed with the PSL tests in test.yml, I will propose to split them out)
  • Add a configuration file .golangci.yml with the configs you used
  golangci-lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version-file: 'go.mod'
          cache: true
      - name: golangci-lint
        uses: golangci/golangci-lint-action@v8
        with:
          version: v2.1

Thanks!

@weppos weppos changed the title Kerolasa/golangci lint pstools: golangci lint Jul 8, 2025
@weppos weppos changed the title pstools: golangci lint tools: golangci lint Jul 8, 2025
kerolasa and others added 3 commits October 27, 2025 12:11
psltool.go:107:15: Error return value of `fmt.Fprintln` is not checked (errcheck)
psltool.go:110:15: Error return value of `fmt.Fprintln` is not checked (errcheck)
psltool.go:120:23: Error return value of `mdiff.FormatUnified` is not checked (errcheck)
psltool.go:205:15: Error return value of `fmt.Fprintln` is not checked (errcheck)
psltool.go:209:15: Error return value of `fmt.Fprintln` is not checked (errcheck)
psltool.go:273:15: Error return value of `fmt.Fprintln` is not checked (errcheck)
psltool.go:275:15: Error return value of `fmt.Fprintln` is not checked (errcheck)
psltool.go:277:15: Error return value of `fmt.Fprintf` is not checked (errcheck)
psltool.go:280:16: Error return value of `io.WriteString` is not checked (errcheck)
psltool.go:284:16: Error return value of `fmt.Fprintln` is not checked (errcheck)
psltool.go:286:17: Error return value of `io.WriteString` is not checked (errcheck)
psltool.go:290:15: Error return value of `fmt.Fprintln` is not checked (errcheck)
psltool.go:327:15: Error return value of `fmt.Fprintln` is not checked (errcheck)
psltool.go:331:17: Error return value of `os.Stdout.Write` is not checked (errcheck)
psltool.go:100:10: ST1005: error strings should not be capitalized (staticcheck)
psltool.go:124:11: ST1005: error strings should not be capitalized (staticcheck)
psltool.go:127:11: ST1005: error strings should not be capitalized (staticcheck)
psltool.go:130:11: ST1005: error strings should not be capitalized (staticcheck)
psltool.go:171:10: ST1005: error strings should not be capitalized (staticcheck)
psltool.go:174:10: ST1005: error strings should not be capitalized (staticcheck)

Signed-off-by: Sami Kerola <kerolasa@cloudflare.com>
internal/parser/validate.go:235:12: Error return value of `group.Wait` is not checked (errcheck)
internal/parser/validate.go:250:12: Error return value of `group.Wait` is not checked (errcheck)
internal/parser/write.go:20:14: Error return value of `fmt.Fprintf` is not checked (errcheck)
internal/parser/write.go:75:14: Error return value of `fmt.Fprintf` is not checked (errcheck)
newgtlds.go:345:23: Error return value of `resp.Body.Close` is not checked (errcheck)
newgtlds_test.go:553:17: Error return value of `os.Remove` is not checked (errcheck)
newgtlds_test.go:561:17: Error return value of `os.Remove` is not checked (errcheck)
newgtlds_test.go:573:17: Error return value of `os.Remove` is not checked (errcheck)
newgtlds_test.go:583:17: Error return value of `os.Remove` is not checked (errcheck)
newgtlds_test.go:593:17: Error return value of `os.Remove` is not checked (errcheck)
newgtlds_test.go:668:16: Error return value of `fmt.Fprintln` is not checked (errcheck)
internal/parser/clean.go:421:2: S1011: should replace loop with out.Text = append(out.Text, inf.Other...) (staticcheck)
internal/parser/diff.go:266:7: S1002: should omit comparison to bool constant, can be simplified to !b.info().isUnchanged (staticcheck)
internal/parser/errors.go:24:59: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/errors.go:34:84: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/errors.go:44:79: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/errors.go:56:74: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/errors.go:67:69: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/errors.go:79:72: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/errors.go:90:61: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/errors.go:100:70: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/errors.go:110:73: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/errors.go:122:52: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/errors.go:130:72: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/errors.go:138:75: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/exceptions.go:32:2: S1008: should use 'return missingTXT.Has(domain.String())' instead of 'if missingTXT.Has(domain.String()) { return true }; return false' (staticcheck)
internal/parser/parser.go:266:8: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/parser.go:419:26: QF1008: could remove embedded field "SourceRange" from selector (staticcheck)
internal/parser/exceptions.go:25:6: func exemptFromSorting is unused (unused)
internal/parser/exceptions.go:77:5: var incorrectSort is unused (unused)

Signed-off-by: Sami Kerola <kerolasa@cloudflare.com>
This is my first github workflow ever, lets hope this works.

Requested-by: Simone Carletti <weppos@weppos.net>
Reference: publicsuffix#2512
Signed-off-by: Sami Kerola <kerolasa@cloudflare.com>
@kerolasa kerolasa force-pushed the kerolasa/golangci-lint branch from 7fc2cc5 to e7d3895 Compare October 27, 2025 12:12
Signed-off-by: Sami Kerola <kerolasa@cloudflare.com>
@kerolasa
Copy link
Copy Markdown
Contributor Author

kerolasa commented Oct 27, 2025

Hello @weppos. I am not sure if the github workflow change looks the way you hoped. That's my first try with the github workflow, so it might be severely lacking in quality or even working. Anyways, I tried something rebased the pull and added go vendor updates as a minor maintenance bonus.

Oh, and what comes to adding .golangci.yml config. I have had some fun fixing v1 vs v2 golangci issues that I really believe best option is to run without config and let the defaults take precedence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants