Skip to content

chore: add linter that catches math/rand imports#42513

Merged
mauri870 merged 3 commits intoelastic:mainfrom
mauri870:golangci-lint-math-rand
Feb 5, 2025
Merged

chore: add linter that catches math/rand imports#42513
mauri870 merged 3 commits intoelastic:mainfrom
mauri870:golangci-lint-math-rand

Conversation

@mauri870
Copy link
Copy Markdown
Member

Proposed commit message

This is a follow up to #42025 that migrated from math/rand to the newer math/rand/v2 package. Currently there is nothing preventing contributors to commiting code using math/rand and regressing these changes.

There is still code in beats that use math/rand, but it is mainly in tests. Since the linter only runs on new code I'm not fixing it here.

Introduce a linter that catches math/rand imports in Go files.

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.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Related issues

Logs

Offending code gets warned like this:

filebeat/input/filestream/internal/task/group_test.go:24:2: import 'math/rand' is not allowed from list 'main': superseded by math/rand/v2 (depguard)
        "math/rand"

@mauri870 mauri870 added cleanup Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team labels Jan 30, 2025
@mauri870 mauri870 self-assigned this Jan 30, 2025
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jan 30, 2025
@mauri870 mauri870 marked this pull request as ready for review January 30, 2025 18:47
@mauri870 mauri870 requested a review from a team as a code owner January 30, 2025 18:47
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jan 30, 2025

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @mauri870? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jan 30, 2025

backport-8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Jan 30, 2025
@mauri870 mauri870 merged commit 8cb39a0 into elastic:main Feb 5, 2025
mergify bot pushed a commit that referenced this pull request Feb 5, 2025
mauri870 added a commit that referenced this pull request Feb 5, 2025
(cherry picked from commit 8cb39a0)

Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
@pierrehilbert pierrehilbert added the backport-9.0 Automated backport to the 9.0 branch label Feb 5, 2025
mergify bot pushed a commit that referenced this pull request Feb 5, 2025
pierrehilbert pushed a commit that referenced this pull request Feb 5, 2025
(cherry picked from commit 8cb39a0)

Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-8.x Automated backport to the 8.x branch with mergify backport-9.0 Automated backport to the 9.0 branch cleanup 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.

4 participants