Skip to content

Commit

Permalink
feat: Extend golangci-lint configuration and fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
0michalsokolowski0 committed Aug 26, 2024
1 parent deba5a0 commit 2549692
Show file tree
Hide file tree
Showing 56 changed files with 232 additions and 178 deletions.
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
102 changes: 102 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
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
- exportloopref
- 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

Check failure

Code scanning / gosec

Potential hardcoded credentials Error

Potential hardcoded credentials

// 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

Check failure

Code scanning / gosec

Potential hardcoded credentials Error

Potential hardcoded credentials

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

0 comments on commit 2549692

Please sign in to comment.