Skip to content

Commit 1d1d35a

Browse files
Laure-didependabot[bot]scaleway-botjremy42devtools-ci-cd
authored
chore: update linter (#4643)
Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Olivier Cano <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Scaleway Bot <[email protected]> Co-authored-by: Jonathan R. <[email protected]> Co-authored-by: devtools-ci-cd <[email protected]> Co-authored-by: Rémy Léone <[email protected]> Co-authored-by: Yacine Fodil <[email protected]> Co-authored-by: Olivier Cano <[email protected]>
1 parent 34a932e commit 1d1d35a

File tree

266 files changed

+13109
-3028
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

266 files changed

+13109
-3028
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v4
1111
- name: golangci-lint
12-
uses: golangci/golangci-lint-action@v6
12+
uses: golangci/golangci-lint-action@v7
1313
with:
1414
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
1515
version: latest

.golangci.yml

Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@
22
# Golang CI pipeline configuration
33
#
44
# To execute linters in local the ./scripts/lint.sh script can be used.
5+
version: "2"
6+
7+
formatters:
8+
enable:
9+
- gci # Gci controls golang package import order and makes it always deterministic. [fast: true, auto-fix: false]
10+
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true]
11+
- gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
12+
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt. [fast: true, auto-fix: true]
13+
- golines
514

615
linters:
16+
default: none
717
# Run golangci-lint linters to see the list of all linters
818
# Please keep them sorted alphabetically
919
enable:
@@ -16,25 +26,18 @@ linters:
1626
- decorder # check declaration order and count of types, constants, variables and functions [fast: true, auto-fix: false]
1727
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false]
1828
- durationcheck # check for two durations multiplied together [fast: false, auto-fix: false]
19-
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: false, auto-fix: false]
2029
- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted. [fast: false, auto-fix: false]
2130
- errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. [fast: false, auto-fix: false]
2231
- exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. [auto-fix]
23-
- gci # Gci controls golang package import order and makes it always deterministic. [fast: true, auto-fix: false]
2432
- gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. [fast: true, auto-fix: false]
2533
- gochecksumtype # Run exhaustiveness checks on Go "sum types" [fast: false, auto-fix: false]
2634
- goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false]
2735
- gocritic # Provides diagnostics that check for bugs, performance and style issues. [fast: false, auto-fix: false]
2836
- gocyclo # Computes and checks the cyclomatic complexity of functions [fast: true, auto-fix: false]
29-
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true]
30-
- gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
3137
- goheader # Checks is file header matches to pattern [fast: true, auto-fix: false]
32-
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt. [fast: true, auto-fix: true]
3338
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. [fast: true, auto-fix: false]
3439
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations. [fast: true, auto-fix: false]
3540
- goprintffuncname # Checks that printf-like functions are named with `f` at the end [fast: true, auto-fix: false]
36-
- gosec #(gas): Inspects source code for security problems [fast: false, auto-fix: false]
37-
- gosimple #(megacheck): Linter for Go source code that specializes in simplifying a code [fast: false, auto-fix: false]
3841
- govet #(vet, vetshadow): Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: false, auto-fix: false]
3942
- grouper # An analyzer to analyze expression groups. [fast: true, auto-fix: false]
4043
- importas # Enforces consistent import aliases [fast: false, auto-fix: false]
@@ -59,14 +62,11 @@ linters:
5962
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false]
6063
- rowserrcheck # checks whether Err of rows is checked successfully [fast: false, auto-fix: false]
6164
- sloglint # ensure consistent code style when using log/slog [fast: false, auto-fix: false]
62-
- staticcheck
63-
- stylecheck # Stylecheck is a replacement for golint [fast: false, auto-fix: false]
6465
- tagalign # check that struct tags are well aligned [fast: true, auto-fix: true]
6566
- testifylint # Checks usage of github.com/stretchr/testify. [fast: false, auto-fix: false]
6667
- testpackage # linter that makes you use a separate _test package [fast: true, auto-fix: false]
6768
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers [fast: false, auto-fix: false]
6869
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes [fast: false, auto-fix: false]
69-
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: false, auto-fix: false]
7070
- unconvert # Remove unnecessary type conversions [fast: false, auto-fix: false]
7171
- unparam # Reports unused function parameters [fast: false, auto-fix: false]
7272
- unused #(megacheck): Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
@@ -76,42 +76,22 @@ linters:
7676
- whitespace # Tool for detection of leading and trailing whitespace [fast: true, auto-fix: true]
7777
- zerologlint # Detects the wrong usage of `zerolog` that a user forgets to dispatch with `Send` or `Msg` [fast: false, auto-fix: false]
7878

