palourde/uchiwa

View on GitHub

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
    }
Severity: Minor
Found in uchiwa/server.go - About 1 hr to fix

    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
        }
    Severity: Minor
    Found in uchiwa/server.go - About 1 hr to fix

      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)
      Severity: Minor
      Found in uchiwa/daemon/metrics.go - About 1 hr to fix

        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
        Severity: Major
        Found in uchiwa/server.go - About 1 hr to fix

          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)
              }
          
          
          Severity: Minor
          Found in uchiwa/sensu/request.go - About 1 hr 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 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"
          Severity: Minor
          Found in uchiwa/config/config.go - About 1 hr to fix

            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{}
            Severity: Minor
            Found in uchiwa/authentication/controllers.go - About 1 hr to fix

              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 {
              Severity: Minor
              Found in uchiwa/authentication/controllers.go - About 1 hr 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 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
              Severity: Minor
              Found in uchiwa/server.go - About 1 hr 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 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
              Severity: Major
              Found in uchiwa/server.go - About 1 hr to fix

                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 {
                Severity: Minor
                Found in uchiwa/authentication/controllers.go - About 1 hr to fix

                  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
                  Severity: Minor
                  Found in uchiwa/daemon/clients.go - About 1 hr to fix

                    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
                        }
                    Severity: Major
                    Found in uchiwa/server.go - About 1 hr to fix

                      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
                          }
                      Severity: Major
                      Found in uchiwa/server.go - About 1 hr to fix

                        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
                            }
                        Severity: Major
                        Found in uchiwa/server.go - About 1 hr to fix

                          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
                          Severity: Major
                          Found in uchiwa/server.go - About 1 hr to fix

                            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
                            Severity: Minor
                            Found in uchiwa/server.go - About 1 hr to fix

                              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
                                  }
                              Severity: Minor
                              Found in uchiwa/server.go - About 55 mins 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 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)
                              
                              
                              Severity: Major
                              Found in uchiwa/server.go - About 55 mins to fix

                                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
                                Severity: Major
                                Found in uchiwa/server.go - About 50 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language