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

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

                func ApiTerminal_realtime(w http.ResponseWriter, r *http.Request, session *sessions.Session) (response string, callmet bool) {
                
                    c, err := globals.Upgrader.Upgrade(w, r, nil)
                    if err != nil {
                        log.Print("upgrade:", err)
                Severity: Minor
                Found in api/handlers/rest_ApiTerminal_realtime.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

                                                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 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

                        } 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 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

                                        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") == "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

                                } else if r.FormValue("type") == "4" {
                                    varf := []types.Inputs{}
                                    varf = append(varf, types.Inputs{Name: "name", Type: "text", Text: "Template name"})
                            
                                    response = templates.Form(types.Forms{Link: "/api/act?type=5&pkg=" + r.FormValue("pkg") + "&bundle=" + r.FormValue("bundle"), CTA: "Create Template file", Class: "warning", Inputs: varf})
                            Severity: Major
                            Found in api/handlers/rest_POSTApiCreate.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

                                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

                                                                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

                                                  } 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 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