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

Julian picture Julian · Sep 6, 2012 · Viewed 7.6k times · Source

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

Answer

Nick picture Nick · Oct 17, 2012

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