Skip to content

Commit

Permalink
lint: gocritic (preferStringWriter)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Sep 16, 2024
1 parent ad41a1b commit 52bc301
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ linters-settings:
- equalFold #
- unnecessaryBlock #
- ptrToRefParam #
- preferStringWriter #
- stringXbytes #
- appendAssign #
- tooManyResultsChecker
Expand Down
22 changes: 11 additions & 11 deletions pkg/apiserver/controllers/v1/decisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func writeStartupDecisions(gctx *gin.Context, filters map[string][]string, dbFun

if needComma {
//respBuffer.Write([]byte(","))
gctx.Writer.Write([]byte(","))
gctx.Writer.WriteString(",")

Check warning on line 163 in pkg/apiserver/controllers/v1/decisions.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/controllers/v1/decisions.go#L163

Added line #L163 was not covered by tests
} else {
needComma = true
}
Expand Down Expand Up @@ -212,7 +212,7 @@ func writeDeltaDecisions(gctx *gin.Context, filters map[string][]string, lastPul

if needComma {
//respBuffer.Write([]byte(","))
gctx.Writer.Write([]byte(","))
gctx.Writer.WriteString(",")

Check warning on line 215 in pkg/apiserver/controllers/v1/decisions.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/controllers/v1/decisions.go#L215

Added line #L215 was not covered by tests
} else {
needComma = true
}
Expand Down Expand Up @@ -244,56 +244,56 @@ func (c *Controller) StreamDecisionChunked(gctx *gin.Context, bouncerInfo *ent.B
gctx.Writer.Header().Set("Content-Type", "application/json")
gctx.Writer.Header().Set("Transfer-Encoding", "chunked")
gctx.Writer.WriteHeader(http.StatusOK)
gctx.Writer.Write([]byte(`{"new": [`)) //No need to check for errors, the doc says it always returns nil
gctx.Writer.WriteString(`{"new": [`) //No need to check for errors, the doc says it always returns nil

Check warning on line 247 in pkg/apiserver/controllers/v1/decisions.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/controllers/v1/decisions.go#L247

Added line #L247 was not covered by tests

// if the blocker just started, return all decisions
if val, ok := gctx.Request.URL.Query()["startup"]; ok && val[0] == "true" {
// Active decisions
err := writeStartupDecisions(gctx, filters, c.DBClient.QueryAllDecisionsWithFilters)
if err != nil {
log.Errorf("failed sending new decisions for startup: %v", err)
gctx.Writer.Write([]byte(`], "deleted": []}`))
gctx.Writer.WriteString(`], "deleted": []}`)

Check warning on line 255 in pkg/apiserver/controllers/v1/decisions.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/controllers/v1/decisions.go#L255

Added line #L255 was not covered by tests
gctx.Writer.Flush()

return err
}

gctx.Writer.Write([]byte(`], "deleted": [`))
gctx.Writer.WriteString(`], "deleted": [`)

Check warning on line 261 in pkg/apiserver/controllers/v1/decisions.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/controllers/v1/decisions.go#L261

Added line #L261 was not covered by tests
//Expired decisions
err = writeStartupDecisions(gctx, filters, c.DBClient.QueryExpiredDecisionsWithFilters)
if err != nil {
log.Errorf("failed sending expired decisions for startup: %v", err)
gctx.Writer.Write([]byte(`]}`))
gctx.Writer.WriteString(`]}`)

Check warning on line 266 in pkg/apiserver/controllers/v1/decisions.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/controllers/v1/decisions.go#L266

Added line #L266 was not covered by tests
gctx.Writer.Flush()

return err
}

gctx.Writer.Write([]byte(`]}`))
gctx.Writer.WriteString(`]}`)

Check warning on line 272 in pkg/apiserver/controllers/v1/decisions.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/controllers/v1/decisions.go#L272

Added line #L272 was not covered by tests
gctx.Writer.Flush()
} else {
err = writeDeltaDecisions(gctx, filters, bouncerInfo.LastPull, c.DBClient.QueryNewDecisionsSinceWithFilters)
if err != nil {
log.Errorf("failed sending new decisions for delta: %v", err)
gctx.Writer.Write([]byte(`], "deleted": []}`))
gctx.Writer.WriteString(`], "deleted": []}`)

Check warning on line 278 in pkg/apiserver/controllers/v1/decisions.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/controllers/v1/decisions.go#L278

Added line #L278 was not covered by tests
gctx.Writer.Flush()

return err
}

gctx.Writer.Write([]byte(`], "deleted": [`))
gctx.Writer.WriteString(`], "deleted": [`)

Check warning on line 284 in pkg/apiserver/controllers/v1/decisions.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/controllers/v1/decisions.go#L284

Added line #L284 was not covered by tests

err = writeDeltaDecisions(gctx, filters, bouncerInfo.LastPull, c.DBClient.QueryExpiredDecisionsSinceWithFilters)

if err != nil {
log.Errorf("failed sending expired decisions for delta: %v", err)
gctx.Writer.Write([]byte(`]}`))
gctx.Writer.WriteString("]}")

Check warning on line 290 in pkg/apiserver/controllers/v1/decisions.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/controllers/v1/decisions.go#L290

Added line #L290 was not covered by tests
gctx.Writer.Flush()

return err
}

gctx.Writer.Write([]byte(`]}`))
gctx.Writer.WriteString("]}")

Check warning on line 296 in pkg/apiserver/controllers/v1/decisions.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/controllers/v1/decisions.go#L296

Added line #L296 was not covered by tests
gctx.Writer.Flush()
}

Expand Down

0 comments on commit 52bc301

Please sign in to comment.