Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update golanci-lint version and fix warnings #990

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
go-version: ["1.18", "1.19", "1.20", "1.21", "1.22"]
go-version: ["1.18", "1.19", "1.20", "1.21", "1.22", "1.23"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand All @@ -18,20 +18,19 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
- name: Install project tools and dependencies
if: ${{ matrix.go-version != '1.18' }}
if: ${{ matrix.go-version == '1.23' }}
run: make project-tools
- name: Lint
if: ${{ matrix.go-version != '1.18' }}
if: ${{ matrix.go-version == '1.23' }}
run: |
make lint
scripts/check-sync-tidy.sh
- name: Lint scripts
if: ${{ matrix.go-version == '1.22' }}
if: ${{ matrix.go-version == '1.23' }}
run: |
make lint-scripts
- name: Test
run: make test
- name: Test scripts
if: ${{ matrix.go-version == '1.22' }}
run: |
make test-scripts
if: ${{ matrix.go-version >= '1.22' }}
run: make test-scripts
11 changes: 5 additions & 6 deletions core/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ func SetupAuth(cfg *config.Configuration) (rt http.RoundTripper, err error) {
return nil, fmt.Errorf("configuring token authentication: %w", err)
}
return tokenRoundTripper, nil
} else {
authRoundTripper, err := DefaultAuth(cfg)
if err != nil {
return nil, fmt.Errorf("configuring default authentication: %w", err)
}
return authRoundTripper, nil
}
authRoundTripper, err := DefaultAuth(cfg)
if err != nil {
return nil, fmt.Errorf("configuring default authentication: %w", err)
}
return authRoundTripper, nil
}

// DefaultAuth will search for a valid service account key or token in several locations.
Expand Down
2 changes: 1 addition & 1 deletion core/clients/key_flow_continuous_refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestContinuousRefreshToken(t *testing.T) {
}

numberDoCalls := 0
mockDo := func(req *http.Request) (resp *http.Response, err error) {
mockDo := func(_ *http.Request) (resp *http.Response, err error) {
numberDoCalls++

if tt.doError != nil {
Expand Down
2 changes: 1 addition & 1 deletion core/clients/key_flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestRequestToken(t *testing.T) {

for _, tt := range testCases {
t.Run(tt.name, func(t *testing.T) {
mockDo := func(req *http.Request) (resp *http.Response, err error) {
mockDo := func(_ *http.Request) (resp *http.Response, err error) {
return tt.mockResponse, tt.mockError
}

Expand Down
4 changes: 2 additions & 2 deletions core/clients/no_auth_flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ func TestNoAuthFlow_Do(t *testing.T) {
c := &NoAuthFlow{
client: tt.fields.client,
}
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, `{"status":"ok"}`)
_, _ = fmt.Fprintln(w, `{"status":"ok"}`)
})
server := httptest.NewServer(handler)
defer server.Close()
Expand Down
4 changes: 2 additions & 2 deletions core/clients/token_flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ func TestTokenFlow_Do(t *testing.T) {
client: tt.fields.client,
config: tt.fields.config,
}
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, `{"status":"ok"}`)
_, _ = fmt.Fprintln(w, `{"status":"ok"}`)
})
server := httptest.NewServer(handler)
defer server.Close()
Expand Down
6 changes: 3 additions & 3 deletions core/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,21 +237,21 @@ func WithToken(token string) ConfigurationOption {

// Deprecated: retry options were removed to reduce complexity of the client. If this functionality is needed, you can provide your own custom HTTP client. This option has no effect, and will be removed in a later update
func WithMaxRetries(_ int) ConfigurationOption {
return func(config *Configuration) error {
return func(_ *Configuration) error {
return nil
}
}

// Deprecated: retry options were removed to reduce complexity of the client. If this functionality is needed, you can provide your own custom HTTP client. This option has no effect, and will be removed in a later update
func WithWaitBetweenCalls(_ time.Duration) ConfigurationOption {
return func(config *Configuration) error {
return func(_ *Configuration) error {
return nil
}
}

// Deprecated: retry options were removed to reduce complexity of the client. If this functionality is needed, you can provide your own custom HTTP client. This option has no effect, and will be removed in a later update
func WithRetryTimeout(_ time.Duration) ConfigurationOption {
return func(config *Configuration) error {
return func(_ *Configuration) error {
return nil
}
}
Expand Down
17 changes: 6 additions & 11 deletions golang-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ linters-settings:
# it's a comma-separated list of prefixes
local-prefixes: github.com/freiheit-com/nmww
depguard:
list-type: blacklist
include-go-root: false
packages:
- github.com/stretchr/testify
packages-with-error-message:
# specify an error message to output when a blacklisted package is used
- github.com/stretchr/testify: "do not use a testing framework"
rules:
main:
list-mode: lax # Everything is allowed unless it is denied
deny:
- pkg: "github.com/stretchr/testify"
desc: Do not use a testing framework
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
Expand Down Expand Up @@ -75,7 +74,6 @@ linters:
- unused
# additional linters
- errorlint
- exportloopref
- gochecknoinits
- gocritic
- gofmt
Expand All @@ -91,9 +89,6 @@ linters:
- forcetypeassert
- errcheck
disable:
- structcheck # deprecated
- deadcode # deprecated
- varcheck # deprecated
- noctx # false positive: finds errors with http.NewRequest that dont make sense
- unparam # false positives
issues:
Expand Down
2 changes: 1 addition & 1 deletion scripts/project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ elif [ "$action" = "tools" ]; then

go mod download

go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0
else
echo "Invalid action: '$action', please use $0 help for help"
fi
12 changes: 6 additions & 6 deletions services/dns/wait/wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestCreateZoneWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &dns.ZoneResponse{
Zone: &dns.Zone{
State: &tt.resourceState,
State: utils.Ptr(tt.resourceState),
Id: utils.Ptr("zid"),
},
}
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestUpdateZoneWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &dns.ZoneResponse{
Zone: &dns.Zone{
State: &tt.resourceState,
State: utils.Ptr(tt.resourceState),
Id: utils.Ptr("zid"),
},
}
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestDeleteZoneWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &dns.ZoneResponse{
Zone: &dns.Zone{
State: &tt.resourceState,
State: utils.Ptr(tt.resourceState),
Id: utils.Ptr("zid"),
},
}
Expand Down Expand Up @@ -300,7 +300,7 @@ func TestCreateRecordSetWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &dns.RecordSetResponse{
Rrset: &dns.RecordSet{
State: &tt.resourceState,
State: utils.Ptr(tt.resourceState),
Id: utils.Ptr("rid"),
},
}
Expand Down Expand Up @@ -368,7 +368,7 @@ func TestUpdateRecordSetWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &dns.RecordSetResponse{
Rrset: &dns.RecordSet{
State: &tt.resourceState,
State: utils.Ptr(tt.resourceState),
Id: utils.Ptr("rid"),
},
}
Expand Down Expand Up @@ -436,7 +436,7 @@ func TestDeleteRecordSetWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &dns.RecordSetResponse{
Rrset: &dns.RecordSet{
State: &tt.resourceState,
State: utils.Ptr(tt.resourceState),
Id: utils.Ptr("rid"),
},
}
Expand Down
36 changes: 18 additions & 18 deletions services/iaas/wait/wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func TestCreateNetworkAreaWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.NetworkArea{
AreaId: utils.Ptr("naid"),
State: &tt.resourceState,
State: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -242,7 +242,7 @@ func TestUpdateNetworkAreaWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.NetworkArea{
AreaId: utils.Ptr("naid"),
State: &tt.resourceState,
State: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -303,7 +303,7 @@ func TestDeleteNetworkAreaWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.NetworkArea{
AreaId: utils.Ptr("naid"),
State: &tt.resourceState,
State: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -362,7 +362,7 @@ func TestCreateNetworkWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Network{
NetworkId: utils.Ptr("nid"),
State: &tt.resourceState,
State: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -421,7 +421,7 @@ func TestUpdateNetworkWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Network{
NetworkId: utils.Ptr("nid"),
State: &tt.resourceState,
State: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -482,7 +482,7 @@ func TestDeleteNetworkWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Network{
NetworkId: utils.Ptr("nid"),
State: &tt.resourceState,
State: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -548,7 +548,7 @@ func TestCreateVolumeWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Volume{
Id: utils.Ptr("vid"),
Status: &tt.resourceState,
Status: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -609,7 +609,7 @@ func TestDeleteVolumeWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Volume{
Id: utils.Ptr("vid"),
Status: &tt.resourceState,
Status: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -675,7 +675,7 @@ func TestCreateServerWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Server{
Id: utils.Ptr("sid"),
Status: &tt.resourceState,
Status: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -736,7 +736,7 @@ func TestDeleteServerWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Server{
Id: utils.Ptr("sid"),
Status: &tt.resourceState,
Status: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -814,7 +814,7 @@ func TestResizeServerWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Server{
Id: utils.Ptr("sid"),
Status: &tt.finalResourceState,
Status: utils.Ptr(tt.finalResourceState),
}
}

Expand Down Expand Up @@ -880,7 +880,7 @@ func TestStartServerWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Server{
Id: utils.Ptr("sid"),
Status: &tt.resourceState,
Status: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -946,7 +946,7 @@ func TestStopServerWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Server{
Id: utils.Ptr("sid"),
Status: &tt.resourceState,
Status: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -1012,7 +1012,7 @@ func TestDeallocateServerWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Server{
Id: utils.Ptr("sid"),
Status: &tt.resourceState,
Status: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -1078,7 +1078,7 @@ func TestRescueServerWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Server{
Id: utils.Ptr("sid"),
Status: &tt.resourceState,
Status: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -1144,7 +1144,7 @@ func TestUnrescueServerWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Server{
Id: utils.Ptr("sid"),
Status: &tt.resourceState,
Status: utils.Ptr(tt.resourceState),
}
}

Expand Down Expand Up @@ -1238,8 +1238,8 @@ func TestProjectRequestWaitHandler(t *testing.T) {
if tt.wantResp {
wantRes = &iaas.Request{
RequestId: utils.Ptr("rid"),
RequestAction: &tt.requestAction,
Status: &tt.requestState,
RequestAction: utils.Ptr(tt.requestAction),
Status: utils.Ptr(tt.requestState),
}
}

Expand Down
Loading
Loading