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

ci: Extend golangci-lint configuration and fix errors #244

Merged
merged 4 commits into from
Aug 27, 2024
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ key.*
completions

*.csv
.idea
101 changes: 101 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
linters-settings:
depguard:
rules:
main:
deny:
- pkg: "io/ioutil"
# https://go.dev/doc/go1.16#ioutil
desc: io/ioutil package has been deprecated.
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
gci:
sections:
- standard
- default
- prefix(github.com/spacelift-io/backend)
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- performance
disabled-checks:
- ifElseChain
- wrapperFunc
- hugeParam
- rangeValCopy
- appendCombine
- commentedOutCode
- sloppyReassign
- filepathJoin
- evalOrder
- equalFold
- returnAfterHttpError
- preferStringWriter
- sprintfQuotedString
- preferFprint
gofmt:
simplify: true
goimports:
local-prefixes: github.com/spacelift-io/backend
govet:
check-shadowing: false
enable:
- nilness
nolintlint:
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: increment-decrement
- name: var-declaration
- name: package-comments
- name: range
- name: time-naming
- name: errorf
- name: unreachable-code
- name: redefines-builtin-id
staticcheck:
checks: [ "all", "-SA1019"]

errorlint:
errorf: false
errorf-multi: false
asserts: false
comparison: true

linters:
disable-all: true
enable:
- asasalint
- bodyclose
- depguard
- errorlint
- gci
- gocheckcompilerdirectives
- gocritic
- gofmt
- goimports
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- makezero
- noctx
- nolintlint
- staticcheck
- revive
- typecheck
- unconvert
- wastedassign
- unparam
4 changes: 2 additions & 2 deletions browserauth/browserauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ func (h *Handler) extractToken(r *http.Request) error {
}

// Decrypt the token AES key using our private key
key, err := rsa.DecryptOAEP(sha512.New(), rand.Reader, h.key, []byte(encKey), nil)
key, err := rsa.DecryptOAEP(sha512.New(), rand.Reader, h.key, encKey, nil)
if err != nil {
return errors.Wrap(err, "could not decrypt key")
}

// Decrypt the token using the decrypted AES key
jwt, err := internal.DecryptAES(key, []byte(encToken))
jwt, err := internal.DecryptAES(key, encToken)
if err != nil {
return errors.Wrap(err, "could not decrypt session token")
}
Expand Down
3 changes: 1 addition & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import (
"strings"

"github.com/shurcooL/graphql"
"golang.org/x/oauth2"

"github.com/spacelift-io/spacectl/client/session"
"golang.org/x/oauth2"
)

type client struct {
Expand Down
4 changes: 2 additions & 2 deletions client/session/from_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const (

// EnvSpaceliftAPIKeyEndpoint represents the name of the environment variable
// pointing to the Spacelift API endpoint.
EnvSpaceliftAPIKeyEndpoint = "SPACELIFT_API_KEY_ENDPOINT"
EnvSpaceliftAPIKeyEndpoint = "SPACELIFT_API_KEY_ENDPOINT" //nolint: gosec
Dismissed Show dismissed Hide dismissed

// EnvSpaceliftAPIKeyID represents the name of the environment variable
// pointing to the Spacelift API key ID.
EnvSpaceliftAPIKeyID = "SPACELIFT_API_KEY_ID"
EnvSpaceliftAPIKeyID = "SPACELIFT_API_KEY_ID" //nolint: gosec
Dismissed Show dismissed Hide dismissed

// EnvSpaceliftAPIKeySecret represents the name of the environment variable
// pointing to the Spacelift API key secret.
Expand Down
Loading
Loading