Closed josephdpurcell closed 8 years ago
This PR is likely blocked by https://github.com/codeclimate/codeclimate-phpcodesniffer/pull/33.
It looks like this works. Next would be to try adding a codeclimate yml with:
engines:
phpcodesniffer:
enabled: true
config:
standard: "Drupal"
and see if it correctly runs. Any thoughts on how to test?
Thanks for this @josephdpurcell! The approach here looks reasonable, and your example .codeclimate.yml
looks correct. For testing it, I would suggest building this version of the image locally (docker build -t codeclimate/codeclimate-phpcodesniffer .
), and then running codeclimate analyze
on a local project with that configuration to confirm you're getting the expected results.
I was able to successfully test this. Here are the steps I took:
git clone --branch feature/drupal git@github.com:josephdpurcell/codeclimate-phpcodesniffer.git
cd codeclimate-phpcodesniffer
docker build -t codeclimate/codeclimate-phpcodesniffer .
cd ..
git clone git@github.com:josephdpurcell/drupal-relaxed.git
cd drupal-relaxed
codeclimate analyze
And here was the output:
root@wps:~/drupal-relaxed# codeclimate analyze
Starting analysis
Running phpcodesniffer: Done!
== relaxed.api.php (2 issues) ==
22: Missing parameter comment [phpcodesniffer]
24: Return comment must be on the next line [phpcodesniffer]
...
...
== src/Workspace/RelaxedWorkspaceNegotiator.php (5 issues) ==
1: Missing file doc comment [phpcodesniffer]
10: Missing class doc comment [phpcodesniffer]
12: Missing short description in doc comment [phpcodesniffer]
17: Missing short description in doc comment [phpcodesniffer]
18: Missing parameter comment [phpcodesniffer]
Analysis complete! Found 450 issues.
So, as far as I can tell this PR will meet the objective of supporting Drupal code sniffs with PHPCS.
Closing in favor of https://github.com/codeclimate/codeclimate-phpcodesniffer/pull/34.
This addresses https://github.com/codeclimate/codeclimate-phpcodesniffer/issues/30.
While this solution varies from https://github.com/codeclimate/codeclimate-phpcodesniffer/pull/29, I suspect we would want to find a generic way to add code standards to Code Climate's PHPCS. Perhaps the best alternative is to request PHPCS itself to support these sniffs.
I have not tested to verify this PR works. Next step should be to verify it.
Side note: I generated the list of sniffs that Drupal has by running
phpcs -e --standard="Drupal"
.