Showing 34 of 61 total issues
Avoid deeply nested control flow statements. Confirmed
switch alg {
case jwa.RS256, jwa.RS384, jwa.RS512, jwa.PS256, jwa.PS384, jwa.PS512:
k := KidPair{
Kid: key.KeyID(),
Key: &rsa.PublicKey{
Method Config.reApplyResourceURLDefaults
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (config Config) reApplyResourceURLDefaults() *Config {
const http = "http"
const https = "https"
const p80S = "80"
const p443S = "443"
- 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 Runtime.loadAcmeCertAndKeyFromCache
has 7 return statements (exceeds 4 allowed). Confirmed
func (runtime *Runtime) loadAcmeCertAndKeyFromCache(provider string) error {
var e error
if !runtime.cacheDirIsActive() {
return errors.New("cache directory not active, cannot load TLS from cache")
Avoid deeply nested control flow statements. Open
if len(atmpt.ContentEncoding) > 0 {
//only set this if it was present upstream, otherwise assume nothing and leave empty.
proxy.Dwn.Resp.ContentEncoding = atmpt.ContentEncoding
} else {
proxy.Dwn.Resp.ContentEncoding = EncIdentity
Avoid deeply nested control flow statements. Open
if w[0] == STAR {
less = false
} else {
less = true
}
Function upgradeWebsocket
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Confirmed
func upgradeWebsocket(proxy *Proxy) {
var status = make(chan WebsocketStatus)
var tx *WebsocketTx = &WebsocketTx{}
//dialer uses TLSInsecureSkipVerify to accept any certificate or host name.
- 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 validHostName
has 7 return statements (exceeds 4 allowed). Open
func validHostName(r ResourceMapping) error {
invalidErr := errors.New(fmt.Sprintf("resource host needs a valid DNS name: %v", r.URL.Host))
p := idna.New(
idna.ValidateLabels(true),
//this has to be off it disallows * for registration
Method Jwt.UnmarshalJSON
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (j *Jwt) UnmarshalJSON(data []byte) error {
var value interface{}
if err := json.Unmarshal(data, &value); err != nil {
return 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
Avoid deeply nested control flow statements. Open
} else if proxy.hasUpstreamAttemptAborted() {
sendStatusCodeAsJSON(proxy.respondWith(504, gatewayTimeoutTriggeredByUpstreamEvent))
} else {
sendStatusCodeAsJSON(proxy.respondWith(502, badGatewayTriggeredUnableToProcessUpstreamResponse))
}
Avoid deeply nested control flow statements. Open
} else if star == r.RequestURI && options == strings.ToUpper(r.Method) {
globalOptionsHandler(w, r)
} else {
httpHandler(w, r)
}
Method Runtime.fetchAcmeCertAndKey
has 6 return statements (exceeds 4 allowed). Confirmed
func (runtime *Runtime) fetchAcmeCertAndKey(url string) error {
var e error
defer func() {
if r := recover(); r != nil {
Function checkFullCertChain
has 6 return statements (exceeds 4 allowed). Confirmed
func checkFullCertChain(chain *tls.Certificate) ([]TlsLink, error) {
if len(chain.Certificate) == 0 {
return nil, errors.New("no certificate data found")
}
Method ContentEncoding.matches
has 5 return statements (exceeds 4 allowed). Open
func (c ContentEncoding) matches(encoding ContentEncoding) bool {
if len(c) == 0 && encoding == EncIdentity {
return true
} else if len(string(encoding)) == 0 {
return false
Method Runtime.cacheAcmeCertAndKey
has 5 return statements (exceeds 4 allowed). Confirmed
func (runtime *Runtime) cacheAcmeCertAndKey(provider string) error {
var e error
if !runtime.cacheDirIsActive() {
return errors.New("cache directory not active, cannot cache keys")