Skip to content

Commit 35b5670

Browse files
Laure-diremyleone
andauthored
chore: fix golangci-lint (scaleway#2507)
Co-authored-by: Rémy Léone <[email protected]>
1 parent 4452ad0 commit 35b5670

File tree

6 files changed

+32
-23
lines changed

6 files changed

+32
-23
lines changed

.github/workflows/golangci-lint.yml

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

.golangci.yml

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
# Golang CI pipeline configuration
33
#
44
# To execute linters in local the ./scripts/lint.sh script can be used.
5+
version: "2"
6+
formatters:
7+
enable:
8+
- gci # Gci controls golang package import order and makes it always deterministic. [fast: true, auto-fix: false]
9+
- 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]
10+
- gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
11+
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt. [fast: true, auto-fix: true]
512

613
linters:
7-
disable-all: true
8-
9-
# Run golangci-lint linters to see
14+
default: none
1015
enable:
1116
- asasalint # check for pass []any as any in variadic func(...any) [fast: false, auto-fix: false]
1217
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers [fast: true, auto-fix: false]
@@ -21,20 +26,15 @@ linters:
2126
- 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]
2227
- 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]
2328
- errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. [fast: false, auto-fix: false]
24-
- gci # Gci controls golang package import order and makes it always deterministic. [fast: true, auto-fix: false]
2529
- gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. [fast: true, auto-fix: false]
2630
- gochecksumtype # Run exhaustiveness checks on Go "sum types" [fast: false, auto-fix: false]
2731
- goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false]
2832
- gocritic # Provides diagnostics that check for bugs, performance and style issues. [fast: false, auto-fix: false]
2933
- gocyclo # Computes and checks the cyclomatic complexity of functions [fast: true, auto-fix: false]
30-
- 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]
31-
- gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
3234
- goheader # Checks is file header matches to pattern [fast: true, auto-fix: false]
33-
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt. [fast: true, auto-fix: true]
3435
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. [fast: true, auto-fix: false]
3536
- 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]
3637
- goprintffuncname # Checks that printf-like functions are named with `f` at the end [fast: true, auto-fix: false]
37-
- gosimple #(megacheck): Linter for Go source code that specializes in simplifying a code [fast: false, auto-fix: false]
3838
- grouper # An analyzer to analyze expression groups. [fast: true, auto-fix: false]
3939
- importas # Enforces consistent import aliases [fast: false, auto-fix: false]
4040
- ineffassign # Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
@@ -48,7 +48,6 @@ linters:
4848
- noctx # noctx finds sending http request without context.Context [fast: false, auto-fix: false]
4949
- nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false]
5050
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. [fast: true, auto-fix: false]
51-
- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. [fast: false, auto-fix: false]
5251
- prealloc # Finds slice declarations that could potentially be pre-allocated [fast: true, auto-fix: false]
5352
- predeclared # find code that shadows one of Go's predeclared identifiers [fast: true, auto-fix: false]
5453
- promlinter # Check Prometheus metrics naming via promlint [fast: true, auto-fix: false]
@@ -59,24 +58,33 @@ linters:
5958
- sloglint # ensure consistent code style when using log/slog [fast: false, auto-fix: false]
6059
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. [fast: false, auto-fix: false]
6160
- staticcheck #(megacheck): Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false]
62-
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 [fast: false, auto-fix: false]
6361
- testifylint # Checks usage of github.com/stretchr/testify. [fast: false, auto-fix: false]
6462
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers [fast: false, auto-fix: false]
6563
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes [fast: false, auto-fix: false]
66-
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: false, auto-fix: false]
6764
- unconvert # Remove unnecessary type conversions [fast: false, auto-fix: false]
6865
- unused #(megacheck): Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
6966
- usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. [fast: true, auto-fix: false]
7067
- wastedassign # wastedassign finds wasted assignment statements. [fast: false, auto-fix: false]
7168
- whitespace # Tool for detection of leading and trailing whitespace [fast: true, auto-fix: true]
7269
- zerologlint # Detects the wrong usage of `zerolog` that a user forgets to dispatch with `Send` or `Msg` [fast: false, auto-fix: false]
7370

71+
settings:
72+
revive:
73+
rules:
74+
- name: exported
75+
disabled: true
76+
77+
exclusions:
78+
rules:
79+
- path: _test\.go
80+
linters:
81+
- stylecheck
82+
- gosec
83+
- path: ^api/instance/v1/instance.*sdk\.go$
84+
linters:
85+
- unused
86+
- errcheck
87+
7488
issues:
7589
max-issues-per-linter: 0
7690
max-same-issues: 0
77-
78-
exclude-rules:
79-
- path: _test\.go
80-
linters:
81-
- stylecheck
82-
- gosec

api/edge_services/v1beta1/edge_services_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package edge_services //nolint:revive
1+
package edge_services
22

33
import (
44
"time"

api/instance/v1/instance_sdk_server_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func TestServerUpdate(t *testing.T) {
4848
serverID = createServerResponse.Server.ID
4949

5050
testhelpers.Assert(t, createServerResponse.Server != nil, "Should have server in response")
51-
testhelpers.Assert(t, 1 == len(createServerResponse.Server.Volumes), "should have exactly one volume because we didn't pass volumes map in the requests.")
51+
testhelpers.Assert(t, len(createServerResponse.Server.Volumes) == 1, "should have exactly one volume because we didn't pass volumes map in the requests.")
5252
for _, volume := range createServerResponse.Server.Volumes {
5353
volumeID = volume.ID
5454
}
@@ -109,7 +109,7 @@ func TestServerUpdate(t *testing.T) {
109109
testhelpers.Equals(t, bootType, updateServerResponse.Server.BootType)
110110
testhelpers.Equals(t, commercialType, updateServerResponse.Server.CommercialType)
111111
testhelpers.Equals(t, *dynamicIPRequired, updateServerResponse.Server.DynamicIPRequired)
112-
testhelpers.Assert(t, 1 == len(updateServerResponse.Server.Volumes), "should have exactly one volume because we didn't pass volumes map in the requests.")
112+
testhelpers.Assert(t, len(updateServerResponse.Server.Volumes) == 1, "should have exactly one volume because we didn't pass volumes map in the requests.")
113113

114114
testhelpers.Equals(t, newName, updateServerResponse.Server.Name)
115115
testhelpers.Equals(t, updatedTags, updateServerResponse.Server.Tags)
@@ -124,7 +124,7 @@ func TestServerUpdate(t *testing.T) {
124124
})
125125
testhelpers.AssertNoError(t, err)
126126
testhelpers.Assert(t, updateServerResponse.Server != nil, "Should have server in response")
127-
testhelpers.Assert(t, 0 == len(updateServerResponse.Server.Volumes), "volume should be detached from server.")
127+
testhelpers.Assert(t, len(updateServerResponse.Server.Volumes) == 0, "volume should be detached from server.")
128128
})
129129

130130
t.Run("cleanup server and volume", func(t *testing.T) {

api/ipam/v1/ipam_sdk.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ func NewAPI(client *scw.Client) *API {
456456
client: client,
457457
}
458458
}
459+
459460
func (s *API) Regions() []scw.Region {
460461
return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw}
461462
}

api/serverless_sqldb/v1alpha1/serverless_sqldb_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package serverless_sqldb //nolint:revive
1+
package serverless_sqldb
22

33
import (
44
"time"

0 commit comments

Comments
 (0)