After trying with success gitlab’s code quality with the code climate example in a small demo project I tried to configure it for the main project of my company.
But running code climate with our codebase is too slow to have running it in a ci pipeline (tried docker in docker executor with overlay fs in our own gitlab runner, maybe its missconfigured, who knows) . Our codebase is mainly php and php code sniffer and php mess detector are faster than codeclimate (30s vs 1h).
So I came to the conclusion of writting my own “code climate reporter” which reads phpcs and phpmd reports and writes a code climate alike report (copy pasted code from https://github.com/codeclimate/codeclimate-phpcodesniffer/blob/master/engine.php)… But it does not work, nothing appears in merge request (of course, the branch improves some of the issues stated in the phpcs reports downloaded from the pipeline artifacts )
I have downloaded artifacts, both from master branch, and from merge request feature branch and both are valid json files with a schema similar to the generated by code climate.
is there any other requirement to comply with what gitlab code quality report expects?
Our .gitlab-ci.yml
cache:
paths:
- phpcs.phar
code_quality:
image: php:7.0
allow_failure: true
before_script:
- php -r "file_exists('phpcs.phar')?'':copy('https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar', 'phpcs.phar');"
script:
- php phpcs.phar --standard=PSR12 --report=json app/ > phpcs_report.json
- php code_quality_report.php ./phpcs_report.json > ./gl-code-quality-report.json
artifacts:
paths: [gl-code-quality-report.json]
And the gl-code-quality-report.json looks like
[{
"type": "issue",
"check_name": "Generic Files LineLength TooLong",
"description": "Line exceeds 120 characters; contains 150 characters",
"categories": ["Style"],
"location": {
"path": "\/builds\/my_awesome_php_project/file-with-issue.php",
"lines": {
"begin": 7,
"end": 7
}
},
"remediation_points": 60000,
"engine_name": "phpcodesniffer",
"fingerprint": "25483835d0658f51751af0d77bf29ef3"
}]