Showing 63 of 199 total issues

Function maketar has 6 return statements (exceeds 4 allowed).
Open

func maketar(pw []*io.PipeWriter, files []*multipart.FileHeader) error {
    var w []io.Writer
    for i := range pw {
        w = append(w, pw[i])
        defer pw[i].Close()
Severity: Major
Found in controllers/submission.go - About 40 mins to fix

Function PostCompany has 6 return statements (exceeds 4 allowed).
Open

func PostCompany(ctx context.Context, w http.ResponseWriter, r *http.Request) (status int, err error) {
    if r.Method != "POST" {
        return http.StatusMethodNotAllowed, nil
    }

Severity: Major
Found in controllers/company.go - About 40 mins to fix

Function GetCompanyByUser has 6 return statements (exceeds 4 allowed).
Open

func GetCompanyByUser(ctx context.Context, w http.ResponseWriter, r *http.Request) (int, error) {
    if r.Method != "GET" {
        return http.StatusMethodNotAllowed, nil
    }

Severity: Major
Found in controllers/user.go - About 40 mins to fix

Function GetSubmissionsForResult has 6 return statements (exceeds 4 allowed).
Open

func GetSubmissionsForResult(ctx context.Context, w http.ResponseWriter, r *http.Request) (status int, err error) {
    if r.Method != "GET" {
        return http.StatusMethodNotAllowed, nil
    }

Severity: Major
Found in controllers/submission.go - About 40 mins to fix

Function CheckNick has 6 return statements (exceeds 4 allowed).
Open

func CheckNick(nick string) error {
    if nick == "" {
        return errors.New("nick is zero")
    }

Severity: Major
Found in util/nick.go - About 40 mins to fix

Function Tokens has 6 return statements (exceeds 4 allowed).
Open

func Tokens(ctx context.Context, w http.ResponseWriter, r *http.Request) (status int, err error) {
    if r.Method != "POST" {
        return http.StatusMethodNotAllowed, nil
    }

Severity: Major
Found in controllers/token.go - About 40 mins to fix

Method Tasker.Call has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

func (t Tasker) Call(ctx context.Context, result model.KeyedResult, task model.KeyedTask, user model.User, startTime time.Time) (model.Skills, error) {
Severity: Minor
Found in logic/logic.go - About 35 mins to fix

Function diffTasker has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

func diffTasker(ctx context.Context, result model.KeyedResult, task model.KeyedTask, user model.User, startTime time.Time) (skills model.Skills, err error) {
Severity: Minor
Found in logic/tasker_diff.go - About 35 mins to fix

Function processDiffResults has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

func processDiffResults(ctx context.Context, sub model.KeyedSubmission, tr model.DiffTestResult, bucket, testFile string, test *datastore.Key) (ts model.TestStats, err error) {
Severity: Minor
Found in runner/diff.go - About 35 mins to fix

Function deal has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

func deal(ctx context.Context, w http.ResponseWriter, r *http.Request, status int, err error) {
Severity: Minor
Found in controllers/controllers.go - About 35 mins to fix

Function junitTasker has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

func junitTasker(ctx context.Context, result model.KeyedResult, task model.KeyedTask, user model.User, startTime time.Time) (skills model.Skills, err error) {
Severity: Minor
Found in logic/tasker_junit.go - About 35 mins to fix

Function upload has 5 return statements (exceeds 4 allowed).
Open

func upload(ctx context.Context, bucket, base string, files []*multipart.FileHeader) multiError {
    errc := make(chan error)
    var errs []error

    for _, fh := range files {
Severity: Major
Found in controllers/submission.go - About 35 mins to fix

Function GetChallengesForCompany has 5 return statements (exceeds 4 allowed).
Open

func GetChallengesForCompany(ctx context.Context, w http.ResponseWriter, r *http.Request) (status int, err error) {
    if r.Method != "GET" {
        return http.StatusMethodNotAllowed, nil
    }

Severity: Major
Found in controllers/challenge.go - About 35 mins to fix

Function TestsByTaskKey has 5 return statements (exceeds 4 allowed).
Open

func TestsByTaskKey(ctx context.Context, w http.ResponseWriter, r *http.Request) (status int, err error) {
    _, ok := passenger.FromContext(ctx)
    if !ok {
        return http.StatusUnauthorized, nil
    }
Severity: Major
Found in controllers/task.go - About 35 mins to fix

Function coderJunit has 5 return statements (exceeds 4 allowed).
Open

func coderJunit(_ context.Context, t model.KeyedTest, sub model.KeyedSubmission, ball io.Reader) (err error) {
    // TODO: use real context here if possible
    ctx := appengine.BackgroundContext()
    if _, ok := t.Params["code"]; !ok {
        log.Debugf(ctx, "JUnit Coder Runner: missing param")
Severity: Major
Found in test/coder_junit.go - About 35 mins to fix

Function Invitation has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
Open

func Invitation(ctx context.Context, w http.ResponseWriter, r *http.Request) (status int, err error) {
    if r.Method != "POST" {
        return http.StatusMethodNotAllowed, nil
    }

Severity: Minor
Found in controllers/invitation.go - About 35 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

Function Templates has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
Open

func Templates(ctx context.Context, w http.ResponseWriter, r *http.Request) (int, error) {
    if r.Method != "GET" {
        return http.StatusMethodNotAllowed, nil
    }

Severity: Minor
Found in controllers/code.go - About 35 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

Function delete has 5 return statements (exceeds 4 allowed).
Open

func delete(w http.ResponseWriter, r *http.Request) {
    address, err := mail.ParseAddress(r.FormValue("email"))

    if err != nil {
        http.Error(w, "Invalid email address: "+err.Error(), 422)
Severity: Major
Found in controllers/sub.go - About 35 mins to fix

Function testRobot has 5 return statements (exceeds 4 allowed).
Open

func testRobot(m *model.Map, in io.Reader) (tr model.RobotTestResults, err error) {
    tr.Moves = append(tr.Moves, model.RobotLogEntry{Position: m.Start, Event: model.Move})
    direction := model.Right
    r := bufio.NewReader(in)
    var picks []int
Severity: Major
Found in test/robot.go - About 35 mins to fix

Function decodeToken has 5 return statements (exceeds 4 allowed).
Open

func decodeToken(ctx context.Context, token string) (*datastore.Key, []byte, error) {
    b, err := hex.DecodeString(token)
    if err != nil {
        return nil, nil, err
    }
Severity: Major
Found in util/passenger/passenger.go - About 35 mins to fix
Severity
Category
Status
Source
Language