thestrukture/IDE

View on GitHub
api/handlers/endpoints.go

Summary

Maintainability
C
1 day
Test Coverage
C
73%

Function ApiAttempt has a Cognitive Complexity of 59 (exceeds 20 allowed). Consider refactoring.
Open

func ApiAttempt(w http.ResponseWriter, r *http.Request) (callmet bool) {
    var response string
    var session *sessions.Session

    var er error
Severity: Minor
Found in api/handlers/endpoints.go - About 6 hrs 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

Function ApiAttempt has 78 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func ApiAttempt(w http.ResponseWriter, r *http.Request) (callmet bool) {
    var response string
    var session *sessions.Session

    var er error
Severity: Major
Found in api/handlers/endpoints.go - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

        } else if isURL := (r.URL.Path == "/api/govet" && r.Method == strings.ToUpper("POST")); !callmet && isURL {
    
            response, callmet = POSTApiGovet(w, r, session)
    
        } else if !callmet && gosweb.UrlAtZ(r.URL.Path, "/api/socket") {
    Severity: Major
    Found in api/handlers/endpoints.go - About 45 mins to fix

      package comment should be of the form "Package handlers ..."
      Open

      // File generated by Gopher Sauce
      Severity: Minor
      Found in api/handlers/endpoints.go by golint

      exported function ApiAttempt should have comment or be unexported
      Open

      func ApiAttempt(w http.ResponseWriter, r *http.Request) (callmet bool) {
      Severity: Minor
      Found in api/handlers/endpoints.go by golint

      exported var WebCache should have comment or be unexported
      Open

      var WebCache = gosweb.NewCache()
      Severity: Minor
      Found in api/handlers/endpoints.go by golint

      func ApiAttempt should be APIAttempt
      Open

      func ApiAttempt(w http.ResponseWriter, r *http.Request) (callmet bool) {
      Severity: Minor
      Found in api/handlers/endpoints.go by golint

      There are no issues that match your filters.

      Category
      Status