Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why aren't CodeSniffer excluding the --ignore specified folders?

I'm using Jenkins(Hudson) CI, and every night analysing the code using a number of tools for repporting, including Codesniffer for Checkstyle reports. I wan't it to ignore the ./framework/* directory, but it insists on including it, regardless of my efforts with the --ignore parameter.

The report is created and parsed successfully, but not really of any use to us because of the extreme amount of violations of the Pear Coding standards in the framework.

Codesniffer is called from my Ant build-script like this:

<target name="phpcs-ci" description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
 <exec executable="phpcs" dir="${basedir}" output="${basedir}/build/logs/checkstyle.xml" failonerror="off">
  <arg line="--report=checkstyle --standard=${basedir}/build/phpcs.xml --extensions=php  --ignore=*/framework/* ${basedir}" />
 </exec>
</target>

I've tried --ignore=framework, --ignore=framework/, and the one in the line above, all from examples I've found around the web.

I've also tried using a different line for each argument (using < arg value"..." /> ), but to no avail.

Any ideas? Much appreciated :)

Edit: The --ignore argument is now:

--ignore=${basedir}/framework/

...And still, the framework folder is being included. Does anyone out there have a working PhpCodeSniffer configuration, with an --ignore argument, working?

Crossing fingers here

like image 458
Julian Avatar asked Sep 06 '12 11:09

Julian


2 Answers

I was having the same problem in Jenkins and above answer helped me to some extent. This is what I have now (and works on my system).

If your system looks like this:

/
/build.xml
/foo
/foo/bar

This is what I have in my build.xml

  <target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="phpcs">
  <arg value="--standard=${basedir}/build/phpcs.xml" />
  <arg value="--ignore=foo/bar" />
  <arg path="${basedir}" />
</exec>

The trick was not to use ${basedir} and to lose the trailing slash of the directory.

I hope it helps

like image 130
Nick Avatar answered Oct 06 '22 23:10

Nick


It's also possible to place these exclusions in build/phpcs.xml. Working fine here in Jenkins.

Examples for excluding all files in js/facebook dir, wildcard match for js/jquery* and a specified filename.

<exclude-pattern>lib/facebook</exclude-pattern>
<exclude-pattern>js/jquery*</exclude-pattern>
<exclude-pattern>lib/Postmark.php</exclude-pattern>
like image 5
markdwhite Avatar answered Oct 06 '22 23:10

markdwhite