-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add linter to the building pipeline #30896
Conversation
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
This pull request does not have a backport label. Could you fix it @rdner? 🙏
NOTE: |
This pull request is now in conflicts. Could you fix it? 🙏
|
We should communicate the impact of this change to everyone who works on beats, at least the beats-contrib mailing list. Maybe link the PR to show what linters will be enabled. |
This pull request is now in conflicts. Could you fix it? 🙏
|
# Select the Go version to target. The default is '1.13'. | ||
go: "1.17.6" | ||
|
||
stylecheck: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For stylecheck (or some other linter) could we check that godoc follows the https://staticcheck.io/docs/checks/#ST1020. Like if you are going to put effort into writing docs for your exported function then follow the Go conventions 😄. FWIW we have that check in go-libaudit (had to disable one of the default excludes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually thought it was the default behaviour, I used to see this errors before in one of my previous projects. I tested locally and even with checks: ["all"]
for staticcheck
and stylecheck
it didn't return any errors for missing or malformed go doc strings. I'll investigate further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably one of the default rules for excluding issues listed in https://golangci-lint.run/usage/configuration#command-line-options. Like maybe EXC0014
.
Adding something like this can workaround it:
issues:
include:
# If you're going to write a comment follow the conventions.
# https://go.dev/doc/effective_go#commentary.
# comment on exported (.+) should be of the form "(.+)..."
- EXC0014
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add it later as a separate PR, since this is already stable and approved.
I landed here after hitting lint errors regarding errors.Wrap(err, "error message")) with fmt.Errorf("error message: %w", err)) Thought I'd mention it here for confirmation and incase it helps others resolve the replacement. |
* Added the mage targets * Added the linting configuration * Added the steps to Jenkinsfile
* Added the mage targets * Added the linting configuration * Added the steps to Jenkinsfile
What does this PR do?
WARNING! After merging this PR developers will be forced into fixing all linter issues in the entire files they change.
Why is it important?
The linter proved itself useful in the
elastic-agent-libs
repository and uncovered some bugs. This will allow us to catch certain problems (e.g. not checked error) before our customers report them.Checklist
- [ ] 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 worksCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
To run the linter on the entire repository (can take minutes to complete and would most likely emit a lot issues
Or run against files touched by the difference of the current branch and
main
(lint last change).Related issues