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

Linter fixes - gosimple #9046

Merged
merged 2 commits into from
Mar 25, 2021
Merged

Linter fixes - gosimple #9046

merged 2 commits into from
Mar 25, 2021

Conversation

zak-pawel
Copy link
Collaborator

Here are fixes for problems found by gosimple:

  • S1003: should use strings.ContainsAny(s, "*?[") instead
    • instead of strings.IndexAny(s, "*?[") >= 0
  • S1039: unnecessary use of fmt.Sprintf
    • example: msg := fmt.Sprintf("catmaster is incorrect")
  • S1019: should use make(map[string][]point) instead
    • instead of make(map[string][]point, 0)
  • S1023: redundant return statement
  • S1023: redundant break statement
  • S1025: the argument is already a string, there's no need to use fmt.Sprintf
    • example: fmt.Sprintf("%s", firstParseErrorStr)
  • S1005: unnecessary assignment to the blank identifier
    • exameple min, _ := f.values[statisticTypeMin]
  • S1004: should use bytes.Equal(value, []byte("No")) instead
    • instead of bytes.Compare(value, []byte("No")) == 0
  • S1021: should merge variable declaration with assignment on next line
  • S1009: should omit nil check; len() for nil slices is defined as zero
    • example: if rest == nil || len(rest) == 0 {
  • S1002: should omit comparison to bool constant, can be simplified to !ok
    • example: if ok == false {
  • S1034: assigning the result of this type assertion to a variable (switch i := i.(type)) could eliminate type assertions in switch cases
  • S1033: unnecessary guard around call to delete
  • S1008: should use return f.namePass.Match(key) instead of if f.namePass.Match(key) { return true }; return false
  • S1011: should replace loop with m.metrics = append(m.metrics, metrics...)
  • S1012: should use time.Since instead of time.Now().Sub

These need to be reviewed carefully and fixed in the near future:

  • S1007: should use raw string (...) with regexp.Compile to avoid having to escape twice
  • S1000: should use for range instead of for { select {} }
  • S1000: should use a simple channel send/receive instead of select with a single case

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!

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Mar 24, 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.

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

@helenosheaa helenosheaa merged commit 099ccda into influxdata:master Mar 25, 2021
jblesener pushed a commit to jblesener/telegraf that referenced this pull request Apr 18, 2021
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants