Skip to content

Commit

Permalink
Fix Existing Lints (#51)
Browse files Browse the repository at this point in the history
Signed-off-by: Russell Troxel <[email protected]>
  • Loading branch information
rtrox authored Jan 2, 2024
1 parent e8abd6d commit 528f754
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
18 changes: 12 additions & 6 deletions internal/calibre/tasks/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ type importOutputCtxKey string

const importOutputKey importOutputCtxKey = "importOutput"

type identifierKey struct {
typ, val string
}

type importContext struct {
visitedAuthors map[int64]ksuid.ID
visitedTags map[int64]ksuid.ID
Expand Down Expand Up @@ -166,7 +162,12 @@ func ImportBooks(cal calibre.Calibre, client *ent.Client, ctx context.Context, c
Msg("Failed to create book")
ic.AddFailedBook(book.Title)
}
cb(float64(idx+1) / (float64(total)))
if err := cb(float64(idx+1) / (float64(total))); err != nil {
log.Warn().Err(err).
Str("book", book.Title).
Int64("bookID", book.ID).
Msg("Failed to update progress")
}
continue
}

Expand Down Expand Up @@ -217,7 +218,12 @@ func ImportBooks(cal calibre.Calibre, client *ent.Client, ctx context.Context, c
Int64("bookID", book.ID).
Msg("Failed to create series")
}
cb(float64(idx+1) / (float64(total)))
if err := cb(float64(idx+1) / (float64(total))); err != nil {
log.Warn().Err(err).
Str("book", book.Title).
Int64("bookID", book.ID).
Msg("Failed to update progress")
}
}

return nil
Expand Down
6 changes: 3 additions & 3 deletions internal/middleware/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Test_StructuredLogger(t *testing.T) {
{
name: "200 OK",
handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK"))
w.Write([]byte("OK")) // nolint: errcheck
w.WriteHeader(http.StatusOK)
}),
expectedFunc: func() map[string]interface{} {
Expand Down Expand Up @@ -72,7 +72,7 @@ func Test_StructuredLogger(t *testing.T) {

logLine := make(map[string]interface{})
require.NoError(
json.Unmarshal([]byte(out.String()), &logLine),
json.Unmarshal(out.Bytes(), &logLine),
)
require.NotEqual("", logLine["latency"])
for k, v := range tt.expectedFunc() {
Expand Down Expand Up @@ -153,7 +153,7 @@ func Test_StructeredLoggerPathLogging(t *testing.T) {
handle.ServeHTTP(httptest.NewRecorder(), httptest.NewRequest("GET", tt.path, nil))
logLine := make(map[string]interface{})
require.NoError(
json.Unmarshal([]byte(out.String()), &logLine),
json.Unmarshal(out.Bytes(), &logLine),
)
require.Equal(tt.path, logLine["path"])
})
Expand Down
2 changes: 1 addition & 1 deletion internal/middleware/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Test_PrometheusMiddleware(t *testing.T) {
{
name: "200 OK",
handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK"))
w.Write([]byte("OK")) // nolint: errcheck
w.WriteHeader(http.StatusOK)
}),
expectedMetrics: []string{
Expand Down
2 changes: 1 addition & 1 deletion internal/task/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestSchedulerSchedule(t *testing.T) {
require.NoError(err)

require.NotPanics(func() {
s.Schedule(ctx)
require.NoError(s.Schedule(ctx))
})

select {
Expand Down
4 changes: 3 additions & 1 deletion internal/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func (t *concurrentTaskMap) RegisterTasks(taskMap TaskMap) {
func NoOpTask(ctx context.Context, task *ent.Task, cb ProgressCallback) (msg string, err error) {
log := log.Ctx(ctx)
log.Info().Interface("task", task).Msg("NoOpTask")
cb(1)
if err := cb(1); err != nil {
return "", err
}
return "done", nil
}
2 changes: 1 addition & 1 deletion internal/tests/task_privacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func Test_UpdateSystemTask(t *testing.T) {
SetType(task_enums.TypeNoOp).
SetIsSystemTask(true).
SaveX(adminCtx)
task, err := task.Update().
_, err := task.Update().
SetProgress(0.5).
Save(tt.updaterContext(data))
if tt.shouldUpdate {
Expand Down

0 comments on commit 528f754

Please sign in to comment.