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

Run revive linter in CI #8798

Merged
merged 9 commits into from
Feb 18, 2021
Merged

Run revive linter in CI #8798

merged 9 commits into from
Feb 18, 2021

Conversation

sspaink
Copy link
Contributor

@sspaink sspaink commented Feb 4, 2021

Run the revive linter for each pull request, but don't fail on it just output the results in a friendly format. Added a config toml with the rule "exported" removed that had 2K issues reported for things exported without a comment.

Once the errors are more cleaned up, this should be updated to warn/error if a pull request introduces issues. Related to the pr #8797.

Just output the results, don't fail on it
Removed the rule.exported rule
Copy link
Contributor

@telegraf-tiger telegraf-tiger bot left a comment

Choose a reason for hiding this comment

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

🤝 ✅ CLA has been signed. Thank you!

@zak-pawel
Copy link
Collaborator

LGTM!

revivelint_config.toml Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@srebhan
Copy link
Member

srebhan commented Feb 4, 2021

Not sure if this is the right place but I'll try anyway. ;-)
Working through #8797 I found the following things that we might want to have as a rule:

  1. Do not use log in a plugin of type input, output, aggregator, processor (parser and serializer are special) but rather use telegraf.Logger.
  2. Finding \"%s\" in fmt functions and use %q instead.
  3. Patterns of the form
if condition {
    return true
}
return false

or the inverse can be simplified to return condition.

@srebhan srebhan self-assigned this Feb 4, 2021
@zak-pawel zak-pawel 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 Feb 4, 2021
@zak-pawel
Copy link
Collaborator

Not sure if this is the right place but I'll try anyway. ;-)
Working through #8797 I found the following things that we might want to have as a rule:

  1. Do not use log in a plugin of type input, output, aggregator, processor (parser and serializer are special) but rather use telegraf.Logger.
  2. Finding \"%s\" in fmt functions and use %q instead.
  3. Patterns of the form
if condition {
    return true
}
return false

or the inverse can be simplified to return condition.

@srebhan (and @ssoroka, @reimda): Unfortunately it seems that to add own rule, accepted PR to https://github.com/mgechev/revive or fork is needed: https://github.com/mgechev/revive#extensibility

@sspaink
Copy link
Contributor Author

sspaink commented Feb 4, 2021

@zak-pawel that is an unfortunate limitation, maybe we should use golangci-lint for now which would let us create a Telegraf specific linter without having to push it upstream (more info). I can just update this PR to change from revive->golangci-lint.
We could potentially run both linters if we want or wait until golangci-lint supports running revive.

@p-zak
Copy link
Collaborator

p-zak commented Feb 4, 2021

@zak-pawel that is an unfortunate limitation, maybe we should use golangci-lint for now which would let us create a Telegraf specific linter without having to push it upstream (more info). I can just update this PR to change from revive->golangci-lint.
We could potentially run both linters if we want or wait until golangci-lint supports running revive.

I think that we can start with revive (as wew did :)) - because it is pretty good tool. We will try to fix as many problems as possible and after that (or in parallel) we can start to work with golangci-lint also.
In the meantime we need to think about custom rules.

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.

Perfect thanks!

@srebhan
Copy link
Member

srebhan commented Feb 4, 2021

@sspaink I discussed with @p-zak and I think at least my requests can be covered. 1. can be checked by not allowing to include log in the plugins. 2. might be an upstream acceptable change anyway, same as 3. The probably also exist at least partially.

@p-zak
Copy link
Collaborator

p-zak commented Feb 4, 2021

@sspaink I discussed with @p-zak and I think at least my requests can be covered. 1. can be checked by not allowing to include log in the plugins. 2. might be an upstream acceptable change anyway, same as 3. The probably also exist at least partially.

@srebhan we can cover these in the future, they should not be part of this PR :)

@srebhan
Copy link
Member

srebhan commented Feb 4, 2021

@p-zak I fully agree.

@srebhan srebhan added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Feb 4, 2021
@sspaink sspaink removed 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 Feb 16, 2021
Makefile Show resolved Hide resolved
@zak-pawel
Copy link
Collaborator

zak-pawel commented Feb 16, 2021

@sspaink Don't we need to wait for next release (> v1.36.0) of golangci-lint to contain revive linter? Right now we have unknown linter: https://app.circleci.com/pipelines/github/influxdata/telegraf/3456/workflows/54ea1dc6-8eda-4b53-8dc5-d79ec57cba0b/jobs/78136

@zak-pawel
Copy link
Collaborator

@sspaink Don't we need to wait for next release (> v1.36.0) of golangci-lint to contain revive linter? Right now we have unknown linter: https://app.circleci.com/pipelines/github/influxdata/telegraf/3456/workflows/54ea1dc6-8eda-4b53-8dc5-d79ec57cba0b/jobs/78136

And v1.37.0 has been just released :)

.golangci.yml Outdated Show resolved Hide resolved
@zak-pawel zak-pawel 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 Feb 18, 2021
@sspaink sspaink merged commit 660eb5b into influxdata:master Feb 18, 2021
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Mar 5, 2023
* Run revive linter in CI
Just output the results, don't fail on it
Removed the rule.exported rule

* Move revive install to CI

* new line

* Use golangci-lint

* Get v1.37

* increase timeout by a minute

* try five minutes

* newline missing

* Update config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin 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.

5 participants