pstuifzand/ekster

View on GitHub
pkg/server/microsub.go

Summary

Maintainability
F
3 days
Test Coverage

Method microsubHandler.ServeHTTP has a Cognitive Complexity of 109 (exceeds 20 allowed). Consider refactoring.
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())
Severity: Minor
Found in pkg/server/microsub.go - About 1 day to fix

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

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())
Severity: Major
Found in pkg/server/microsub.go - About 6 hrs to fix

Method microsubHandler.ServeHTTP has 20 return statements (exceeds 4 allowed).
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())
Severity: Major
Found in pkg/server/microsub.go - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

                if err != nil {
                    http.Error(w, err.Error(), 500)
                    return
                }
Severity: Major
Found in pkg/server/microsub.go - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

        } else if action == "follow" {
            channel := values.Get("channel")
            following, err := h.backend.FollowGetList(channel)
            if err != nil {
                http.Error(w, err.Error(), 500)
Severity: Major
Found in pkg/server/microsub.go - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                if err != nil {
                    http.Error(w, err.Error(), 500)
                    return
                }
Severity: Major
Found in pkg/server/microsub.go - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if err != nil {
                http.Error(w, err.Error(), 500)
                return
            }
Severity: Major
Found in pkg/server/microsub.go - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

        } else if action == "unfollow" {
            uid := values.Get("channel")
            url := values.Get("url")
            err := h.backend.UnfollowURL(uid, url)
            if err != nil {
Severity: Major
Found in pkg/server/microsub.go - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if err != nil {
                http.Error(w, err.Error(), 500)
                return
            }
Severity: Major
Found in pkg/server/microsub.go - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            } else if name != "" {
                channel, err := h.backend.ChannelsUpdate(uid, name)
                if err != nil {
                    http.Error(w, err.Error(), 500)
                    return
Severity: Major
Found in pkg/server/microsub.go - About 45 mins to fix

There are no issues that match your filters.

Category
Status