Skip to content

Comments

golangci: Enable testifylint for data-plane owned code#49008

Open
orestisfl wants to merge 3 commits intoelastic:mainfrom
orestisfl:add-testifylint
Open

golangci: Enable testifylint for data-plane owned code#49008
orestisfl wants to merge 3 commits intoelastic:mainfrom
orestisfl:add-testifylint

Conversation

@orestisfl
Copy link
Contributor

Proposed commit message

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.

This will help with writing cleaner tests and ease debugging of flaky tests. E.g. using Len will print the full array and it's length instead of just two numbers that are hard to debug.

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.EqualValuesassert.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

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

None. Test-only changes with no impact on production code or behavior.

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.
@orestisfl orestisfl self-assigned this Feb 20, 2026
@orestisfl orestisfl requested review from a team as code owners February 20, 2026 14:38
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Feb 20, 2026
@github-actions
Copy link
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@orestisfl orestisfl added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Feb 20, 2026
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Feb 20, 2026
@orestisfl orestisfl removed the needs_team Indicates that the issue/PR needs a Team:* label label Feb 20, 2026
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@orestisfl orestisfl added the backport-active-all Automated backport with mergify to all the active branches label Feb 20, 2026
@orestisfl orestisfl requested a review from rdner February 20, 2026 14:39
@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Feb 20, 2026
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

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

Labels

backport-active-all Automated backport with mergify to all the active branches cleanup skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants