From 78efe888584d9a069946ddbb547fe1c1e15a83a8 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 22 Aug 2024 11:28:21 +0200 Subject: [PATCH] fix: golang ci lint errors --- .golangci.yml | 9 +++------ account-api/client.go | 2 +- account-api/login.go | 2 +- cmd/project/project_proxy.go | 4 ++-- extension/asset_platform.go | 2 +- go.mod | 2 +- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 3c09c4ff..50129f46 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,12 +4,11 @@ linters: disable-all: true enable: - bodyclose - - exportloopref - exhaustive - goconst - gofmt - goprintffuncname -# - gosec + # - gosec - gosimple - govet - ineffassign @@ -60,11 +59,9 @@ linters-settings: - "Prefix(github.com/FriendsOfShopware/shopware-cli)" issues: + exclude-dirs: + - version exclude-rules: - path: cmd\/* linters: - forbidigo - -run: - skip-dirs: - - version diff --git a/account-api/client.go b/account-api/client.go index 52be717e..8ec82a91 100644 --- a/account-api/client.go +++ b/account-api/client.go @@ -58,7 +58,7 @@ func (*Client) doRequest(request *http.Request) ([]byte, error) { } if resp.StatusCode >= 400 { - return nil, fmt.Errorf(string(data)) + return nil, fmt.Errorf(string(data)+", got status code %d", resp.StatusCode) } return data, nil diff --git a/account-api/login.go b/account-api/login.go index 5505ee62..8d5bf7e9 100644 --- a/account-api/login.go +++ b/account-api/login.go @@ -116,7 +116,7 @@ func fetchMemberships(ctx context.Context, token token) ([]Membership, error) { } if resp.StatusCode != 200 { - return nil, fmt.Errorf(string(data)) + return nil, fmt.Errorf(string(data)+" but got status code %d", resp.StatusCode) } var companies []Membership diff --git a/cmd/project/project_proxy.go b/cmd/project/project_proxy.go index 73f9e889..49159b13 100644 --- a/cmd/project/project_proxy.go +++ b/cmd/project/project_proxy.go @@ -1,7 +1,7 @@ package project import ( - "fmt" + "errors" "os" "os/exec" "runtime" @@ -35,7 +35,7 @@ var projectProxyCmd = &cobra.Command{ message += "See cloudflare for more information: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation" } - return fmt.Errorf(message) + return errors.New(message) } logging.FromContext(cobraCmd.Context()).Infof("Make sure you have set TRUSTED_PROXIES=127.0.0.1,::1 inside your .env file") diff --git a/extension/asset_platform.go b/extension/asset_platform.go index b292bf17..42684aa5 100644 --- a/extension/asset_platform.go +++ b/extension/asset_platform.go @@ -353,7 +353,7 @@ func InstallNPMDependencies(path string, packageJsonData NpmPackage, additionalP } } - if isProductionMode && (packageJsonData.Dependencies == nil || len(packageJsonData.Dependencies) == 0) { + if isProductionMode && len(packageJsonData.Dependencies) == 0 { return nil } diff --git a/go.mod b/go.mod index 317afb37..c8c3cb9f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/FriendsOfShopware/shopware-cli -go 1.21 +go 1.23 require ( dario.cat/mergo v1.0.1