This tool lets you see how your branch is affecting the code quality (what issues you've added, fixed, and what issues are outstanding in the files you've touched.)
It covers 2/3 of our code quality metrics (code smells, cyclomatic complexity, but not similar code). Codeclimate supports 'duplication' as a plugin, but it takes twice as long to run on everything and only really works if you run it on everything.
-
Install the codeclimate cli:
brew tap codeclimate/formulae brew install codeclimate -
Add a
.codeclimate.ymlconfig file eg:--- version: "2" plugins: rubocop: enabled: true channel: rubocop-1-36-0 reek: enabled: true exclude_patterns: - config/ - db/ - dist/ - features/ - public/ - "**/node_modules/" - script/ - "**/spec/" - "**/test/" - "**/tests/" - Tests/ - "**/vendor/" - "**/*_test.go" - "**/*.d.ts" - "**/*.min.js" - "**/*.min.css" - "**/__tests__/" - "**/__mocks__/" - "/.gitlab/" - coverage/ -
Give execute permission for
codeclimate_diffchmod a+x ./codeclimate_diff -
Run the baseline and commit the result to the repo
./codeclimate_diff --baseline
-
Create a feature branch for your work, and reset the baseline + commit (5 mins)
-
Do some work
-
Check if you've added any issues (about 10 secs per code file changed on your branch)
# runs on all code files changed in your branch ./codeclimate_diff OR # filters the changed files in your branch futher ./codeclimate_diff --pattern places OR # only shows the new and fixed issues ./codeclimate_diff --new-only -
Now you have time to fix the issues yay!
- Extract into a Gem
- See if we can improve performance (it spins up a docker container per file)
- Plug into the pipeline and fail if we've introduced more issues than fixed
- Run duplication in the pipeline.
- Run the baseline in the pipeline and download it from the artifact instead of running locally?