dkan
dkan copied to clipboard
Add PHPCS to CI pipeline until CodeClimate errors are resolved
Describe the bug
CodeClimate is displaying errors on all PRs and not providing useful feedback.
Steps To Reproduce
Create a PR with code changes.
Reccomended Fix
Add PHPCS to the pipeline until we're able to fix CodeClimate.
Some things I found:
-
composer-installers
disallows packages of typenpm-asset
. Given that this project is a Drupal module meant for a wide audience, we shouldn't be specifying how thenpm-asset/select2
package is installed. However, that's a conversation out of scope here. I just removedextra.installer-types.npm-asset
. - Moving PHPCS behavior out of CodeClimate and into Github Actions is not hard at all. Clicking 'New Action' gave me a handy template which I modified. The phpcs runner lives in composer.json where it's called by the new Github Action.
- Performing a PHPCS scan of the whole codebase reveals that many files are not up to coding standards. This is an issue because we don't want to change the whole codebase in one go (we could fix many issues with phpcbf). Ideally we'd only scan changed/added files, which remains a little bit of a challenge given resource constraints. We could investigate https://github.com/tj-actions/changed-files and other similar packages which probably exist.
- We want to be able to show code coverage for tests. One solution to this could be to generate an HTML coverage report. The problem is that dktl does the actual test running, and it generates clover reports. This means either changing dktl, or discovering a way to convert clover to HTML, or perhaps finding a github-native way of displaying this information from an artifact.
- composer.json is now configured so that packages will be sorted when you require them. :-)
Thanks on your work on this @paul-m! Let's discuss after standup today.
CodeClimate is working now.