pkg/server/microsub.go
Method microsubHandler.ServeHTTP
has a Cognitive Complexity of 109 (exceeds 20 allowed). Consider refactoring. Open
Open
func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
// log.Printf("Incoming request: %s %s\n", r.Method, r.URL)
// log.Println(r.URL.Query())
- 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 microsubHandler.ServeHTTP
has 192 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
// log.Printf("Incoming request: %s %s\n", r.Method, r.URL)
// log.Println(r.URL.Query())
- Create a ticketCreate a ticket
Method microsubHandler.ServeHTTP
has 20 return statements (exceeds 4 allowed). Open
Open
func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
// log.Printf("Incoming request: %s %s\n", r.Method, r.URL)
// log.Println(r.URL.Query())
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if err != nil {
http.Error(w, err.Error(), 500)
return
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
} else if action == "follow" {
channel := values.Get("channel")
following, err := h.backend.FollowGetList(channel)
if err != nil {
http.Error(w, err.Error(), 500)
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if err != nil {
http.Error(w, err.Error(), 500)
return
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if err != nil {
http.Error(w, err.Error(), 500)
return
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
} else if action == "unfollow" {
uid := values.Get("channel")
url := values.Get("url")
err := h.backend.UnfollowURL(uid, url)
if err != nil {
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if err != nil {
http.Error(w, err.Error(), 500)
return
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
} else if name != "" {
channel, err := h.backend.ChannelsUpdate(uid, name)
if err != nil {
http.Error(w, err.Error(), 500)
return
- Create a ticketCreate a ticket