Showing 56 of 81 total issues
Method Uchiwa.stashHandler
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (u *Uchiwa) stashHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodDelete {
http.Error(w, "", http.StatusBadRequest)
return
}
Method Uchiwa.eventHandler
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (u *Uchiwa) eventHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodDelete {
http.Error(w, "", http.StatusBadRequest)
return
}
Function rawMetricsToAggregatedCoordinates
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
func rawMetricsToAggregatedCoordinates(rawMetrics []*structs.SERawMetric) *structs.SEMetric {
// Find the oldest data point in the last position
var oldest float64
for _, metrics := range rawMetrics {
count := len(metrics.Points)
Method Uchiwa.clientHandler
has 18 return statements (exceeds 4 allowed). Open
func (u *Uchiwa) clientHandler(w http.ResponseWriter, r *http.Request) {
// We only support DELETE & GET requests
if r.Method != http.MethodDelete && r.Method != http.MethodGet && r.Method != http.MethodHead {
http.Error(w, "", http.StatusBadRequest)
return
Method API.doRequest
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func (api *API) doRequest(req *http.Request) ([]byte, *http.Response, error) {
if api.User != "" && api.Pass != "" {
req.SetBasicAuth(api.User, api.Pass)
}
- 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 initUchiwa
has 64 lines of code (exceeds 50 allowed). Consider refactoring. Open
func initUchiwa(global GlobalConfig) GlobalConfig {
// Set the proper authentication driver
if global.Github.Server != "" {
global.Auth.Driver = "github"
Method Config.Login
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *Config) Login() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
decoder := json.NewDecoder(r.Body)
var data interface{}
Function restrictedHandler
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func restrictedHandler(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var token *jwt.Token
authenticationToken, err := r.Cookie(authenticationCookieName)
if err == nil {
- 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 Uchiwa.checkHandler
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func (u *Uchiwa) checkHandler(w http.ResponseWriter, r *http.Request) {
// We only support DELETE & GET requests
if r.Method != http.MethodGet && r.Method != http.MethodHead {
http.Error(w, "", http.StatusBadRequest)
return
- 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 Uchiwa.checkHandler
has 13 return statements (exceeds 4 allowed). Open
func (u *Uchiwa) checkHandler(w http.ResponseWriter, r *http.Request) {
// We only support DELETE & GET requests
if r.Method != http.MethodGet && r.Method != http.MethodHead {
http.Error(w, "", http.StatusBadRequest)
return
Function restrictedHandler
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
func restrictedHandler(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var token *jwt.Token
authenticationToken, err := r.Cookie(authenticationCookieName)
if err == nil {
Function findClientEvents
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
func findClientEvents(client map[string]interface{}, events *[]interface{}) map[string]interface{} {
if len(*events) == 0 {
client["status"] = 0
} else {
var criticals, warnings int
Method Uchiwa.resultsHandler
has 12 return statements (exceeds 4 allowed). Open
func (u *Uchiwa) resultsHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodDelete {
http.Error(w, "", http.StatusBadRequest)
return
}
Method Uchiwa.eventHandler
has 12 return statements (exceeds 4 allowed). Open
func (u *Uchiwa) eventHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodDelete {
http.Error(w, "", http.StatusBadRequest)
return
}
Method Uchiwa.stashHandler
has 12 return statements (exceeds 4 allowed). Open
func (u *Uchiwa) stashHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodDelete {
http.Error(w, "", http.StatusBadRequest)
return
}
Method Uchiwa.silencedHandler
has 12 return statements (exceeds 4 allowed). Open
func (u *Uchiwa) silencedHandler(w http.ResponseWriter, r *http.Request) {
token := authentication.GetJWTFromContext(r)
if r.Method == http.MethodGet || r.Method == http.MethodHead {
// GET on /silenced
Method Uchiwa.stashesHandler
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (u *Uchiwa) stashesHandler(w http.ResponseWriter, r *http.Request) {
token := authentication.GetJWTFromContext(r)
if r.Method == http.MethodGet || r.Method == http.MethodHead {
// GET on /stashes
Method Uchiwa.stashHandler
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (u *Uchiwa) stashHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodDelete {
http.Error(w, "", http.StatusBadRequest)
return
}
- 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 Uchiwa.clientsHandler
has 9 return statements (exceeds 4 allowed). Open
func (u *Uchiwa) clientsHandler(w http.ResponseWriter, r *http.Request) {
// Support GET & HEAD requests
if r.Method == http.MethodGet || r.Method == http.MethodHead {
token := authentication.GetJWTFromContext(r)
Method Uchiwa.stashesHandler
has 8 return statements (exceeds 4 allowed). Open
func (u *Uchiwa) stashesHandler(w http.ResponseWriter, r *http.Request) {
token := authentication.GetJWTFromContext(r)
if r.Method == http.MethodGet || r.Method == http.MethodHead {
// GET on /stashes