Showing 44 of 1,416 total issues
Function POSTApiCreate
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
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" {
Function LoadPage
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func LoadPage(title string) (*gosweb.Page, error) {
if lPage, ok := WebCache.Get(title); ok {
return &lPage, nil
}
Function Handler
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
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
Function RenderTemplate
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
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))
Function Zipit
has 9 return statements (exceeds 4 allowed). Open
Open
func Zipit(source, target string) error {
zipfile, err := os.Create(target)
if err != nil {
return err
}
Function LoadPage
has 9 return statements (exceeds 4 allowed). Open
Open
func LoadPage(title string) (*gosweb.Page, error) {
if lPage, ok := WebCache.Get(title); ok {
return &lPage, nil
}
Function fApiSearch_project
has 8 return statements (exceeds 4 allowed). Open
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")
Function ApiTerminal_realtime
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
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)
- Read upRead up
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
Open
if globals.Windows {
mjk = strings.Replace(mjk, "/", "\\", -1)
}
Avoid deeply nested control flow statements. Open
Open
if globals.Windows {
mjk = strings.Replace(mjk, "/", "\\", -1)
}
Avoid deeply nested control flow statements. Open
Open
} else if r.FormValue("type") == "4" {
sapp := methods.GetApp(methods.GetApps(), r.FormValue("pkg"))
for _, v := range sapp.Css {
Avoid deeply nested control flow statements. Open
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") {
Avoid deeply nested control flow statements. Open
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!')"})
}
Avoid deeply nested control flow statements. Open
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" {
Avoid deeply nested control flow statements. Open
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})
Avoid deeply nested control flow statements. Open
Open
} else if isLinux {
ctx = exec.InteractiveExec(cm1)
} else {
ctx = exec.InteractiveExec(cm1, cm2)
Function POSTApiPut
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
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" {
- Read upRead up
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
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 {
Avoid deeply nested control flow statements. Open
Open
} else if v.Type == "faas" {
rootel["icon"] = "fa fa-rocket"
rootel["project"] = true
rootel["btype"] = nil
} else {
Avoid deeply nested control flow statements. Open
Open
if v != r.FormValue("id") {
temp = append(temp, v)
}