Skip to content

Commit

Permalink
ci/lint: fixed several issues following golangci-lint update
Browse files Browse the repository at this point in the history
  • Loading branch information
mvisonneau committed Sep 27, 2024
1 parent 743310c commit c7351f9
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 71 deletions.
14 changes: 4 additions & 10 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
linters:
enable-all: true
disable:
# Deprecated ones
- golint
- ifshort
- interfacer
- maligned
- nosnakecase
- scopelint
# Deprecated
- gomnd

# We don't want these ones
- exhaustivestruct
- forcetypeassert
- gochecknoglobals
- godox
- goerr113
- ireturn
- nakedret
- testpackage
- varnamelen
- interfacebloat
- wsl

# TODO
- tagliatelle
Expand All @@ -29,7 +23,7 @@ linters:
- gomoddirectives
- forbidigo
- goconst
- gomnd
- mnd
- lll
- dupl
- depguard
Expand Down
31 changes: 0 additions & 31 deletions .revive.toml

This file was deleted.

1 change: 1 addition & 0 deletions pkg/controller/environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func (c *Controller) PullEnvironmentMetrics(ctx context.Context, env schemas.Env
if err = c.Store.GetMetric(ctx, &behindCommitsCountMetric); err != nil {
return err
}

envBehindCommitCount = behindCommitsCountMetric.Value
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func (c *Controller) ProcessJobMetrics(ctx context.Context, ref schemas.Ref, job

if jobRunCountExists && ((lastJob.ID != job.ID && jobTriggered) || (lastJob.ID == job.ID && jobTriggered && !lastJobTriggered)) {
storeGetMetric(ctx, c.Store, &jobRunCount)

jobRunCount.Value++
}

Expand Down
1 change: 1 addition & 0 deletions pkg/controller/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ func emitStatusMetric(ctx context.Context, s store.Store, metricKind schemas.Met

continue
}

statusMetric.Value = 0
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/gitlab/branches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ func TestGetProjectBranches(t *testing.T) {
assert.Equal(t, []string{"100"}, r.URL.Query()["per_page"])
currentPage, err := strconv.Atoi(r.URL.Query()["page"][0])
assert.NoError(t, err)

nextPage := currentPage + 1

if currentPage == 2 {
nextPage = currentPage
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/gitlab/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (c *Client) ReadinessCheck(ctx context.Context) healthcheck.Check {
return fmt.Errorf("HTTP error: empty response")
}

if err == nil && resp.StatusCode != 200 {
if err == nil && resp.StatusCode != http.StatusOK {
return fmt.Errorf("HTTP error: %d", resp.StatusCode)
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/monitor/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,14 @@ func (m *model) View() string {
// TABS
{
renderedTabs := []string{}

for tabID, t := range tabs {
if m.tabID == tabID {
renderedTabs = append(renderedTabs, activeTab.Render(string(t)))

continue
}

renderedTabs = append(renderedTabs, inactiveTab.Render(string(t)))
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/ratelimit/ratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

// Limiter ..
type Limiter interface {
Take(context.Context) time.Duration
Take(ctx context.Context) time.Duration
}

// Take ..
Expand Down
1 change: 1 addition & 0 deletions pkg/store/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ func (l *Local) UnqueueTask(_ context.Context, tt schemas.TaskType, uniqueID str
defer l.tasksMutex.Unlock()

delete(l.tasks[tt], uniqueID)

l.executedTasksCount++
}

Expand Down
56 changes: 28 additions & 28 deletions pkg/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@ import (

// Store ..
type Store interface {
SetProject(context.Context, schemas.Project) error
DelProject(context.Context, schemas.ProjectKey) error
GetProject(context.Context, *schemas.Project) error
ProjectExists(context.Context, schemas.ProjectKey) (bool, error)
Projects(context.Context) (schemas.Projects, error)
ProjectsCount(context.Context) (int64, error)
SetEnvironment(context.Context, schemas.Environment) error
DelEnvironment(context.Context, schemas.EnvironmentKey) error
GetEnvironment(context.Context, *schemas.Environment) error
EnvironmentExists(context.Context, schemas.EnvironmentKey) (bool, error)
Environments(context.Context) (schemas.Environments, error)
EnvironmentsCount(context.Context) (int64, error)
SetRef(context.Context, schemas.Ref) error
DelRef(context.Context, schemas.RefKey) error
GetRef(context.Context, *schemas.Ref) error
RefExists(context.Context, schemas.RefKey) (bool, error)
Refs(context.Context) (schemas.Refs, error)
RefsCount(context.Context) (int64, error)
SetMetric(context.Context, schemas.Metric) error
DelMetric(context.Context, schemas.MetricKey) error
GetMetric(context.Context, *schemas.Metric) error
MetricExists(context.Context, schemas.MetricKey) (bool, error)
Metrics(context.Context) (schemas.Metrics, error)
MetricsCount(context.Context) (int64, error)
SetProject(ctx context.Context, p schemas.Project) error
DelProject(ctx context.Context, pk schemas.ProjectKey) error
GetProject(ctx context.Context, p *schemas.Project) error
ProjectExists(ctx context.Context, pk schemas.ProjectKey) (bool, error)
Projects(ctx context.Context) (schemas.Projects, error)
ProjectsCount(ctx context.Context) (int64, error)
SetEnvironment(ctx context.Context, e schemas.Environment) error
DelEnvironment(ctx context.Context, ek schemas.EnvironmentKey) error
GetEnvironment(ctx context.Context, e *schemas.Environment) error
EnvironmentExists(ctx context.Context, ek schemas.EnvironmentKey) (bool, error)
Environments(ctx context.Context) (schemas.Environments, error)
EnvironmentsCount(ctx context.Context) (int64, error)
SetRef(ctx context.Context, r schemas.Ref) error
DelRef(ctx context.Context, rk schemas.RefKey) error
GetRef(ctx context.Context, r *schemas.Ref) error
RefExists(ctx context.Context, rk schemas.RefKey) (bool, error)
Refs(ctx context.Context) (schemas.Refs, error)
RefsCount(ctx context.Context) (int64, error)
SetMetric(ctx context.Context, m schemas.Metric) error
DelMetric(ctx context.Context, mk schemas.MetricKey) error
GetMetric(ctx context.Context, m *schemas.Metric) error
MetricExists(ctx context.Context, mk schemas.MetricKey) (bool, error)
Metrics(ctx context.Context) (schemas.Metrics, error)
MetricsCount(ctx context.Context) (int64, error)

// Helpers to keep track of currently queued tasks and avoid scheduling them
// twice at the risk of ending up with loads of dangling goroutines being locked
QueueTask(context.Context, schemas.TaskType, string, string) (bool, error)
UnqueueTask(context.Context, schemas.TaskType, string) error
CurrentlyQueuedTasksCount(context.Context) (uint64, error)
ExecutedTasksCount(context.Context) (uint64, error)
QueueTask(ctx context.Context, tt schemas.TaskType, taskUUID, processUUID string) (bool, error)
UnqueueTask(ctx context.Context, tt schemas.TaskType, taskUUID string) error
CurrentlyQueuedTasksCount(ctx context.Context) (uint64, error)
ExecutedTasksCount(ctx context.Context) (uint64, error)
}

// NewLocalStore ..
Expand Down

0 comments on commit c7351f9

Please sign in to comment.