I have written a little script to install Drupal Code Sniffer in a git repository. A patch is attached in the following comment with it. It is very helpful if someone wants to get set up quickly.

Comments

klausi’s picture

Status: Active » Postponed (maintainer needs more info)

Patch/script is missing?

juampynr’s picture

Status: Postponed (maintainer needs more info) » Needs review

Here it is. However, the symlink generates a dummy link like the following:

juampy@juampy-box:~/projects/modules/drupalcs (7.x-1.x)$ ls -al Drupal/Drupal
lrwxrwxrwx 1 root root 45 Aug 30 22:44 Drupal/Drupal -> /home/juampy/projects/modules/drupalcs/Drupal

Apart from that, after running it you can see how the pre-commit hook fires the code sniffer.

If you want to test it, uninstall PHP Code Sniffer (sudo pear uninstall PHP_CodeSniffer), apply this patch and read the usage instructions.

juampynr’s picture

StatusFileSize
new1.36 KB

Doh! Here it is.

klausi’s picture

Project: Drupal Code Sniffer » Coder
Version: 7.x-1.x-dev » 7.x-2.x-dev
Component: Code » Code Sniffer
Category: bug » feature

Drupalcs has been merged into coder, moving this issue.

douggreen’s picture

Title: Script to configure a git repository to use this project » Drush command to install and configure
Status: Needs review » Needs work

I've added a hook_requirements check for PHP_CodeSniffer and started a drush command to install and configure it. I'd like to see more options, to allow things like adding the pre-commit hooks for git. See #1763674: Script to configure a git repository to use this project. I created the new issue because I am not yet doing git pre-commits, just hook_requirements and a drush install. But even so, can we mark this a duplicate?

douggreen’s picture

IMO, if we add pre-commit hooks, it should tie into drush coder-review and run all of the reviews ... but before we do this, I'd like to see us cleanup the reviews to things like "required", "suggested", "strict", etc... and the reviews might use the coder regex, grep, or sniffs.

douggreen’s picture

Title: Drush command to install and configure » Script to configure a git repository to use this project

sorry, I didn't want to change this title ..

lars toomre’s picture

@douggreen - What do we need to move reviews to categories like "required", "suggested", "strict", etc? Is there an issue for this reorganization? I did not see one.

Perhaps you could open the issue and detail what you are thinking so that we can start to work towards that?

I really like the idea of hvaing git pre-commit hooks that run Coder on a proposed piece of code and would like to see this feature in Coder 7.2/8.x. Thanks in advance.

klausi’s picture

Component: Code Sniffer » Coder Sniffer
Issue summary: View changes
Status: Needs work » Closed (won't fix)

Coder 7.x is frozen now and will not receive updates. Coder 8.x-2.x can be used to check code for any Drupal version, Coder 8.x-2.x also supports the phpcbf command to automatically fix conding standard errors. Please check if this issue is still relevant and reopen against that version if necessary.