cmd/eksterd/http.go
Method mainHandler.ServeHTTP
has a Cognitive Complexity of 159 (exceeds 20 allowed). Consider refactoring. Open
Open
func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
conn := h.pool.Get()
defer conn.Close()
err := r.ParseForm()
- Read upRead up
- Create a ticketCreate a ticket
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 mainHandler.ServeHTTP
has 350 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
conn := h.pool.Get()
defer conn.Close()
err := r.ParseForm()
- Create a ticketCreate a ticket
File http.go
has 639 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
package main
import (
"embed"
"encoding/json"
- Create a ticketCreate a ticket
Method mainHandler.ServeHTTP
has 40 return statements (exceeds 4 allowed). Open
Open
func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
conn := h.pool.Get()
defer conn.Close()
err := r.ParseForm()
- Create a ticketCreate a ticket
Function verifyAuthCode
has 9 return statements (exceeds 4 allowed). Open
Open
func verifyAuthCode(code, redirectURI, authEndpoint, clientID string) (bool, *authResponse, error) {
reqData := url.Values{}
reqData.Set("code", code)
reqData.Set("client_id", clientID)
reqData.Set("redirect_uri", redirectURI)
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if err != nil {
fmt.Fprintf(w, "ERROR: %s\n", err)
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if err == http.ErrNoCookie {
http.Redirect(w, r, "/", 302)
return
}
- Create a ticketCreate a ticket
Function getEndpoints
has 7 return statements (exceeds 4 allowed). Open
Open
func getEndpoints(me string) (parsedEndpoints, error) {
endpoints := parsedEndpoints{}
meURL, err := url.Parse(me)
if err != nil {
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if !isLoggedIn(h.Backend, &sess) {
w.WriteHeader(401)
fmt.Fprintf(w, "Unauthorized")
return
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
} else if err != nil {
http.Error(w, "could not read cookie", 500)
return
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if sess.NextURI != "" {
http.Redirect(w, r, sess.NextURI, 302)
} else {
http.Redirect(w, r, "/", 302)
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
} else if r.URL.Path == "/logs" {
c, err := r.Cookie("session")
if err == http.ErrNoCookie {
http.Redirect(w, r, "/", 302)
return
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if v.UID == currentChannel {
page.CurrentChannel = v
if setting, e := h.Backend.Settings[v.UID]; e {
page.CurrentSetting = setting
} else {
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
} else if r.URL.Path == "/auth/approve" {
// create a code
code := util.RandStringBytes(32)
state := r.FormValue("state")
channel := r.FormValue("channel")
- Create a ticketCreate a ticket
TODO found Open
Open
// responseType := query.Get("response_type") // TODO: check response_type
- Create a ticketCreate a ticket
- Exclude checks
TODO found Open
Open
// TODO: if not logged in, make sure we get back here
- Create a ticketCreate a ticket
- Exclude checks