Skip to content

Commit

Permalink
Updated linters
Browse files Browse the repository at this point in the history
  • Loading branch information
kvanzuijlen committed Oct 24, 2023
1 parent 8d03adf commit e13a504
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 22 deletions.
7 changes: 2 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ run:
linters:
enable:
- govet
- golint
- ineffassign
- goconst
- deadcode
- gofmt
- goimports
- gosec
- gosimple
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- bodyclose
- dogsled
- goprintffuncname
Expand All @@ -25,6 +21,7 @@ linters:
- stylecheck
- unconvert
- gocritic
- revive
disable-all: true
issues:
exclude-rules:
Expand All @@ -38,6 +35,6 @@ issues:
# If we have tests in shared test folders, these can be less strictly linted
- path: tests/.*_tests\.go
linters:
- golint
- revive
- bodyclose
- stylecheck
5 changes: 2 additions & 3 deletions oauthproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,8 @@ func (patTest *PassAccessTokenTest) getEndpointWithCookie(cookie string, endpoin
value = strings.TrimPrefix(field, keyPrefix)
if value != field {
break
} else {
value = ""
}
value = ""
}
if value == "" {
return 0, ""
Expand Down Expand Up @@ -612,7 +611,7 @@ func (sipTest *SignInPageTest) GetEndpoint(endpoint string) (int, string) {
type AlwaysSuccessfulValidator struct {
}

func (AlwaysSuccessfulValidator) Validate(user, password string) bool {
func (AlwaysSuccessfulValidator) Validate(_, _ string) bool {
return true
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/sessions/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import (

type NoOpLock struct{}

func (l *NoOpLock) Obtain(ctx context.Context, expiration time.Duration) error {
func (l *NoOpLock) Obtain(_ context.Context, _ time.Duration) error {
return nil
}

func (l *NoOpLock) Peek(ctx context.Context) (bool, error) {
func (l *NoOpLock) Peek(_ context.Context) (bool, error) {
return false, nil
}

func (l *NoOpLock) Refresh(ctx context.Context, expiration time.Duration) error {
func (l *NoOpLock) Refresh(_ context.Context, _ time.Duration) error {
return nil
}

func (l *NoOpLock) Release(ctx context.Context) error {
func (l *NoOpLock) Release(_ context.Context) error {
return nil
}
2 changes: 1 addition & 1 deletion pkg/providers/oidc/verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ type testVerifier struct {
jwk jose.JSONWebKey
}

func (t *testVerifier) VerifySignature(ctx context.Context, jwt string) ([]byte, error) {
func (t *testVerifier) VerifySignature(_ context.Context, jwt string) ([]byte, error) {
jws, err := jose.ParseSigned(jwt)
if err != nil {
return nil, fmt.Errorf("oidc: malformed jwt: %v", err)
Expand Down
8 changes: 4 additions & 4 deletions pkg/sessions/tests/mock_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ type MockLock struct {
elapsed time.Duration
}

func (l *MockLock) Obtain(ctx context.Context, expiration time.Duration) error {
func (l *MockLock) Obtain(_ context.Context, expiration time.Duration) error {
l.expiration = expiration
return nil
}

func (l *MockLock) Peek(ctx context.Context) (bool, error) {
func (l *MockLock) Peek(_ context.Context) (bool, error) {
if l.elapsed < l.expiration {
return true, nil
}
return false, nil
}

func (l *MockLock) Refresh(ctx context.Context, expiration time.Duration) error {
func (l *MockLock) Refresh(_ context.Context, expiration time.Duration) error {
if l.expiration <= l.elapsed {
return sessions.ErrNotLocked
}
Expand All @@ -33,7 +33,7 @@ func (l *MockLock) Refresh(ctx context.Context, expiration time.Duration) error
return nil
}

func (l *MockLock) Release(ctx context.Context) error {
func (l *MockLock) Release(_ context.Context) error {
if l.expiration <= l.elapsed {
return sessions.ErrNotLocked
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/validation/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func validateHeader(header options.Header, names map[string]struct{}) []string {
return msgs
}

func validateHeaderValue(name string, value options.HeaderValue) []string {
func validateHeaderValue(_ string, value options.HeaderValue) []string {
switch {
case value.SecretSource != nil && value.ClaimSource == nil:
return []string{validateSecretSource(*value.SecretSource)}
Expand Down
2 changes: 1 addition & 1 deletion providers/adfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (p *ADFSProvider) RefreshSession(ctx context.Context, s *sessions.SessionSt
return refreshed, err
}

func (p *ADFSProvider) fallbackUPN(ctx context.Context, s *sessions.SessionState) error {
func (p *ADFSProvider) fallbackUPN(_ context.Context, s *sessions.SessionState) error {
claims, err := p.getClaimExtractor(s.IDToken, s.AccessToken)
if err != nil {
return fmt.Errorf("could not extract claims: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions providers/internal_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ type ValidateSessionTestProvider struct {

var _ Provider = (*ValidateSessionTestProvider)(nil)

func (tp *ValidateSessionTestProvider) GetEmailAddress(ctx context.Context, s *sessions.SessionState) (string, error) {
func (tp *ValidateSessionTestProvider) GetEmailAddress(_ context.Context, _ *sessions.SessionState) (string, error) {
return "", errors.New("not implemented")
}

// Note that we're testing the internal validateToken() used to implement
// several Provider's ValidateSession() implementations
func (tp *ValidateSessionTestProvider) ValidateSession(ctx context.Context, s *sessions.SessionState) bool {
func (tp *ValidateSessionTestProvider) ValidateSession(_ context.Context, _ *sessions.SessionState) bool {
return false
}

Expand Down
2 changes: 1 addition & 1 deletion providers/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (p *OIDCProvider) Redeem(ctx context.Context, redirectURL, code, codeVerifi

// EnrichSession is called after Redeem to allow providers to enrich session fields
// such as User, Email, Groups with provider specific API calls.
func (p *OIDCProvider) EnrichSession(ctx context.Context, s *sessions.SessionState) error {
func (p *OIDCProvider) EnrichSession(_ context.Context, s *sessions.SessionState) error {
// If a mandatory email wasn't set, error at this point.
if s.Email == "" {
return errors.New("neither the id_token nor the profileURL set an email")
Expand Down

0 comments on commit e13a504

Please sign in to comment.