Browse Source

Some linter cleanup

pull/1496/head
Gabe Kangas 4 years ago
parent
commit
bdce2e13bf
  1. 38
      .golangci.yml
  2. 2
      core/chat/chatclient.go
  3. 2
      core/chat/events.go
  4. 1
      core/chat/utils.go
  5. 4
      core/transcoder/thumbnailGenerator.go
  6. 5
      core/transcoder/transcoder.go
  7. 2
      utils/performanceTimer.go

38
.golangci.yml

@ -40,8 +40,44 @@ linters: @@ -40,8 +40,44 @@ linters:
- unconvert
- unparam
- whitespace
- nakedret
- cyclop
- gosimple
- varcheck
- unused
- deadcode
- exportloopref
- gocritic
- forbidigo
- unparam
- wastedassign
linters-settings:
govet:
disable:
- composite
cyclop:
# the maximal code complexity to report. default is 10. eventually work our way to that.
max-complexity: 20
# the max average package complexity. If it's higher than 0.0 (float) the check is enabled (default 0.0)
package-average: 0.0
# should ignore tests
skip-tests: true
gosimple:
# Select the Go version to target. The default is '1.13'.
go: "1.17"
# https://staticcheck.io/docs/options#checks
checks: ["all"]
gocritic:
disabled-checks:
- ifElseChain
- exitAfterDefer
forbidigo:
# Forbid the following identifiers (identifiers are written using regexp):
forbid:
# Logging via Print bypasses our logging framework.
- ^(fmt\.Print(|f|ln)|print|println)
- ^panic.*$

2
core/chat/chatclient.go

@ -118,7 +118,7 @@ func (c *Client) readPump() { @@ -118,7 +118,7 @@ func (c *Client) readPump() {
continue
}
message = bytes.TrimSpace(bytes.Replace(message, newline, space, -1))
message = bytes.TrimSpace(bytes.ReplaceAll(message, newline, space))
c.handleEvent(message)
}
}

2
core/chat/events.go

@ -111,6 +111,6 @@ func (s *Server) userMessageSent(eventData chatClientEvent) { @@ -111,6 +111,6 @@ func (s *Server) userMessageSent(eventData chatClientEvent) {
SaveUserMessage(event)
eventData.client.MessageCount = eventData.client.MessageCount + 1
eventData.client.MessageCount++
_lastSeenCache[event.User.ID] = time.Now()
}

1
core/chat/utils.go

@ -2,6 +2,7 @@ package chat @@ -2,6 +2,7 @@ package chat
import (
"syscall"
log "github.com/sirupsen/logrus"
)

4
core/transcoder/thumbnailGenerator.go

@ -132,10 +132,8 @@ func makeAnimatedGifPreview(sourceFile string, outputFile string) { @@ -132,10 +132,8 @@ func makeAnimatedGifPreview(sourceFile string, outputFile string) {
ffmpegCmd := strings.Join(animatedGifFlags, " ")
if _, err := exec.Command("sh", "-c", ffmpegCmd).Output(); err != nil {
log.Errorln(err)
} else {
// rename temp file
if err := os.Rename(outputFileTemp, outputFile); err != nil {
} else if err := os.Rename(outputFileTemp, outputFile); err != nil {
log.Errorln(err)
}
}
}

5
core/transcoder/transcoder.go

@ -284,9 +284,8 @@ func (t *Transcoder) getVariantsString() string { @@ -284,9 +284,8 @@ func (t *Transcoder) getVariantsString() string {
for _, variant := range t.variants {
variantsCommandFlags = variantsCommandFlags + " " + variant.getVariantString(t)
singleVariantMap := ""
singleVariantMap = fmt.Sprintf("v:%d,a:%d ", variant.index, variant.index)
variantsStreamMaps = variantsStreamMaps + singleVariantMap
singleVariantMap := fmt.Sprintf("v:%d,a:%d ", variant.index, variant.index)
variantsStreamMaps += singleVariantMap
}
variantsCommandFlags = variantsCommandFlags + " " + variantsStreamMaps + "\""

2
utils/performanceTimer.go

@ -52,7 +52,7 @@ func removeHighValue(values []float64) []float64 { @@ -52,7 +52,7 @@ func removeHighValue(values []float64) []float64 {
func avg(values []float64) float64 {
total := 0.0
for _, number := range values {
total = total + number
total += number
}
average := total / float64(len(values))
return average

Loading…
Cancel
Save