gochan-org / gochan

Function with cyclomatic complexity higher than threshold GO-R1005
Anti-pattern
Minor
2 days ago6 months old
func deletePosts has a cyclomatic complexity of 17 with "high" risk
157	server.ServeError(writer, errStr, wantsJSON, nil)
158}
159
160func deletePosts(checkedPosts []int, writer http.ResponseWriter, request *http.Request) {161	// Delete post(s) or thread(s)
162	infoEv, errEv := gcutil.LogRequest(request)
163	defer gcutil.LogDiscard(infoEv, errEv)
func CallManageFunction has a cyclomatic complexity of 25 with "high" risk
 37
 38// CallManageFunction is called when a user accesses /manage to use manage tools
 39// or log in to a staff account
 40func CallManageFunction(writer http.ResponseWriter, request *http.Request) { 41	var err error
 42	wantsJSON := serverutil.IsRequestingJSON(request)
 43	accessEv := gcutil.LogAccess(request)
func getBoardDataFromForm has a cyclomatic complexity of 24 with "high" risk
207
208// getBoardDataFromForm parses the relevant form fields into the board and returns any errors for invalid string to int
209// or missing required fields. It should only be used for editing and creating boards
210func getBoardDataFromForm(board *gcsql.Board, request *http.Request) error {211	requestType, _, _ := boardsRequestType(request)
212
213	staff, err := getCurrentStaff(request)
func MakePost has a cyclomatic complexity of 55 with "critical" risk
 97}
 98
 99// MakePost is called when a user accesses /post. Parse form data, then insert and build
100func MakePost(writer http.ResponseWriter, request *http.Request) {101	request.ParseMultipartForm(maxFormBytes)
102	wantsJSON := serverutil.IsRequestingJSON(request)
103
func AttachUploadFromRequest has a cyclomatic complexity of 23 with "high" risk
 74// AttachUploadFromRequest reads an incoming HTTP request and processes any incoming files.
 75// It returns the upload (if there was one) and whether or not any errors were served (meaning
 76// that it should stop processing the post
 77func AttachUploadFromRequest(request *http.Request, writer http.ResponseWriter, post *gcsql.Post, postBoard *gcsql.Board) (*gcsql.Upload, error) { 78	infoEv, errEv := gcutil.LogRequest(request)
 79	defer func() {
 80		gcutil.LogDiscard(infoEv, errEv)