Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More fixes for golangci-lint upgrade #94

Merged
merged 1 commit into from
Dec 3, 2023

Conversation

brandur
Copy link
Contributor

@brandur brandur commented Dec 3, 2023

So after #93 came in I ran my own brew upgrade golangci-lint, and I
guess I got a new point release, because I got a whole bunch of new lint
problems. I wish it was clearer which version I even got, but apparently
golangci-lint is releasing HEAD versions to Homebrew:

$ golangci-lint --version
golangci-lint has version HEAD-185b2c7 built with go1.21.4 from 185b2c7 on 2023-11-29T17:26:42Z

I fixed most of the problems, but I ended up disabling one of the
features of testifylint that disallows uses of testify functions in
goroutines, which would've required some very significant changes, and
which in our project produces a false positive rate (of actual problems)
of 100.0% as far as I can tell. See the description of this feature
here:

https://github.com/Antonboom/testifylint#go-require

$ golangci-lint run --fix
client_test.go:378:6: go-require: require must only be used in the goroutine running the test function (testifylint)
                                        require.NoError(t, err)
                                        ^
internal/baseservice/base_service_test.go:40:4: go-require: require must only be used in the goroutine running the test function (testifylint)
                        require.FailNow(t, "Test case took too long to run (sleep statements should return immediately)")
                        ^
internal/dbadapter/db_adapter_test.go:409:6: go-require: require must only be used in the goroutine running the test function (testifylint)
                                        require.NoError(t, err)
                                        ^
internal/riverinternaltest/riverinternaltest_test.go:78:8: go-require: TestTx contains assertions that must only be used in the goroutine running the test function (testifylint)
                        _ = TestTx(ctx, t)

@brandur brandur force-pushed the brandur-more-golang-ci-lint-fixes branch from a23d11a to 2efeeb7 Compare December 3, 2023 03:42
@@ -897,7 +897,7 @@ func Test_Client_InsertMany(t *testing.T) {

jobs, err := bundle.queries.JobGetByKind(ctx, client.driver.GetDBPool(), (noOpArgs{}).Kind())
require.NoError(t, err)
require.Len(t, jobs, 2, fmt.Sprintf("Expected to find exactly two jobs of kind: %s", (noOpArgs{}).Kind()))
require.Len(t, jobs, 2, "Expected to find exactly two jobs of kind: "+(noOpArgs{}).Kind()) //nolint:goconst
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added nolint on these lines ... I dunno about adding constants for assertion messages.

@brandur brandur requested a review from bgentry December 3, 2023 03:48
Copy link
Contributor

@bgentry bgentry left a comment

Choose a reason for hiding this comment

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

Ah, I suspect you're running on brew install golangci-lint --HEAD whereas I'm running the latest bundled release again. I had to use HEAD at one point due to an OS upgrade iirc but that's resolved now.

Up to you if you want to move forward with this right now or wait til this gets officially released.

@brandur
Copy link
Contributor Author

brandur commented Dec 3, 2023

Ah, I suspect you're running on brew install golangci-lint --HEAD whereas I'm running the latest bundled release again. I had to use HEAD at one point due to an OS upgrade iirc but that's resolved now.

Hah, I swear I didn't. This is the exact command I ran today (does an upgrade take head into account?):

brew upgrade golangci-lint

Either way, these changes are very likely going to be coming in anyway, so probably not too harmful to get them a little early.

So after #93 came in I ran my own `brew upgrade golangci-lint`, and I
guess I got a new point release, because I got a whole bunch of new lint
problems. I wish it was clearer which version I even got, but apparently
golangci-lint is releasing HEAD versions to Homebrew:

    $ golangci-lint --version
    golangci-lint has version HEAD-185b2c7 built with go1.21.4 from 185b2c7 on 2023-11-29T17:26:42Z

I fixed most of the problems, but I ended up disabling one of the
features of `testifylint` that disallows uses of testify functions in
goroutines, which would've required some very significant changes, and
which in our project produces a false positive rate (of actual problems)
of 100.0% as far as I can tell. See the description of this feature
here:

https://github.com/Antonboom/testifylint#go-require

    $ golangci-lint run --fix
    client_test.go:378:6: go-require: require must only be used in the goroutine running the test function (testifylint)
                                            require.NoError(t, err)
                                            ^
    internal/baseservice/base_service_test.go:40:4: go-require: require must only be used in the goroutine running the test function (testifylint)
                            require.FailNow(t, "Test case took too long to run (sleep statements should return immediately)")
                            ^
    internal/dbadapter/db_adapter_test.go:409:6: go-require: require must only be used in the goroutine running the test function (testifylint)
                                            require.NoError(t, err)
                                            ^
    internal/riverinternaltest/riverinternaltest_test.go:78:8: go-require: TestTx contains assertions that must only be used in the goroutine running the test function (testifylint)
                            _ = TestTx(ctx, t)
@brandur brandur force-pushed the brandur-more-golang-ci-lint-fixes branch from 2efeeb7 to 8be1e1d Compare December 3, 2023 03:57
@brandur
Copy link
Contributor Author

brandur commented Dec 3, 2023

Ah, actually you're probably right. I likely installed --head at some point in the past, and the option was persisted through until now.

$ brew info golangci-lint
==> golangci-lint: stable 1.55.2 (bottled), HEAD
Fast linters runner for Go
https://golangci-lint.run/
/opt/homebrew/Cellar/golangci-lint/HEAD-185b2c7 (9 files, 30.5MB) *
  Built from source on 2023-12-02 at 18:19:30
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/g/golangci-lint.rb
License: GPL-3.0-only
==> Dependencies
Required: go ✔
==> Options
--HEAD
        Install HEAD version
==> Caveats
zsh completions have been installed to:
  /opt/homebrew/share/zsh/site-functions
==> Analytics
install: 10,193 (30 days), 31,449 (90 days), 84,287 (365 days)
install-on-request: 10,189 (30 days), 31,438 (90 days), 84,255 (365 days)
build-error: 0 (30 days)

@brandur
Copy link
Contributor Author

brandur commented Dec 3, 2023

Thx. I may have jumped the gun, but going to merge this since the work's done and these will be coming down the pipeline soon-ish anyway.

@brandur brandur merged commit 0bbcd0c into master Dec 3, 2023
7 checks passed
@brandur brandur deleted the brandur-more-golang-ci-lint-fixes branch December 3, 2023 10:37
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