Skip to content

Replace Code Climate with golangci-lint

Pedro Pombeiro requested to merge golangci-lint into master

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.

There are some linters which are more memory-hungry and lock up/panic in CI: deadcode, gosimple and unused. I've made it so that those only run with make codequality and not on the CI build. 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.)

💁 This MR should be reviewed commit-by-commit, since each commit adds a linter and contains the code changes required to make the linter pass. If the team doesn't agree with using a linter we can simply drop the commit.

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?

#24911 (closed)

Edited by Pedro Pombeiro

Merge request reports