Skip to content

Conversation

@thaJeztah
Copy link
Contributor

See individual commits for details.


func formatErrorMessage(err error) string {
//nolint:errorlint // unwrapping is not appropriate here
// unwrapping is not appropriate here
Copy link
Contributor Author

Choose a reason for hiding this comment

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

LOL looks like different versions of the linters disagree. Let me add nolintlint to the ignore list;

assert/cmp/compare.go:252:14: type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)
        if _, ok := err.(causer); ok {
                    ^

Current versions of this linter default to no allowing third-party
dependencies by default (only stdlib and golang.org/x/sys).

As there's currently no configuration set to prevent a specific import,
this results in some imports being flagged;

    fs/manifest_test.go:11:2: import 'github.com/google/go-cmp/cmp' is not allowed from list 'Main' (depguard)
        "github.com/google/go-cmp/cmp"
        ^
    assert/assert.go:96:2: import 'github.com/google/go-cmp/cmp' is not allowed from list 'Main' (depguard)
        gocmp "github.com/google/go-cmp/cmp"
        ^
    assert/assert_test.go:8:2: import 'github.com/google/go-cmp/cmp' is not allowed from list 'Main' (depguard)
        gocmp "github.com/google/go-cmp/cmp"
        ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
The nolintlint linter considers the `nolint` to be redundant;

    assert/cmp/compare.go:251:2: directive `//nolint:errorlint // unwrapping is not appropriate here` is unused for linter "errorlint" (nolintlint)
        //nolint:errorlint // unwrapping is not appropriate here
        ^

But depending on the go version, it may trigger a warning:

    assert/cmp/compare.go:252:14: type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)
            if _, ok := err.(causer); ok {
                        ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
    assert/assert_test.go:108:3: empty-block: this block is empty, you can remove it (revive)
            for range []int{1, 2, 3, 4} {
            }

Signed-off-by: Sebastiaan van Stijn <[email protected]>
    internal/source/source.go:75:2: return both the `nil` error and invalid value: use a sentinel error instead (nilnil)
        return nil, nil
        ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
"cap" is now a builtin:

    internal/source/source_test.go:50:2: redefines-builtin-id: redefinition of the built-in function cap (revive)
        cap := &capture{}
        ^
    internal/source/source_test.go:73:2: redefines-builtin-id: redefinition of the built-in function cap (revive)
        cap := &capture{}
        ^
    internal/source/source_test.go:86:2: redefines-builtin-id: redefinition of the built-in function cap (revive)
        cap := &capture{}
        ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
    fs/report_test.go:187:19: unused-parameter: parameter 'b' seems to be unused, consider removing or renaming it as _ (revive)
            matcher := func(b []byte) CompareResult {
                            ^
    fs/report_test.go:196:19: unused-parameter: parameter 'b' seems to be unused, consider removing or renaming it as _ (revive)
            matcher := func(b []byte) CompareResult {
                            ^
    fs/report.go:107:46: printf: non-constant format string in call to gotest.tools/v3/fs.existenceProblem (govet)
                p = append(p, existenceProblem("content", r.FailureMessage()))
                                                          ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
    assert/assert_test.go:249:12: unused-parameter: parameter 'b' seems to be unused, consider removing or renaming it as _ (revive)
        f := func(b bool) {}
                  ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Current versions of govet check for printf functions called with a format
string, but no arguments. This results in linting errors:

    fs/report.go:107:46: printf: non-constant format string in call to gotest.tools/v3/fs.existenceProblem (govet)
                p = append(p, existenceProblem("content", r.FailureMessage()))
                                                          ^

This patch changes existenceProblem to use format.Message, which is used
elsewhere for similar situations.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
    poll/example_test.go:38:16: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
        check := func(t poll.LogT) poll.Result {
                      ^

    poll/poll_test.go:21:21: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
        func (t *fakeT) Log(args ...interface{}) {}
                        ^
    poll/poll_test.go:23:22: unused-parameter: parameter 'format' seems to be unused, consider removing or renaming it as _ (revive)
        func (t *fakeT) Logf(format string, args ...interface{}) {}
                         ^

    poll/poll_test.go:28:16: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
        check := func(t LogT) Result {
                      ^
    poll/poll.go:154:18: printf: non-constant format string in call to gotest.tools/v3/poll.Continue (govet)
        return Continue(buf.String())
                        ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
    assert/opt/opt_test.go:254:20: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
        func TestPathDebug(t *testing.T) {
                           ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
    x/subtest/example_test.go:47:23: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
    func startFakeService(t subtest.TestContext) string {
                          ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
    poll/poll.go:154:18: printf: non-constant format string in call to gotest.tools/v3/poll.Continue (govet)
        return Continue(buf.String())
                        ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Comment on lines 20 to +23

func (t *fakeT) Log(args ...interface{}) {}
func (t *fakeT) Log(...interface{}) {}

func (t *fakeT) Logf(format string, args ...interface{}) {}
func (t *fakeT) Logf(string, ...interface{}) {}

Choose a reason for hiding this comment

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

Maybe you coule use any instead of interface{}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept interface{} for now, so that we didn't have to raise the go version in go.mod;

go 1.17

(any would require go1.18 as minimum; https://go.dev/ref/spec#Go_1.18)

Choose a reason for hiding this comment

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

I know 😬 but Go 1.18 is now not only old, but no longer supported

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, more than aware; I also know that it's not uncommon for companies to maintain an (internal) LTS version of older Go versions. Not all of those will be visible publicly on GitHub. (e.g. I know Google for a long time required compatibility with go1.13 for some of their systems - they maintained their own version for that).


func existenceProblem(filename, reason string, args ...interface{}) problem {
return problem(filename + ": " + fmt.Sprintf(reason, args...))
func existenceProblem(filename string, msgAndArgs ...interface{}) problem {

Choose a reason for hiding this comment

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

Maybe you coule use ...any instead of ...interface{}

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

Thank you!

We should update the Go minimum version sometime soon.

@dnephin dnephin merged commit 9aa7888 into gotestyourself:main Aug 29, 2024
@thaJeztah thaJeztah deleted the linting_errors branch August 29, 2024 06:38
@thaJeztah
Copy link
Contributor Author

We should update the Go minimum version sometime soon.

Yes, if there's a need to bump, that's probably fine.

I tried to avoid it if there's no strict / important reason, knowing that gotest.tools is a test-dependency, and (library) projects may want to continue support for old Go versions, therefore running tests against those, so it's worth trying to keep the requirements as low as reasonably possible.

Crown0815 pushed a commit to Crown0815/forgejo-runner-windows that referenced this pull request May 21, 2025
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [gotest.tools/v3](https://github.com/gotestyourself/gotest.tools) | require | patch | `v3.5.1` -> `v3.5.2` |

---

### Release Notes

<details>
<summary>gotestyourself/gotest.tools (gotest.tools/v3)</summary>

### [`v3.5.2`](https://github.com/gotestyourself/gotest.tools/releases/tag/v3.5.2)

[Compare Source](gotestyourself/gotest.tools@v3.5.1...v3.5.2)

#### What's Changed

-   assert: ensure message is always displayed & fix under bazel by [@&#8203;cstrahan](https://github.com/cstrahan) in gotestyourself/gotest.tools#276
-   go.mod: golang.org/x/tools v0.13.0 for go1.22+ compatibility by [@&#8203;thaJeztah](https://github.com/thaJeztah) in gotestyourself/gotest.tools#282
-   poll: Continue(): use format.Message for formatting by [@&#8203;thaJeztah](https://github.com/thaJeztah) in gotestyourself/gotest.tools#279
-   fix TestFromDirSymlink on Windows due to missing drive-letter by [@&#8203;thaJeztah](https://github.com/thaJeztah) in gotestyourself/gotest.tools#283
-   Fix various linting issues and minor bugs by [@&#8203;thaJeztah](https://github.com/thaJeztah) in gotestyourself/gotest.tools#280
-   fix badges in readme, gofmt, and minor linting fix by [@&#8203;thaJeztah](https://github.com/thaJeztah) in gotestyourself/gotest.tools#284
-   circleci: add go1.21, go1.22, go1.23, and update golangci-lint to v1.60.3 by [@&#8203;thaJeztah](https://github.com/thaJeztah) in gotestyourself/gotest.tools#285
-   assert, assert/cmp: un-deprecate assert.ErrorType for now by [@&#8203;thaJeztah](https://github.com/thaJeztah) in gotestyourself/gotest.tools#286

#### New Contributors

-   [@&#8203;cstrahan](https://github.com/cstrahan) made their first contribution in gotestyourself/gotest.tools#276

**Full Changelog**: gotestyourself/gotest.tools@v3.5.1...v3.5.2

</details>

---

### Configuration

📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMTIuMCIsInVwZGF0ZWRJblZlciI6IjM5LjI1Mi4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/524
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
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.

3 participants