Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Thank you for your help! If the status of the bug report you submitted changes, you will be notified. You may return here and check on the status or update your report at any time. The URL for your bug report is: http://pear.php.net/bugs/19246.
Bug #19246 In Eclipse CodeSniffer drops the extensions paramater
Submitted: 2012-01-24 17:27 UTC
From: barnettech Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.2)
PHP Version: 5.3.1 OS: Mac
Roadmaps: (Not assigned)    
Subscription  


 [2012-01-24 17:27 UTC] barnettech (James Barnett)
Description: ------------ I successfully installed code sniffer in Eclipse, but it only works on .php files. I right clicked on preferences->php tools ->php CodeSniffer and I set file extensions to be php,module,inc,install,test,profile,theme and still the code sniffer only flags files with the php extension. In the console I see the extensions parameter did not get set, here is what I see: /usr/bin/php -c /var/folders/q6/44cl7bwn1blfrxchzns459rh0000gp/T/zend_debu g/session3952346344543095394.tmp -d asp_tags=off /Applications/eclipse/plugins/org.phpsrc.eclipse.pti.tools.codesni ffer_1.3.0.R20111119000000/php/tools/phpcs.php --report=xml -- standard=/Users/barnettech/drush/drupalcs/DrupalCodingStand ard /Users/barnettech/Sites/belldev/git/dev/babsoncomm/docroot/si tes/all/modules/custom/folder_timerelease/folder_timerelease. module <?xml version="1.0" encoding="UTF-8"?> <phpcs version="1.3.2"> </phpcs> So I did some digging. If I insert these lines on lines 424 and 425 of /Users/barnettech/pear/share/pear/PHP/CodeSniffer/CLI.php $the_extensions = 'php,module'; $values['extensions'] = explode(',', $the_extensions); Then it will start examining files with both php and module as an extension. I just confirmed that the only thing in variable $arg when public function processLongArgument($arg, $pos, $values) gets called is: "standard=/Users/barnettech/drush/drupalcs/DrupalCodingStan dard" (that function is in the CLI.php file mentioned above). So the extensions parameter is never getting set. This bug was discussed in drupal forum: http://drupal.org/node/1414902 Expected result: ---------------- I would have expected to be able to run CodeSniffer on any file extension that I specify Actual result: -------------- The actual result is even if you specify valid extensions it only works with files with extension php.

Comments

 [2012-01-30 03:52 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz
You may want to try running phpcs on the command line to make sure it is working. I have tried it and it works correctly for me when I specify an extensions command line argument such as: phpcs --extensions=php,module ... I didn't write the eclipse plugin and have never used it, but if the command line works fine for you, then it is the eclipse plugin that is broken and not PHP_CodeSniffer. I don't see any --extensions argument in the debug output you provided, so maybe it hasn't been added correctly to the plugin.
 [2012-02-03 23:16 UTC] das_peter (Peter Philipp)
I've just posted a pull request which should fix the issue: https://github.com/pear/PHP_CodeSniffer/pull/3 The problem isn't that you can't pass extensions but according to the advanced usage documentation (http://pear.php.net/manual/en/package.php.php-codesniffer.advanced-usage.php) extensions are ignored if a file is explicitly passed. That's not the case atm. we should decide whether to change the code (my favourite) or the documentation.
 [2012-02-08 05:16 UTC] squiz (Greg Sherwood)
Try the current git version of PHP_CodeSniffer. I believe this has already been fixed and have confirmed I can NOT call phpcs on a temp.module file with latest stable but I can with the latest dev code. To grab the latest dev: pear uninstall php_codesniffer git clone git://github.com/squizlabs/PHP_CodeSniffer.git cd PHP_CodeSniffer pear install package.xml You might need to use sudo on those pear commands. Also, please submit pull requests to squizlabs/PHP_CodeSniffer in the future because I don't maintain that PEAR fork. I know it is confusing and I have no idea why someone decided to make it that way.
 [2012-02-10 21:15 UTC] das_peter (Peter Philipp)
Confirmed, latest dev works as expected. Thanks :)
 [2012-02-11 03:36 UTC] squiz (Greg Sherwood)
-Status: Feedback +Status: Closed
Good news. Thanks a lot for getting back to me.