Skip to content

Commit

Permalink
linter: update golangci-lint and lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
joelrebel committed Apr 4, 2024
1 parent 6b1fc62 commit 3d814c7
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 29 deletions.
26 changes: 14 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
golangci-lint-version: 1.50.0 # use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: v1.56.2 # use the fixed version to not introduce new linters unexpectedly

linters-settings:
govet:
enable:
- fieldalignment
auto-fix: true
check-shadowing: true
settings:
Expand All @@ -19,7 +17,7 @@ linters-settings:
revive:
min-confidence: 0
gocyclo:
min-complexity: 11
min-complexity: 15
dupl:
threshold: 100
goconst:
Expand Down Expand Up @@ -47,6 +45,8 @@ linters-settings:
- wrapperFunc
gofumpt:
extra-rules: true
whitespace:
auto-fix: true

linters:
enable:
Expand All @@ -71,13 +71,21 @@ linters:
- misspell
- noctx
- stylecheck
- whitespace
- gosec
- contextcheck
- durationcheck
- errchkjson
- errorlint
- gochecksumtype
- nilerr
- reassign
- whitespace
- exportloopref
enable-all: false
disable-all: true

run:
# build-tags:
# build-tags:
skip-dirs:
- internal/fixtures
skip-files:
Expand All @@ -92,10 +100,6 @@ issues:
- linters:
- stylecheck
text: "ST1016"

- linters:
- stylecheck
text: "ST1003"
exclude:
# Default excludes from `golangci-lint run --help` with EXC0002 removed
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
Expand All @@ -119,5 +123,3 @@ issues:
# EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
- Potential file inclusion via variable
exclude-use-default: false


2 changes: 1 addition & 1 deletion cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
var cmdExportStatemachine = &cobra.Command{
Use: "export-statemachine --task|--action [--json|--mermaid]",
Short: "Export a JSON dump of flasher statemachine(s) - writes to a file task-statemachine.json",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
exportStatemachine()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
var cmdInstall = &cobra.Command{
Use: "install",
Short: "Install given firmware for a component",
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
runInstall(cmd.Context())
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
var cmdRun = &cobra.Command{
Use: "run",
Short: "Run flasher service to listen for events and install firmware",
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
runWorker(cmd.Context())
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
var cmdVersion = &cobra.Command{
Use: "version",
Short: "Print Flasher version along with dependency information.",
Run: func(_ *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
fmt.Printf(
"commit: %s\nbranch: %s\ngit summary: %s\nbuildDate: %s\nversion: %s\nGo version: %s\nbmclib version: %s\nFleetDB API version: %s",
version.GitCommit, version.GitBranch, version.GitSummary, version.BuildDate, version.AppVersion, version.GoVersion, version.BmclibVersion, version.FleetDBAPIVersion)
Expand Down
2 changes: 1 addition & 1 deletion internal/install/task_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (t *handler) RunActions(ctx context.Context) error {
}).Debug("action state machine start")

// run the action state machine
err := actionSM.Run(t.ctx.Ctx, action, t.ctx)
err := actionSM.Run(ctx, action, t.ctx)
if err != nil {
return errors.Wrap(
err,
Expand Down
1 change: 1 addition & 0 deletions internal/outofband/action_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ func (h *actionHandler) pollFirmwareTaskStatus(a sw.StateSwitch, c sw.Transition
action.Firmware.Vendor,
action.Firmware.Models,
)
// nolint:errorlint // TODO(joel): rework this to use errors.Is
switch err {
case nil:
tctx.Logger.WithFields(
Expand Down
1 change: 1 addition & 0 deletions internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func (r *Runner) conditionalFault(fname string, task *model.Task, handler Handle
td, err := time.ParseDuration(task.Fault.DelayDuration)
if err != nil {
// invalid duration string is ignored
// nolint:nilerr // nil error returned intentionally
return nil
}

Expand Down
12 changes: 0 additions & 12 deletions internal/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"sync"
"time"

"github.com/google/uuid"
"github.com/metal-toolbox/flasher/internal/model"
Expand All @@ -25,17 +24,6 @@ const (
)

var (
fetchEventsInterval = 10 * time.Second

// taskTimeout defines the time after which a task will be canceled.
taskTimeout = 180 * time.Minute

// taskInprogressTicker is the interval at which tasks in progress
// will ack themselves as in progress on the event stream.
//
// This value should be set to less than the event stream Ack timeout value.
taskInprogressTick = 3 * time.Minute

errTaskFirmwareParam = errors.New("error in task firmware parameters")
errInitTask = errors.New("error initializing new task from condition")
)
Expand Down

0 comments on commit 3d814c7

Please sign in to comment.