Skip to content

Revive fixes - part 1#8797

Merged
ssoroka merged 4 commits intoinfluxdata:masterfrom
zak-pawel:revive-fixes-part1
Feb 8, 2021
Merged

Revive fixes - part 1#8797
ssoroka merged 4 commits intoinfluxdata:masterfrom
zak-pawel:revive-fixes-part1

Conversation

@zak-pawel
Copy link
Copy Markdown
Collaborator

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

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

  • [rule.blank-imports]
    • Disallows blank imports -> Blank import should be only in a main or test package, or have a comment justifying it.
  • [rule.context-as-argument]
    • context.Context should be the first argument of a function. -> By convention, context.Context should be the first parameter of a function. This rule spots function declarations that do not follow the convention.
  • [rule.dot-imports]
    • Forbids . imports. -> Importing with . makes the programs much harder to understand because it is unclear whether names belong to the current package or to an imported package. More information here
  • [rule.error-strings]
    • Conventions around error strings. -> Description: By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline. More information here
  • [rule.error-naming]
    • Naming of error variables. -> By convention, for the sake of readability, variables of type error must be named with the prefix err.
  • [rule.indent-error-flow]
    • Prevents redundant else statements. -> To improve the readability of code, it is recommended to reduce the indentation as much as possible. This rule highlights redundant else-blocks that can be eliminated from the code. More information here
  • [rule.errorf]
    • Should replace errors.New(fmt.Sprintf()) with fmt.Errorf() -> It is possible to get a simpler program by replacing errors.New(fmt.Sprintf()) with fmt.Errorf(). This rule spots that kind of simplification opportunities.

[rule.blank-imports]
[rule.context-as-argument]
[rule.context-keys-type]
[rule.dot-imports]
[rule.error-return]
[rule.error-strings]
[rule.indent-error-flow]
[rule.errorf]
Copy link
Copy Markdown
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!

@sspaink sspaink mentioned this pull request Feb 4, 2021
Copy link
Copy Markdown
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.

Wow that was a ride. :-)
The code looks good to me. I found one more superfluous else in plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go line 308. Please fix this one also.

I also found plugins/outputs/amqp/amqp.go using the log package instead of telegraf.Logger but that might be a separate bunch of changes...

@srebhan srebhan self-assigned this Feb 4, 2021
Copy link
Copy Markdown
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! Thank you very much!

@srebhan srebhan added 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. labels Feb 4, 2021
Copy link
Copy Markdown
Contributor

@ssoroka ssoroka left a comment

Choose a reason for hiding this comment

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

Amazing effort. minor feedback.

Copy link
Copy Markdown
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.

Still awesome... ;-)

@ssoroka ssoroka merged commit ba66d4f into influxdata:master Feb 8, 2021
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Mar 5, 2023
* Revive fixes regarding following set of rules:
[rule.blank-imports]
[rule.context-as-argument]
[rule.context-keys-type]
[rule.dot-imports]
[rule.error-return]
[rule.error-strings]
[rule.indent-error-flow]
[rule.errorf]
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 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