thestrukture/IDE

View on GitHub

Showing 44 of 1,416 total issues

Function POSTApiCreate has 55 lines of code (exceeds 50 allowed). Consider refactoring.
Open

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

    //me := &types.SoftUser{Email:"Strukture user", Username:"Strukture user"}

    if r.FormValue("type") == "0" {
Severity: Minor
Found in api/handlers/rest_POSTApiCreate.go - About 1 hr to fix

    Function LoadPage has 55 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func LoadPage(title string) (*gosweb.Page, error) {
    
        if lPage, ok := WebCache.Get(title); ok {
            return &lPage, nil
        }
    Severity: Minor
    Found in api/templates/templates.go - About 1 hr to fix

      Function Handler has 54 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func Handler(w http.ResponseWriter, r *http.Request) {
          var p *gosweb.Page
          p, err := templates.LoadPage(r.URL.Path)
          var session *sessions.Session
          var er error
      Severity: Minor
      Found in api/handlers/html.go - About 1 hr to fix

        Function RenderTemplate has 51 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func RenderTemplate(w http.ResponseWriter, p *gosweb.Page) {
            defer func() {
                if n := recover(); n != nil {
                    color.Red(fmt.Sprintf("Error loading template in path : web%s.tmpl reason : %s", p.R.URL.Path, n))
        
        
        Severity: Minor
        Found in api/templates/render.go - About 1 hr to fix

          Function Zipit has 9 return statements (exceeds 4 allowed).
          Open

          func Zipit(source, target string) error {
              zipfile, err := os.Create(target)
              if err != nil {
                  return err
              }
          Severity: Major
          Found in api/methods/legacy.go - About 55 mins to fix

            Function LoadPage has 9 return statements (exceeds 4 allowed).
            Open

            func LoadPage(title string) (*gosweb.Page, error) {
            
                if lPage, ok := WebCache.Get(title); ok {
                    return &lPage, nil
                }
            Severity: Major
            Found in api/templates/templates.go - About 55 mins to fix

              Function fApiSearch_project has 8 return statements (exceeds 4 allowed).
              Open

              func fApiSearch_project(w http.ResponseWriter, r *http.Request, session *sessions.Session) (response string, callmet bool) {
              
                  path := filepath.Join(os.ExpandEnv("$GOPATH"), "src", r.FormValue("pkg"), r.FormValue("path"))
                  search := r.FormValue("text")
              
              
              Severity: Major
              Found in api/handlers/middleware_fApiSearch_project.go - About 50 mins to fix

                Avoid deeply nested control flow statements.
                Open

                    } else if r.FormValue("type") == "4" {
                        sapp := methods.GetApp(methods.GetApps(), r.FormValue("pkg"))
                
                        for _, v := range sapp.Css {
                
                
                Severity: Major
                Found in api/handlers/middleware_fApiGet.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                      } else if calls[0] == "meth" {
                          actionText = "The line is located in your package template pipelines at line: " + calls[1]
                      }
                  Severity: Major
                  Found in api/methods/method_ParseLog.go - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                    if err != nil {
                                        response = templates.Alert(types.Alertbs{Type: "danger", Text: "Error creating package " + r.FormValue("name") + ":" + err.Error(), Redirect: "javascript:console.log('error!')"})
                                    }
                    Severity: Major
                    Found in api/handlers/rest_POSTApiAct.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                          } else if r.FormValue("type") == "3" {
                              apps := methods.GetApps()
                              app := methods.GetApp(apps, r.FormValue("pkg"))
                              temp := []string{}
                              for _, v := range app.Css {
                      Severity: Major
                      Found in api/handlers/rest_POSTApiAct.go - About 45 mins to fix

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

                        func POSTApiPut(w http.ResponseWriter, r *http.Request, session *sessions.Session) (response string, callmet bool) {
                        
                            me := types.SoftUser{Email: "Strukture user", Username: "Strukture user"}
                        
                            if r.FormValue("type") == "0" {
                        Severity: Minor
                        Found in api/handlers/rest_POSTApiPut.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

                        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

                          Avoid deeply nested control flow statements.
                          Open

                                          } else if isLinux {
                          
                                              ctx = exec.InteractiveExec(cm1)
                                          } else {
                                              ctx = exec.InteractiveExec(cm1, cm2)
                          Severity: Major
                          Found in api/handlers/rest_ApiTerminal_realtime.go - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                            } else if v.Type == "faas" {
                                                rootel["icon"] = "fa fa-rocket"
                                                rootel["project"] = true
                                                rootel["btype"] = nil
                                            } else {
                            Severity: Major
                            Found in api/handlers/middleware_fApiGet.go - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                              if !f.IsDir() && !strings.Contains(f.Name(), "go-breakpoints") {
                                                                  var mjk string
                              
                                                                  mjk = strings.Replace(path, pkgpath+"web", "", -1) + "/" + f.Name()
                                                                  if globals.Windows {
                              Severity: Major
                              Found in api/handlers/middleware_fApiGet.go - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                                if globals.Windows {
                                                                    mjk = strings.Replace(mjk, "/", "\\", -1)
                                                                }
                                Severity: Major
                                Found in api/handlers/middleware_fApiGet.go - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          if inStructs == -1 {
                                  
                                                              inMethods := methods.FindLine("./methods.dsl", actline)
                                                              if inMethods == -1 {
                                  
                                  
                                  Severity: Major
                                  Found in api/handlers/rest_GETApiBuild.go - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                        } else if r.FormValue("type") == "30" {
                                            ioutil.WriteFile(filepath.Join(os.ExpandEnv("$GOPATH"), "src" ,r.FormValue("pkg"), r.FormValue("target")), []byte(r.FormValue("data")), 0777)
                                    
                                            response = templates.Alert(types.Alertbs{Type: "warning", Text: r.FormValue("target") + " saved!"})
                                        } else if r.FormValue("type") == "4" {
                                    Severity: Major
                                    Found in api/handlers/rest_POSTApiPut.go - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                  if v != r.FormValue("id") {
                                                      temp = append(temp, v)
                                                  }
                                      Severity: Major
                                      Found in api/handlers/rest_POSTApiDelete.go - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language