Showing 40 of 54 total issues
Method Logger.PrintReq
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (l *Logger) PrintReq(username, upstream string, req *http.Request, url url.URL, ts time.Time, status int, size int) {
Function Validate
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func Validate(o *options.Options) error {
msgs := validateCookie(o.Cookie)
msgs = append(msgs, validateSessionCookieMinimal(o)...)
msgs = append(msgs, validateRedisSessionStore(o)...)
msgs = append(msgs, prefixValues("injectRequestHeaders: ", validateHeaders(o.InjectRequestHeaders)...)...)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function registerFlags
has 7 return statements (exceeds 4 allowed). Open
Open
func registerFlags(v *viper.Viper, prefix string, flagSet *pflag.FlagSet, options interface{}) error {
val := reflect.ValueOf(options)
var typ reflect.Type
if val.Kind() == reflect.Ptr {
typ = val.Elem().Type()
Method ProviderData.buildSessionFromClaims
has 6 return statements (exceeds 4 allowed). Open
Open
func (p *ProviderData) buildSessionFromClaims(rawIDToken, accessToken string) (*sessions.SessionState, error) {
ss := &sessions.SessionState{}
if rawIDToken == "" {
return ss, nil
Method LoginGovProvider.Redeem
has 6 return statements (exceeds 4 allowed). Open
Open
func (p *LoginGovProvider) Redeem(ctx context.Context, _, code, codeVerifier string) (*sessions.SessionState, error) {
if code == "" {
return nil, ErrMissingCode
}
Method server.setupTLSListener
has 6 return statements (exceeds 4 allowed). Open
Open
func (s *server) setupTLSListener(opts Opts) error {
if opts.SecureBindAddress == "" || opts.SecureBindAddress == "-" {
// No HTTPS listener required
return nil
}
Method OAuthProxy.ErrorPage
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (p *OAuthProxy) ErrorPage(rw http.ResponseWriter, req *http.Request, code int, appError string, messages ...interface{}) {
Function PrintAuthf
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func PrintAuthf(username string, req *http.Request, status AuthStatus, format string, a ...interface{}) {
Method SessionStore.makeCookie
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (s *SessionStore) makeCookie(req *http.Request, name string, value string, expiration time.Duration, now time.Time) *http.Cookie {
Method Logger.PrintAuthf
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (l *Logger) PrintAuthf(username string, req *http.Request, status AuthStatus, format string, a ...interface{}) {
Method OAuthProxy.doOAuthStart
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *OAuthProxy) doOAuthStart(rw http.ResponseWriter, req *http.Request, overrides url.Values) {
extraParams := p.provider.Data().LoginURLParams(overrides)
prepareNoCache(rw)
var (
Method server.startServer
has 5 return statements (exceeds 4 allowed). Open
Open
func (s *server) startServer(ctx context.Context, listener net.Listener) error {
srv := &http.Server{Handler: s.handler, ReadHeaderTimeout: time.Minute}
g, groupCtx := errgroup.WithContext(ctx)
g.Go(func() error {
Function checkNonce
has 5 return statements (exceeds 4 allowed). Open
Open
func checkNonce(idToken string, p *LoginGovProvider) (err error) {
token, err := jwt.ParseWithClaims(idToken, &loginGovCustomClaims{}, func(_ *jwt.Token) (interface{}, error) {
var pubkeys jose.JSONWebKeySet
rerr := requests.New(p.PubJWKURL.String()).Do().UnmarshalInto(&pubkeys)
if rerr != nil {
Function NewProxy
has 5 return statements (exceeds 4 allowed). Open
Open
func NewProxy(upstreams options.UpstreamConfig, sigData *options.SignatureData, writer pagewriter.Writer) (http.Handler, error) {
m := &multiUpstreamProxy{
serveMux: mux.NewRouter(),
}
Function claimsFromIDToken
has 5 return statements (exceeds 4 allowed). Open
Open
func claimsFromIDToken(idToken string) (*claims, error) {
// id_token is a base64 encode ID token payload
// https://developers.google.com/accounts/docs/OAuth2Login#obtainuserinfo
jwt := strings.Split(idToken, ".")
Method claimExtractor.GetClaim
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *claimExtractor) GetClaim(claim string) (interface{}, bool, error) {
if claim == "" {
return nil, false, nil
}
Method server.Start
has 5 return statements (exceeds 4 allowed). Open
Open
func (s *server) Start(ctx context.Context) error {
g, groupCtx := errgroup.WithContext(ctx)
if s.listener != nil {
g.Go(func() error {
Method LoginGovProvider.configure
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *LoginGovProvider) configure(opts options.LoginGovOptions) error {
pubJWKURL, err := url.Parse(opts.PubJWKURL)
if err != nil {
return fmt.Errorf("could not parse Public JWK URL: %v", err)
}
Function NewOAuthProxy
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func NewOAuthProxy(opts *options.Options, validator func(string) bool) (*OAuthProxy, error) {
sessionStore, err := sessions.NewSessionStore(&opts.Session, &opts.Cookie)
if err != nil {
return nil, fmt.Errorf("error initialising session store: %v", err)
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method GoogleProvider.Redeem
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *GoogleProvider) Redeem(ctx context.Context, redirectURL, code, codeVerifier string) (*sessions.SessionState, error) {
if code == "" {
return nil, ErrMissingCode
}
clientSecret, err := p.GetClientSecret()