wisedog/ladybug

View on GitHub

Showing 41 of 112 total issues

Function ValidationFailAndRedirect has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

func ValidationFailAndRedirect(c *interfacer.AppContext, w http.ResponseWriter,
    r *http.Request, errorMap map[string]string, url string, value interface{}) {
Severity: Minor
Found in controllers/util.go - About 45 mins to fix

    Function AddTool has 7 return statements (exceeds 4 allowed).
    Open

    func AddTool(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request) error {
    
        if err := r.ParseForm(); err != nil {
            log.Error("Build", "type", "http", "msg ", err)
            return errors.HttpError{Status: http.StatusInternalServerError, Desc: "ParseForm failed"}
    Severity: Major
    Found in controllers/builds.go - About 45 mins to fix

      Method Jenkins.AddJenkinsBuilds has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
      Open

      func (j Jenkins) AddJenkinsBuilds(url string, projectID int, db *gorm.DB) error {
          if db == nil {
              return errors.New("Wrong database handler!")
          }
      
      
      Severity: Minor
      Found in controllers/buildtools/jenkins.go - About 45 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 Jenkins.AddJenkinsBuilds has 7 return statements (exceeds 4 allowed).
      Open

      func (j Jenkins) AddJenkinsBuilds(url string, projectID int, db *gorm.DB) error {
          if db == nil {
              return errors.New("Wrong database handler!")
          }
      
      
      Severity: Major
      Found in controllers/buildtools/jenkins.go - About 45 mins to fix

        Function ExecDone has 7 return statements (exceeds 4 allowed).
        Open

        func ExecDone(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request) error {
        
            if err := r.ParseForm(); err != nil {
                log.Error("TestExec", "type", "http", "msg ", err)
                return errors.HttpError{Status: http.StatusInternalServerError, Desc: "ParseForm failed"}
        Severity: Major
        Found in controllers/testexecs.go - About 45 mins to fix

          Function ExecUpdateResult has 7 return statements (exceeds 4 allowed).
          Open

          func ExecUpdateResult(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request) error {
              var rv models.TestCaseResult
          
              if err := r.ParseForm(); err != nil {
                  log.Error("TestExec", "type", "http", "msg ", err)
          Severity: Major
          Found in controllers/testexecs.go - About 45 mins to fix

            Function SectionAdd has 7 return statements (exceeds 4 allowed).
            Open

            func SectionAdd(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request) error {
                // get "section_id" from post form
                if err := r.ParseForm(); err != nil {
                    log.Error("Section", "type", "app", "msg ", err.Error())
                    return RenderJSONWithStatus(w, Resp{Msg: "Parse form is not valid"}, http.StatusBadRequest)
            Severity: Major
            Found in controllers/sections.go - About 45 mins to fix

              Method Travis.AddTravisBuilds has 7 return statements (exceeds 4 allowed).
              Open

              func (t Travis) AddTravisBuilds(url string, projectID int, db *gorm.DB) error {
              
                  repo, u, err := t.ConnectionTest(url)
                  if err != nil {
                      return errors.New("Fail to get Travis repo information")
              Severity: Major
              Found in controllers/buildtools/travis.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                        } else if (*historyUnit)[i].ChangeType == models.HistoryChangeTypeNote {
                            msg = fmt.Sprintf("%s added a note.", (*historyUnit)[i].What)
                        } else {
                            msg = ""
                        }
                Severity: Major
                Found in controllers/testcases.go - About 45 mins to fix

                  Function saveUpdateRequirement has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func saveUpdateRequirement(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request, isUpdate bool) error {
                      var req models.Requirement
                      vars := mux.Vars(r)
                      idStr := vars["id"]
                  
                  
                  Severity: Minor
                  Found in controllers/requirements.go - About 45 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

                  Function UnlinkRequirementRelation has 6 return statements (exceeds 4 allowed).
                  Open

                  func UnlinkRequirementRelation(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request) error {
                      // get requirement, testcase ID from post
                      if err := r.ParseForm(); err != nil {
                          log.Error("TestCase", "type", "app", "msg ", err.Error())
                          return RenderJSONWithStatus(w, Resp{Msg: "Parse form is not valid"}, http.StatusBadRequest)
                  Severity: Major
                  Found in controllers/testcases.go - About 40 mins to fix

                    Function UnlinkTestcaseRelation has 6 return statements (exceeds 4 allowed).
                    Open

                    func UnlinkTestcaseRelation(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request) error {
                        // get requirement, testcase ID from post
                        if err := r.ParseForm(); err != nil {
                            log.Error("Requirement", "type", "app", "msg ", err.Error())
                            return RenderJSONWithStatus(w, Resp{Msg: "Parse form is not valid"}, http.StatusBadRequest)
                    Severity: Major
                    Found in controllers/requirements.go - About 40 mins to fix

                      Function SectionEdit has 6 return statements (exceeds 4 allowed).
                      Open

                      func SectionEdit(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request) error {
                          // get "section_id" from post form
                          if err := r.ParseForm(); err != nil {
                              return logAndRenderJSONWithStatus(w, Resp{Msg: "Parse form is not valid"}, http.StatusBadRequest,
                                  logTypeErr, "Section", "app", err.Error())
                      Severity: Major
                      Found in controllers/sections.go - About 40 mins to fix

                        Function handleSaveUpdate has 6 return statements (exceeds 4 allowed).
                        Open

                        func handleSaveUpdate(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request, isUpdate bool) error {
                        
                            var testcase models.TestCase
                            vars := mux.Vars(r)
                            projectName := vars["projectName"]
                        Severity: Major
                        Found in controllers/testcases.go - About 40 mins to fix

                          Function addEditRequirement has 6 return statements (exceeds 4 allowed).
                          Open

                          func addEditRequirement(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request, isEdit bool) error {
                              var errorMap map[string]string
                              var req models.Requirement
                          
                              session, e := c.Store.Get(r, "ladybug")
                          Severity: Major
                          Found in controllers/requirements.go - About 40 mins to fix

                            Function logAndRenderJSONWithStatus has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            func logAndRenderJSONWithStatus(w http.ResponseWriter, data interface{}, statusCode int,
                                logType int, module, msgType, msg string) error {
                            Severity: Minor
                            Found in controllers/util.go - About 35 mins to fix

                              Function ProjectSave has 5 return statements (exceeds 4 allowed).
                              Open

                              func ProjectSave(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request) error {
                              
                                  if err := r.ParseForm(); err != nil {
                                      log.Error("Projects", "type", "http", "msg ", err)
                                  }
                              Severity: Major
                              Found in controllers/projects.go - About 35 mins to fix

                                Function BuildsSaveProject has 5 return statements (exceeds 4 allowed).
                                Open

                                func BuildsSaveProject(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request) error {
                                    if err := r.ParseForm(); err != nil {
                                        log.Error("Build", "Error ", err)
                                        return errors.HttpError{Status: http.StatusInternalServerError, Desc: "ParseForm failed"}
                                    }
                                Severity: Major
                                Found in controllers/builds.go - About 35 mins to fix

                                  Function UserUpdateProfile has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func UserUpdateProfile(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request) error {
                                      vars := mux.Vars(r)
                                      id := vars["id"]
                                      idInt, _ := strconv.Atoi(id)
                                  
                                  
                                  Severity: Major
                                  Found in controllers/users.go - About 35 mins to fix

                                    Function ProjectSave has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                                    Open

                                    func ProjectSave(c *interfacer.AppContext, w http.ResponseWriter, r *http.Request) error {
                                    
                                        if err := r.ParseForm(); err != nil {
                                            log.Error("Projects", "type", "http", "msg ", err)
                                        }
                                    Severity: Minor
                                    Found in controllers/projects.go - About 35 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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language