golangci: Enable testifylint for data-plane owned code#49008
Open
orestisfl wants to merge 3 commits intoelastic:mainfrom
Open
golangci: Enable testifylint for data-plane owned code#49008orestisfl wants to merge 3 commits intoelastic:mainfrom
orestisfl wants to merge 3 commits intoelastic:mainfrom
Conversation
Enable the testifylint linter and fix all findings in files owned by elastic-agent-data-plane (150 files). Files owned by other teams are left untouched to avoid cross-team review overhead. Fixes applied (mechanical, via golangci-lint --fix and manual repair): - Swap expected/actual argument order in assert.Equal/require.Equal - assert.Nil(err) → assert.NoError(err) - assert.True(t, errors.As(...)) → assert.ErrorAs(...) - assert.Equal(t, N, len(x)) → assert.Len(t, x, N) - assert.Equal(t, "", x) → assert.Empty(t, x) - assert.Equal(t, true, x) → assert.True(t, x) - assert.EqualValues → assert.Equal where types already match - assert.Positive(t, len(x)) → assert.NotEmpty(t, x) - require.NotEqual(t, x, nil) → require.NotNil(t, x) - Remove unused imports left behind by rewrites - Revert incorrect assert.Len conversions where the arg was not int - Nolint intentionally failing assertions in gotest_test.go Disabled checks: - go-require: too many false positives in helpers/callbacks - require-error: using assert for errors lets tests continue 106 issues remain repo-wide (float-compare, useless-assert, error-is-as, formatter) as they require manual judgment.
Contributor
🤖 GitHub commentsJust comment with:
|
Contributor
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
Contributor
|
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed commit message
Enable the
testifylintlinter and fix all findings in files owned byelastic-agent-data-plane(150 files). Files owned by other teams are left untouched to avoid cross-team review overhead.This will help with writing cleaner tests and ease debugging of flaky tests. E.g. using
Lenwill print the full array and it's length instead of just two numbers that are hard to debug.Fixes applied (mechanical, via
golangci-lint --fixand manual repair):assert.Equal/require.Equalassert.Nil(err)→assert.NoError(err)assert.True(t, errors.As(...))→assert.ErrorAs(...)assert.Equal(t, N, len(x))→assert.Len(t, x, N)assert.Equal(t, "", x)→assert.Empty(t, x)assert.Equal(t, true, x)→assert.True(t, x)assert.EqualValues→assert.Equalwhere types already matchassert.Positive(t, len(x))→assert.NotEmpty(t, x)require.NotEqual(t, x, nil)→require.NotNil(t, x)assert.Lenconversions where the arg was notintgotest_test.goDisabled checks:
go-require: too many false positives in helpers/callbacksrequire-error: using assert for errors lets tests continueChecklist
I have commented my code, particularly in hard-to-understand areasI have made corresponding changes to the documentationI have made corresponding change to the default configuration filesI have added tests that prove my fix is effective or that my feature works.I have added an entry in./changelog/fragmentsusing the changelog tool.Disruptive User Impact
None. Test-only changes with no impact on production code or behavior.