oauthproxy.go
File oauthproxy.go
has 992 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
package main
import (
"context"
"embed"
OAuthProxy
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type OAuthProxy struct {
CookieOptions *options.Cookie
Validator func(string) bool
SignInPath string
Function NewOAuthProxy
has 116 lines of code (exceeds 50 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)
}
Method OAuthProxy.OAuthCallback
has 70 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (p *OAuthProxy) OAuthCallback(rw http.ResponseWriter, req *http.Request) {
remoteAddr := ip.GetClientString(p.realClientIPParser, req, true)
// finish the oauth cycle
err := req.ParseForm()
Function NewOAuthProxy
has 12 return statements (exceeds 4 allowed). 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)
}
Method OAuthProxy.OAuthCallback
has 9 return statements (exceeds 4 allowed). Open
Open
func (p *OAuthProxy) OAuthCallback(rw http.ResponseWriter, req *http.Request) {
remoteAddr := ip.GetClientString(p.realClientIPParser, req, true)
// finish the oauth cycle
err := req.ParseForm()
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 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 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 (