Showing 34 of 61 total issues
Method Jwt.LoadJwks
has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring. Confirmed
func (jwt *Jwt) LoadJwks() error {
var err error
//acquires the lock with true else skips
if jwt.lock.TryAcquire(1) {
- 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 Jwt.Validate
has a Cognitive Complexity of 40 (exceeds 20 allowed). Consider refactoring. Confirmed
func (jwt *Jwt) Validate() error {
var err error
alg := *new(jwa.SignatureAlgorithm)
err = alg.Accept(jwt.Alg)
- 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 Config.validateAcmeConfig
has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring. Confirmed
func (config Config) validateAcmeConfig() *Config {
acmeProvider := len(config.Connection.Downstream.Tls.Acme.Provider) > 0
acmeDomain := len(config.Connection.Downstream.Tls.Acme.Domains) > 0 && len(config.Connection.Downstream.Tls.Acme.Domains[0]) > 0
acmeEmail := len(config.Connection.Downstream.Tls.Acme.Email) > 0
- 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 parseUpstreamResponse
has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring. Confirmed
func parseUpstreamResponse(upstreamResponse *http.Response, proxy *Proxy) ([]byte, error) {
var upstreamResponseBody []byte
var bodyError error
//get a reference to this before any race conditions may occur
- 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
Config
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
type Config struct {
Policies map[string]Policy
Routes Routes
Jwt map[string]*Jwt
Resources map[string][]ResourceMapping
Function parseUpstreamResponse
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Confirmed
func parseUpstreamResponse(upstreamResponse *http.Response, proxy *Proxy) ([]byte, error) {
var upstreamResponseBody []byte
var bodyError error
//get a reference to this before any race conditions may occur
File config.go
has 511 lines of code (exceeds 500 allowed). Consider refactoring. Open
package j8a
import (
"bytes"
"encoding/json"
Method Jwt.LoadJwks
has 75 lines of code (exceeds 50 allowed). Consider refactoring. Confirmed
func (jwt *Jwt) LoadJwks() error {
var err error
//acquires the lock with true else skips
if jwt.lock.TryAcquire(1) {
Method Config.validateRoutes
has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring. Open
func (config Config) validateRoutes() *Config {
for i, _ := range config.Routes {
v, e := config.Routes[i].validPath()
if !v {
config.panic(e.Error())
- 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.CountUpConns
has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring. Open
func (rt *Runtime) CountUpConns(proc *process.Process, cs procspy.ConnIter, ips map[string][]net.IP) int {
d := 0
UpConn:
for c := cs.Next(); c != nil; c = cs.Next() {
if c.PID == uint(proc.Pid) {
- 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 Jwt.Validate
has 68 lines of code (exceeds 50 allowed). Consider refactoring. Confirmed
func (jwt *Jwt) Validate() error {
var err error
alg := *new(jwa.SignatureAlgorithm)
err = alg.Accept(jwt.Alg)
Function performUpstreamRequest
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func performUpstreamRequest(proxy *Proxy) (*http.Response, error) {
//get a reference to this before any race conditions may occur
attemptIndex := proxy.Up.Count - 1
req := scaffoldUpstreamRequest(proxy)
var upstreamResponse *http.Response
Method Proxy.parseRequestBody
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (proxy *Proxy) parseRequestBody(request *http.Request) {
//content length 0, do not read just go back
if request.ContentLength == 0 {
infoOrTraceEv(proxy).
Int64(dwnElpsdMicros, time.Since(proxy.Dwn.startDate).Microseconds()).
Method Config.validateAcmeConfig
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (config Config) validateAcmeConfig() *Config {
acmeProvider := len(config.Connection.Downstream.Tls.Acme.Provider) > 0
acmeDomain := len(config.Connection.Downstream.Tls.Acme.Domains) > 0 && len(config.Connection.Downstream.Tls.Acme.Domains[0]) > 0
acmeEmail := len(config.Connection.Downstream.Tls.Acme.Email) > 0
Method Config.validateResources
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
func (config Config) validateResources() *Config {
for name := range config.Resources {
resourceMappings := config.Resources[name]
if len(resourceMappings) == 0 {
config.panic(fmt.Sprintf("resource '%v' needs to have at least one url, see https://j8a.io/docs", 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
Method Route.validHostPattern
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (route *Route) validHostPattern() (bool, error) {
//first check the name is a valid idna name.
p := idna.New(
idna.ValidateLabels(true),
//this has to be off it disallows * for registration
- 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 PerformJ8aTest
has 7 arguments (exceeds 4 allowed). Consider refactoring. Confirmed
func PerformJ8aTest(t *testing.T, testMethod string, wantUpstreamWaitSeconds int, wantTotalWaitSeconds int, wantStatusCode int, serverPort int, tlsMode bool) {
Method Route.validHostPattern
has 8 return statements (exceeds 4 allowed). Open
func (route *Route) validHostPattern() (bool, error) {
//first check the name is a valid idna name.
p := idna.New(
idna.ValidateLabels(true),
//this has to be off it disallows * for registration
Method Route.validPath
has 8 return statements (exceeds 4 allowed). Open
func (route *Route) validPath() (bool, error) {
const fakeHost = "http://127.0.0.1"
defaultError := errors.New(fmt.Sprintf("route %v not a valid URL path", route.Path))
_, err := url.ParseRequestURI(fakeHost + route.Path)
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"