79-
disable:
80-
- cyclop # checks function and package cyclomatic complexity [fast: false, auto-fix: false]
81-
- depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false]
82-
- dupl # Tool for code clone detection [fast: true, auto-fix: false]
83-
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. [fast: false, auto-fix: false]
84-
- exhaustive # check exhaustiveness of enum switch statements [fast: false, auto-fix: false]
85-
- forcetypeassert # finds forced type assertions [fast: true, auto-fix: false]
86-
- funlen # Tool for detection of long functions [fast: true, auto-fix: false]
87-
- gochecknoglobals # check that no global variables exist [fast: true, auto-fix: false]
88-
- gochecknoinits # Checks that no init functions are present in Go code [fast: true, auto-fix: false]
89-
- gocognit # Computes and checks the cognitive complexity of functions [fast: true, auto-fix: false]
90-
- godot # Check if comments end in a period [fast: true, auto-fix: true]
91-
- godox # Tool for detection of FIXME, TODO and other comment keywords [fast: true, auto-fix: false]
92-
- err113 # Golang linter to check the errors handling expressions [fast: false, auto-fix: false]
93-
- lll # Reports long lines [fast: true, auto-fix: false]
94-
- maintidx # maintidx measures the maintainability index of each function. [fast: true, auto-fix: false]
95-
- nestif # Reports deeply nested if statements [fast: true, auto-fix: false]
96-
- nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value. [fast: false, auto-fix: false]
97-
- varnamelen # checks that the length of a variable's name matches its scope [fast: false, auto-fix: false]
98-
- wsl # Whitespace Linter - Forces you to use empty lines! [fast: true, auto-fix: false]
79+
settings:
80+
goconst:
81+
min-len: 5
82+
gosec:
83+
excludes:
84+
- G115
85+
revive:
86+
rules:
87+
- name: exported
88+
disabled: true
9989

100-
linters-settings:
101-
goconst:
102-
min-len: 5
103-
gosec:
104-
excludes:
105-
- G115
90+
exclusions:
91+
paths:
92+
- internal/pkg
10693

107-
issues:
108-
exclude-dirs:
109-
- internal/pkg
110-
111-
max-issues-per-linter: 0
112-
max-same-issues: 0
113-
114-
exclude-rules:
94+
rules:
11595
- path: _test\.go
11696
linters:
11797
- stylecheck
@@ -156,3 +136,7 @@ issues:
156136
- path: internal/namespaces/k8s/v1/types/types.go
157137
linters:
158138
- tagalign
139+
140+
issues:
141+
max-issues-per-linter: 0
142+
max-same-issues: 0

cmd/scw-wasm-tester/human.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
package main
44

55
import (
6-
"syscall/js"
7-
86
"github.com/hashicorp/go-version"
97
"github.com/scaleway/scaleway-cli/v2/core"
108
"github.com/scaleway/scaleway-cli/v2/core/human"
9+
"syscall/js"
1110
)
1211

