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{}) {
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"}
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!")
}
- 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
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!")
}
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"}
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)
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)
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")
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 = ""
}
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"]
- 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
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)
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)
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())
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"]
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")
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 {
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)
}
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"}
}
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)
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)
}
- 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"