Skip to content

Commit

Permalink
chore: Bump golangci-lint from v1.45.2 → v1.55.2 (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
irvinlim authored Feb 17, 2024
1 parent 98148bc commit 4a40039
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 57 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
- id: get-golangci-lint-version
name: Get golangci-lint version
run: echo "GOLANGCI_LINT_VERSION=$(grep '^GOLANGCI_LINT_VERSION' Makefile | cut -d' ' -f3)" >> "$GITHUB_OUTPUT"
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2.5.2
with:
version: v1.45.2
version: ${{ steps.get-golangci-lint-version.outputs.GOLANGCI_LINT_VERSION }}
args: --timeout=5m

generate-lint:
Expand Down
19 changes: 13 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,28 @@ linters-settings:

issues:
exclude-rules:
# Add default exclusions for test files.
- path: '(.+)_test\.go'
linters:
- dupl
- gocognit
- gocyclo
- dupl

# Excludes nil error return unparam checks.
- text: "result .* is always nil"
linters:
- unparam

# Excludes "always receives" unparam checks for test files.
- path: '(.+)_test\.go'
text: "`.*` always receives `.*`"
linters:
- unparam

linters:
enable:
- asciicheck
- bodyclose
- deadcode
- depguard
- dupl
- errcheck
- exportloopref
Expand All @@ -42,15 +52,12 @@ linters:
- nakedret
- noctx
- prealloc
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
25 changes: 14 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -217,26 +217,26 @@ LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN): ## Ensure that the directory exists
mkdir -p $(LOCALBIN)

## Tool Versions
KUSTOMIZE_VERSION ?= v4.5.5
CONTROLLER_TOOLS_VERSION ?= v0.8.0
YQ_VERSION ?= v4.14.1
GOIMPORTS_REVISER_VERSION ?= 32c80678d5d73a50b6966f06b346de58b1d018f1
GOLANGCI_LINT_VERSION ?= v1.55.2
LICENSEHEADERCHECKER_VERSION ?= v1.3.0
GORELEASER_VERSION ?= v1.8.2

## Tool Binaries
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
GOIMPORTS ?= $(LOCALBIN)/goimports
GOIMPORTS_REVISER ?= $(LOCALBIN)/goimports-reviser
YQ ?= $(LOCALBIN)/yq
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint@$(GOLANGCI_LINT_VERSION)
LICENSE_HEADER_CHECKER ?= $(LOCALBIN)/license-header-checker
GORELEASER ?= $(LOCALBIN)/goreleaser

## Tool Versions
KUSTOMIZE_VERSION ?= v4.5.5
CONTROLLER_TOOLS_VERSION ?= v0.8.0
YQ_VERSION ?= v4.14.1
GOIMPORTS_REVISER_VERSION ?= 32c80678d5d73a50b6966f06b346de58b1d018f1
GOLANGCILINT_VERSION ?= v1.45.2
LICENSEHEADERCHECKER_VERSION ?= v1.3.0
GORELEASER_VERSION ?= v1.8.2

.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN):
Expand Down Expand Up @@ -272,7 +272,10 @@ GOLANGCILINT_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/golangci/golan
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT):
@[ -f $(GOLANGCI_LINT) ] || curl -sSfL $(GOLANGCILINT_INSTALL_SCRIPT) | sh -s $(GOLANGCILINT_VERSION)
# Downloads to ./bin/golangci-lint.
@[ -f $(GOLANGCI_LINT) ] || curl -sSfL $(GOLANGCILINT_INSTALL_SCRIPT) | sh -s $(GOLANGCI_LINT_VERSION)
# Move to versioned path.
mv ./bin/golangci-lint $(GOLANGCI_LINT)

