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

{,x-pack/}filebeat: clean up dead code #30483

Merged
merged 2 commits into from
Mar 1, 2022
Merged

Conversation

efd6
Copy link
Contributor

@efd6 efd6 commented Feb 21, 2022

What does this PR do?

This change removes unused code and cleans up the code formatting.

Why is it important?

Deadcode reduces code base maintainability.

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.

Author's Checklist

  • The first commit is purely mechanical and can be verified by running git-generate with that commit checked out.
  • The second commit should be checked with the view to save deletions from the gallows. I will add lint ignore directives for chunks that are to be retained and revert those chunks.

Audit beat was not reformatted because that is already happening in #30321.

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

@efd6 efd6 added cleanup Team:Security-External Integrations backport-skip Skip notification from the automated backport with mergify 8.2-candidate labels Feb 21, 2022
@efd6 efd6 requested a review from andrewkroh February 21, 2022 00:11
@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 Feb 21, 2022
@botelastic
Copy link

botelastic bot commented Feb 21, 2022

This pull request doesn't have a Team:<team> label.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Feb 21, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-02-21T05:08:12.598+0000

  • Duration: 157 min 46 sec

Test stats 🧪

Test Results
Failed 0
Passed 11522
Skipped 1302
Total 12824

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

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

@mergify mergify bot assigned efd6 Feb 21, 2022
@efd6 efd6 force-pushed the gardeninglint branch 2 times, most recently from d4b478e to 18c8fda Compare February 21, 2022 00:59
@efd6 efd6 changed the title {,x-pack/}{audit,file,packet}beat: clean up dead code {,x-pack/}{audit,file,packet,winlog}beat: clean up dead code Feb 21, 2022
@efd6 efd6 marked this pull request as ready for review February 21, 2022 01:41
@efd6 efd6 requested a review from a team as a code owner February 21, 2022 01:41
@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

[git-generate]
gofumpt -w ./{,x-pack/}filebeat
This removes the majority of unused identified by running:

staticcheck -checks 'U*' ./{,x-pack/}filebeat/...

Care has been taken to not remove platform-specific code and mage-required code.
@efd6
Copy link
Contributor Author

efd6 commented Feb 21, 2022

This has been split into 4 parts to ease review; the filebeat part remains here and the auditbeat, packetbeat and winlogbeat parts can be found at the mention links above.

@efd6 efd6 changed the title {,x-pack/}{audit,file,packet,winlog}beat: clean up dead code {,x-pack/}filebeat: clean up dead code Feb 21, 2022
@andrewkroh andrewkroh added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Feb 21, 2022
@elasticmachine
Copy link
Collaborator

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

@jlind23 jlind23 requested a review from a team February 21, 2022 13:27
@@ -195,17 +189,6 @@ func (r rotatedFilestreams) addRotatedFile(original, rotated string, src loginp.
return -1
}

// addRotatedFile adds a new rotated file to the list and returns its index.
// if a file is already added, the source is updated and the index is returned.
func (r rotatedFilestreams) removeRotatedFile(original, rotated string) {
Copy link
Member

Choose a reason for hiding this comment

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

For a SME: Perhaps this is a bug and this was meant to be used somewhere?

Copy link
Member

Choose a reason for hiding this comment

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

@kvch thoughts on if this is a bug or not?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is a leftover from my work. I implemented a few different approaches for tracking rotated files. I probably forgot to clean up a few functions or kept it for when we will support rotating input files. IDK. But for now it can be removed.

@jlind23 jlind23 added the v8.2.0 label Feb 22, 2022
@cmacknz
Copy link
Member

cmacknz commented Feb 22, 2022

Thanks!

FYI we are working through enabling the golangci-lint meta linter in some of the smaller repositories, starting with the elastic-agent-libs repository: elastic/elastic-agent-libs#10

Hopefully we can introduce that configuration (which includes staticcheck) or a subset of it to the beats repository to help enforce this automatically.

@andrewkroh
Copy link
Member

@cmacknz Great 👍 . We've just did this with go-libaudit and enabled the Github Action to check PRs. Any plans to introduce it to the Beats repo? Maybe we could enable the GH action and only check for new issues introduced in PRs.

@cmacknz
Copy link
Member

cmacknz commented Feb 22, 2022

@cmacknz Great 👍 . We've just did this with go-libaudit and enabled the Github Action to check PRs. Any plans to introduce it to the Beats repo? Maybe we could enable the GH action and only check for new issues introduced in PRs.

I would like to get golangci-lint enabled in the beats repo, we just need a sensible plan to introduce it. I like your idea of only checking if new issues were introduced, but I haven't investigated how to implement it yet.

@andrewkroh
Copy link
Member

The CLI tool supports a --new flag and the GH action has an option too (example).

@efd6 efd6 merged commit 0192a90 into elastic:main Mar 1, 2022
@efd6 efd6 deleted the gardeninglint branch March 2, 2022 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip Skip notification from the automated backport with mergify cleanup Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants