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

chore: Fix linter findings for revive:exported in plugins/inputs/l* #16167

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

zak-pawel
Copy link
Collaborator

Summary

Address findings for revive:exported in plugins/inputs/l*.

As part of this effort for files from plugins/inputs/l*, the following actions were taken:

  • Type names (const, var, struct, func, etc) were changed to unexported, wherever they didn't need to be exported.
  • All remaining exported types were given comments in the appropriate form – this does not apply to exported methods that implement "known" plugin interfaces (Gather|Init|Start|Stop|SampleConfig|Parse|Add|Apply|Serialize|SerializeBatch|SetParser|SetParserFunc|GetState|SetState).
  • The order of methods was organized (exported methods first, then unexported, with init at the very end).

It is only part of the bigger work (for issue: #15813).
After all findings of this type in whole project are handled, we can enable revive:exported rule in golangci-lint.

In addition:

  • plugins/inputs/linux_sysctl_fs/linux_sysctl_fs.go contained a method that extracted the path to the proc directory from HOST_PROC (or returned the default: /proc). This method was used by another plugin, plugins/inputs/processes/processes_notwindows.go. I moved this method to internal/env.go and adjusted the code of all plugins which did similar things to use it. I did the same for HOST_SYS.
  • While changing methods from exported to unexported in the interface implemented by mock, I regenerated all mocks using the latest mockery (for input plugins from a* to l*).

Checklist

  • No AI generated code was used in this PR

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Thanks @zak-pawel! Just one comment about getting rid of a useless function. Approving anyway in case you want to do it in a separate PR...

Comment on lines 124 to 126
func newLanz() *Lanz {
return &Lanz{}
}
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we can get rid of this function in the present PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed.

Comment on lines 125 to 127
func (logstash *Logstash) Start(_ telegraf.Accumulator) error {
return nil
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (logstash *Logstash) Start(_ telegraf.Accumulator) error {
return nil
}
func (*Logstash) Start(telegraf.Accumulator) error {
return nil
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed.

@srebhan srebhan removed their assignment Nov 11, 2024
@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Nov 11, 2024
@DStrand1 DStrand1 merged commit 942d2b3 into influxdata:master Nov 12, 2024
27 checks passed
@github-actions github-actions bot added this to the v1.32.3 milestone Nov 12, 2024
srebhan pushed a commit that referenced this pull request Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore linter ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants