Add ability to specify sub path and override global ignore list in phpci.yml

This commit is contained in:
Stephen Brooks 2013-09-18 09:54:23 +01:00
commit f5c7f85bed
3 changed files with 51 additions and 9 deletions

19
PHPCI/Plugin/PhpCodeSniffer.php Normal file → Executable file
View file

@ -47,6 +47,17 @@ class PhpCodeSniffer implements \PHPCI\Plugin
*/
protected $encoding;
/**
* @var string, based on the assumption the root may not hold the code to be
* tested, exteds the base path
*/
protected $path;
/**
* @var array - paths to ignore
*/
protected $ignore;
/**
* @param \PHPCI\Builder $phpci
* @param array $options
@ -59,6 +70,8 @@ class PhpCodeSniffer implements \PHPCI\Plugin
$this->standard = isset($options['standard']) ? $options['standard'] : 'PSR2';
$this->tab_width = isset($options['tab_width']) ? $options['tab_width'] : '';
$this->encoding = isset($options['encoding']) ? $options['encoding'] : '';
$this->path = (isset($options['path'])) ? $options['path'] : '';
$this->ignore = (isset($options['ignore'])) ? (array)$options['ignore'] : $this->phpci->ignore;
}
/**
@ -67,8 +80,8 @@ class PhpCodeSniffer implements \PHPCI\Plugin
public function execute()
{
$ignore = '';
if (count($this->phpci->ignore)) {
$ignore = ' --ignore=' . implode(',', $this->phpci->ignore);
if (count($this->ignore)) {
$ignore = ' --ignore=' . implode(',', $this->ignore);
}
if (strpos($this->standard, '/') !== false) {
@ -93,6 +106,6 @@ class PhpCodeSniffer implements \PHPCI\Plugin
}
$cmd = PHPCI_BIN_DIR . 'phpcs %s %s %s %s %s "%s"';
return $this->phpci->executeCommand($cmd, $standard, $suffixes, $ignore, $tab_width, $encoding, $this->phpci->buildPath);
return $this->phpci->executeCommand($cmd, $standard, $suffixes, $ignore, $tab_width, $encoding, $this->phpci->buildPath . $this->path);
}
}