Skip to content

Migrate from CodeClimate to golangci-lint

What does this MR do?

Replace Code Climate with golangci-lint. golangci-lint is set up to produce Code Climate-compatible output.

Why was this MR needed?

golangci-lint is faster, more efficient, and doesn't resort to using a Docker container locally.

Are there points in the code the reviewer needs to double check?

I've enabled the same linters as were present in Code Climate (gocyclo, gofmt->goimports, govet, golint), and some additional ones (deadcode, goconst, ineffassign, misspell, structcheck, typecheck, unconvert, varcheck) that didn't require significant changes to the codebase, but will protect us in the future.

As @lraykov mentioned, there is a --new-from-rev HEAD~ flag that normally should allow us to spot only issues introduced in the MR, but after running some tests, it always returned an empty result set, so for now we'll forgo that flag.

I'm passing -v to golangci-lint so we have some additional information about execution, memory usage, etc. I know this will be useful in the future for comparison when we decide to add a new linter and start having resource issues.

LINT_FLAGS is a variable that is used to specify additional flags to the lint target. CI has different requirements than local runs (e.g. removing color from output, specifying return code in case of errors found, etc.)

Does this MR meet the acceptance criteria?

  • Documentation created/updated
  • Added tests for this feature/bug
  • In case of conflicts with master - branch was rebased

What are the relevant issue numbers?

gitlab-org/gitlab-runner#24911 (closed)

Merge request reports