Skip to content

Conversation

@josephdpurcell
Copy link
Contributor

@josephdpurcell josephdpurcell commented May 31, 2016

This addresses #30.

While this solution varies from #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".

@josephdpurcell
Copy link
Contributor Author

This PR is likely blocked by #33.

@josephdpurcell
Copy link
Contributor Author

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?

@wfleming
Copy link
Contributor

wfleming commented Jun 2, 2016

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.

@josephdpurcell
Copy link
Contributor Author

I was able to successfully test this. Here are the steps I took:

  1. Install code climate
  2. git clone --branch feature/drupal git@github.com:josephdpurcell/codeclimate-phpcodesniffer.git
  3. cd codeclimate-phpcodesniffer
  4. docker build -t codeclimate/codeclimate-phpcodesniffer .
  5. cd ..
  6. git clone git@github.com:josephdpurcell/drupal-relaxed.git
  7. cd drupal-relaxed
  8. Modify the .codeclimate.yml to have just "Drupal" for the standard
  9. 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.

@josephdpurcell
Copy link
Contributor Author

Closing in favor of #34.

@josephdpurcell josephdpurcell deleted the feature/drupal branch June 8, 2016 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants