Converting PHPCS output to gitlab/codeclimate format

Daniel Ness
Dec 1, 2020

--

In a similar approach to my other gitlab code quality posts (here and here) I’m skipping prebuilt packages for my pipelines and converting the output of my static analysis tools into a codeclimate compatible format using the jq tool.

php -dmemory_limit=-1 vendor/bin/phpcs  --report=json . | jq '[.files | keys[] as $file | .[] | .messages | .[] as $msg |  {type: "issue", check_name: $msg.source, categories: ["PHP", "phpcs"], fingerprint: ("\($file):\($msg.line):\($msg.source)"), description: $msg.message, location: { path: $file, lines: {begin: $msg.line, end: $msg.line }}}]'

--

--