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

Revive fixes - part 2 #8835

Merged
merged 8 commits into from
Feb 16, 2021
Merged

Revive fixes - part 2 #8835

merged 8 commits into from
Feb 16, 2021

Conversation

zak-pawel
Copy link
Collaborator

Revive is fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.

This is part2 of fixes for problems found for following set of rules:

  • [rule.if-return]
    • Redundant if when returning an error. -> Checking if an error is nil to just after return the error or nil is redundant.
  • [rule.increment-decrement]
    • Use i++ and i-- instead of i += 1 and i -= 1. -> By convention, for better readability, incrementing an integer variable by 1 is recommended to be done using the ++ operator. This rule spots expressions like i += 1 and i -= 1 and proposes to change them into i++ and i--.
  • [rule.var-declaration]
    • Reduces redundancies around variable declaration. -> This rule proposes simplifications of variable declarations.
  • [rule.package-comments]
    • Package commenting conventions. -> Packages should have comments. This rule warns on undocumented packages and when packages comments are detached to the package keyword. More information here
  • [rule.receiver-naming]
    • Conventions around the naming of receivers. -> By convention, receiver names in a method should reflect their identity. For example, if the receiver is of type Parts, p is an adequate name for it. Contrary to other languages, it is not idiomatic to name receivers as this or self.
  • [rule.unexported-return]
    • Warns when a public return is from unexported type. -> This rule warns when an exported function or method returns a value of an un-exported type.
    • Few findings left untouched -> for some deeper review in the future.

For changed files, minor fixes were also made (got rid off "log" package where it was easy, CamelCase instead of snake_case, etc...)

[rule.if-return]
[rule.increment-decrement]
[rule.var-declaration]
[rule.package-comments]
[rule.receiver-naming]
[rule.unexported-return]
@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Feb 8, 2021
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!

models/running_output.go Outdated Show resolved Hide resolved
plugins/inputs/cpu/cpu.go Outdated Show resolved Hide resolved
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.

Looks good, found only very minor things... ;-)
Regarding the renaming of the "class" variable I'm not so sure about the exceptions, but if everybody can live with it...

@srebhan srebhan self-assigned this Feb 8, 2021
@srebhan srebhan mentioned this pull request Feb 9, 2021
3 tasks
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.

Looks good to me.

@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 Feb 10, 2021
@zak-pawel
Copy link
Collaborator Author

For retry

@zak-pawel zak-pawel closed this Feb 11, 2021
@zak-pawel
Copy link
Collaborator Author

For retry of windows tests

@zak-pawel zak-pawel reopened this Feb 11, 2021
agent/tick_test.go Outdated Show resolved Hide resolved
models/running_output.go Show resolved Hide resolved
plugins/common/shim/config.go Outdated Show resolved Hide resolved
plugins/common/shim/config_test.go Outdated Show resolved Hide resolved
plugins/inputs/passenger/passenger.go Outdated Show resolved Hide resolved
plugins/inputs/webhooks/webhooks.go Show resolved Hide resolved
@ssoroka
Copy link
Contributor

ssoroka commented Feb 16, 2021

I think there's still a lot of var struct/map/slice cases left over. I'm guessing we don't want to use rule.var-declaration.

@zak-pawel
Copy link
Collaborator Author

zak-pawel commented Feb 16, 2021

I think there's still a lot of var struct/map/slice cases left over. I'm guessing we don't want to use rule.var-declaration.

@ssoroka All var struct/map/slice cases reverted. rule.var-declaration is just fine, I've just changed too much initially.

@ssoroka ssoroka merged commit d9736d5 into influxdata:master Feb 16, 2021
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Mar 5, 2023
* Revive fixes regarding following set of rules:
[rule.if-return]
[rule.increment-decrement]
[rule.var-declaration]
[rule.package-comments]
[rule.receiver-naming]
[rule.unexported-return]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug 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