.PHONY: goreleaser
goreleaser: $(GORELEASER) ## Download goreleaser locally if necessary.
Expand Down
1 change: 0 additions & 1 deletion pkg/cli/cmd/cmd_disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ var (

type DisableCommand struct {
streams *streams.Streams
name string
}

func NewDisableCommand(streams *streams.Streams) *cobra.Command {
Expand Down
1 change: 0 additions & 1 deletion pkg/cli/cmd/cmd_enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ var (

type EnableCommand struct {
streams *streams.Streams
name string
}

func NewEnableCommand(streams *streams.Streams) *cobra.Command {
Expand Down
1 change: 0 additions & 1 deletion pkg/cli/cmd/cmd_kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ var (

type KillCommand struct {
streams *streams.Streams
name string
override bool
killAt time.Time
}
Expand Down
17 changes: 0 additions & 17 deletions pkg/execution/controllers/croncontroller/cron_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"k8s.io/utils/clock"
utiltrace "k8s.io/utils/trace"

configv1alpha1 "github.com/furiko-io/furiko/apis/config/v1alpha1"
execution "github.com/furiko-io/furiko/apis/execution/v1alpha1"
"github.com/furiko-io/furiko/pkg/config"
"github.com/furiko-io/furiko/pkg/execution/util/cronschedule"
Expand Down Expand Up @@ -266,22 +265,6 @@ func (w *CronWorker) syncOne(now time.Time, key string, ts time.Time, counts map
return nil
}

// getTimezone returns the timezone for the given JobConfig.
func (w *CronWorker) getTimezone(cronSchedule *execution.CronSchedule, cfg *configv1alpha1.CronExecutionConfig) string {
// Read from spec.
if cronSchedule.Timezone != "" {
return cronSchedule.Timezone
}

// Use default timezone from config.
if tz := cfg.DefaultTimezone; tz != nil && len(*tz) > 0 {
return *tz
}

// Fallback to controller default.
return defaultTimezone
}

type enqueueHandler struct {
*Context
}
Expand Down
7 changes: 0 additions & 7 deletions pkg/execution/controllers/croncontroller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ import (
"github.com/furiko-io/furiko/pkg/utils/cmp"
)

const (
// defaultTimezone is the default timezone value that will be used if there is
// no timezone configuration for the JobConfig or a default value set for the
// controller.
defaultTimezone = "UTC"
)

// IsScheduleEqual returns true if the ScheduleSpec is not equal and should be updated.
// This equality check is only true in the context of the CronController.
func IsScheduleEqual(orig, updated *execution.ScheduleSpec) (bool, error) {
Expand Down
1 change: 0 additions & 1 deletion pkg/execution/controllers/jobqueuecontroller/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ type JobControlInterface interface {
type JobControl struct {
client executionv1alpha1.ExecutionV1alpha1Interface
recorder record.EventRecorder
name string
}

var _ JobControlInterface = (*JobControl)(nil)
Expand Down
4 changes: 2 additions & 2 deletions pkg/execution/taskexecutor/podtaskexecutor/pod_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ func TestNewPodTaskClient(t *testing.T) {
}

func getPodIndexedName(name string, index int64) string {
name, err := jobutil.GenerateTaskName(fakeJob.Name, tasks.TaskIndex{
taskName, err := jobutil.GenerateTaskName(name, tasks.TaskIndex{
Retry: index,
})
if err != nil {
panic(err)
}
return name
return taskName
}
1 change: 1 addition & 0 deletions pkg/execution/util/job/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func GetCondition(rj *execution.Job) (execution.JobCondition, error) {
// Compute latest timestamps across all tasks.
var latestCreated, latestRunning, latestFinished *metav1.Time
for _, task := range rj.Status.Tasks {
task := task
latestCreated = ktime.TimeMax(latestCreated, &task.CreationTimestamp)
latestRunning = ktime.TimeMax(latestRunning, task.RunningTimestamp)
latestFinished = ktime.TimeMax(latestFinished, task.FinishTimestamp)
Expand Down
5 changes: 2 additions & 3 deletions pkg/execution/util/job/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ var (

type stubTask struct {
metav1.ObjectMeta
taskRef v1alpha1.TaskRef
retryIndex int64
killable bool
taskRef v1alpha1.TaskRef
killable bool
}

func (t *stubTask) GetName() string {
Expand Down
5 changes: 3 additions & 2 deletions pkg/runtime/httphandler/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ func ListenAndServeWebhooks(

mux := http.NewServeMux()
server := newTLSServer(&http.Server{
Addr: addr,
Handler: mux,
Addr: addr,
Handler: mux,
ReadHeaderTimeout: 10 * time.Second,
}, config.TLSCertFile, config.TLSPrivateKeyFile)

ServeWebhooks(mux, webhooks)
Expand Down
6 changes: 4 additions & 2 deletions pkg/runtime/httphandler/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package httphandler
import (
"context"
"net/http"
"time"

"github.com/prometheus/client_golang/prometheus"

Expand All @@ -35,8 +36,9 @@ type Server struct {
func NewServer(addr string) *Server {
mux := http.NewServeMux()
server := &http.Server{
Addr: addr,
Handler: mux,
Addr: addr,
Handler: mux,
ReadHeaderTimeout: 10 * time.Second,
}

return &Server{
Expand Down
3 changes: 1 addition & 2 deletions pkg/runtime/testing/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (r *ReconcilerTest) RunTestCase(t testinginterface.T, tt ReconcilerTestCase
recon := r.ReconcilerFunc(ctrlContext)

// Initialize fixtures.
target, err := r.initClientset(ctx, c.MockClientsets(), tt, ctrlContext.GetHasSynced())
target, err := r.initClientset(ctx, c.MockClientsets(), tt)
if err != nil {
t.Fatalf("cannot initialize fixtures: %v", err)
}
Expand Down Expand Up @@ -230,7 +230,6 @@ func (r *ReconcilerTest) initClientset(
ctx context.Context,
client *mock.Clientsets,
tt ReconcilerTestCase,
hasSynced []cache.InformerSynced,
) (runtime.Object, error) {
// Set up all fixtures.
fixtures := tt.Fixtures
Expand Down

0 comments on commit 4a40039

Please sign in to comment.