1312
func wasmTestMarshalBuildInfo(_ js.Value, _ []js.Value) any {

cmd/scw-wasm-tester/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
package main
44

55
import (
6-
"syscall/js"
7-
86
"github.com/scaleway/scaleway-cli/v2/internal/jshelpers"
7+
"syscall/js"
98
)
109

1110
type jsFunction func(js.Value, []js.Value) any

cmd/scw-wasm-tester/slices.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
package main
44

55
import (
6-
"syscall/js"
7-
86
"github.com/scaleway/scaleway-cli/v2/internal/jshelpers"
7+
"syscall/js"
98
)
109

1110
func wasmTestFromSlice(_ js.Value, _ []js.Value) any {

cmd/scw-wasm/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ package main
55
import (
66
"runtime"
77
"runtime/debug"
8-
"syscall/js"
98

109
"github.com/hashicorp/go-version"
1110
"github.com/scaleway/scaleway-cli/v2/core"
1211
"github.com/scaleway/scaleway-cli/v2/internal/jshelpers"
1312
"github.com/scaleway/scaleway-cli/v2/internal/wasm"
13+
"syscall/js"
1414
)
1515

1616
var (
@@ -62,7 +62,10 @@ func main() {
6262
if args.targetObject != "" {
6363
cliPackage := js.ValueOf(map[string]any{})
6464
cliPackage.Set("run", js.FuncOf(jshelpers.AsPromise(wasm.RunWithBuildInfo(buildInfo))))
65-
cliPackage.Set("complete", js.FuncOf(jshelpers.AsPromise(wasm.AutocompleteWithBuildInfo(buildInfo))))
65+
cliPackage.Set(
66+
"complete",
67+
js.FuncOf(jshelpers.AsPromise(wasm.AutocompleteWithBuildInfo(buildInfo))),
68+
)
6669
cliPackage.Set("configureOutput", js.FuncOf(jshelpers.AsPromise(wasm.ConfigureOutput)))
6770
cliPackage.Set("stop", js.FuncOf(jshelpers.AsyncJsFunc(stop)))
6871
js.Global().Set(args.targetObject, cliPackage)

cmd/scw-wasm/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ package main
44

55
import (
66
"fmt"
7-
"syscall/js"
87

98
"github.com/scaleway/scaleway-cli/v2/core"
109
"github.com/scaleway/scaleway-cli/v2/internal/jshelpers"
1110
"github.com/scaleway/scaleway-cli/v2/internal/wasm"
11+
"syscall/js"
1212
)
1313

1414
func wasmRun(this js.Value, args []js.Value) (any, error) {

cmd/scw/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ func main() {
7070

7171
func mainNoExit() int {
7272
buildInfo := &core.BuildInfo{
73-
Version: version.Must(version.NewSemver(buildVersion())), // panic when version does not respect semantic versioning
73+
Version: version.Must(
74+
version.NewSemver(buildVersion()),
75+
), // panic when version does not respect semantic versioning
7476
BuildDate: BuildDate,
7577
GoVersion: GoVersion,
7678
GitBranch: GitBranch,

core/arg_file_content.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ func loadArgsFileContent(cmd *Command, cmdArgs interface{}) error {
1919
}
2020

2121
fieldName := strcase.ToPublicGoName(argSpec.Name)
22-
fieldValues, err := GetValuesForFieldByName(reflect.ValueOf(cmdArgs), strings.Split(fieldName, "."))
22+
fieldValues, err := GetValuesForFieldByName(
23+
reflect.ValueOf(cmdArgs),
24+
strings.Split(fieldName, "."),
25+
)
2326
if err != nil {
2427
continue
2528
}

core/arg_specs.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ func (s ArgSpecs) GetPositionalArg() *ArgSpec {
2121
for _, argSpec := range s {
2222
if argSpec.Positional {
2323
if positionalArg != nil {
24-
panic(fmt.Errorf("more than one positional parameter detected: %s and %s are flagged as positional arg", positionalArg.Name, argSpec.Name))
24+
panic(
25+
fmt.Errorf(
26+
"more than one positional parameter detected: %s and %s are flagged as positional arg",
27+
positionalArg.Name,
28+
argSpec.Name,
29+
),
30+
)
2531
}
2632
positionalArg = argSpec
2733
}

0 commit comments

Comments
 (0)