diff --git a/PHPCI/Plugin/Composer.php b/PHPCI/Plugin/Composer.php index df2da277..36357986 100644 --- a/PHPCI/Plugin/Composer.php +++ b/PHPCI/Plugin/Composer.php @@ -36,7 +36,7 @@ class Composer implements \PHPCI\Plugin */ public function execute() { - $cmd = PHPCI_DIR . 'composer.phar '. ($this->preferDist ? '--prefer-dist' : null) .' --working-dir="%s" %s'; + $cmd = PHPCI_DIR . 'composer.phar --no-ansi --no-interaction '. ($this->preferDist ? '--prefer-dist' : null) .' --working-dir="%s" %s'; return $this->phpci->executeCommand($cmd, $this->directory, $this->action); } } diff --git a/PHPCI/Plugin/Pdepend.php b/PHPCI/Plugin/Pdepend.php index 95a7a8c0..2a26cbb0 100644 --- a/PHPCI/Plugin/Pdepend.php +++ b/PHPCI/Plugin/Pdepend.php @@ -66,18 +66,23 @@ class Pdepend implements \PHPCI\Plugin throw new \Exception(sprintf('The location %s is not writable.', $this->location)); } - $cmd = PHPCI_BIN_DIR . 'pdepend --summary-xml=%s --jdepend-chart=%s --overview-pyramid=%s "%s"'; + $cmd = PHPCI_BIN_DIR . 'pdepend --summary-xml="%s" --jdepend-chart="%s" --overview-pyramid="%s" %s "%s"'; - //Remove the created files first - unlink($this->location . DIRECTORY_SEPARATOR . $this->summary); - unlink($this->location . DIRECTORY_SEPARATOR . $this->chart); - unlink($this->location . DIRECTORY_SEPARATOR . $this->pyramid); + $this->removeBuildArtifacts(); + + // If we need to ignore directories + if (count($this->phpci->ignore)) { + $ignore = ' --ignore=' . implode(',', $this->phpci->ignore); + } else { + $ignore = ''; + } $success = $this->phpci->executeCommand( $cmd, $this->location . DIRECTORY_SEPARATOR . $this->summary, $this->location . DIRECTORY_SEPARATOR . $this->chart, $this->location . DIRECTORY_SEPARATOR . $this->pyramid, + $ignore, $this->directory ); @@ -101,4 +106,17 @@ class Pdepend implements \PHPCI\Plugin return $success; } -} \ No newline at end of file + + /** + * Remove files created from previous builds + */ + protected function removeBuildArtifacts() + { + //Remove the created files first + foreach (array($this->summary, $this->chart, $this->pyramid) as $file) { + if (file_exists($this->location . DIRECTORY_SEPARATOR . $file)) { + unlink($this->location . DIRECTORY_SEPARATOR . $file); + } + } + } +} diff --git a/PHPCI/Plugin/PhpCodeSniffer.php b/PHPCI/Plugin/PhpCodeSniffer.php index 8e28fd22..5986f724 100644 --- a/PHPCI/Plugin/PhpCodeSniffer.php +++ b/PHPCI/Plugin/PhpCodeSniffer.php @@ -17,13 +17,44 @@ namespace PHPCI\Plugin; */ class PhpCodeSniffer implements \PHPCI\Plugin { - protected $directory; - protected $args; + /** + * @var \PHPCI\Builder + */ protected $phpci; + /** + * @var array + */ + protected $suffixes; + + /** + * @var string + */ + protected $directory; + + /** + * @var string + */ + protected $standard; + + /** + * @var string + */ + protected $tab_width; + + /** + * @var string + */ + protected $encoding; + + /** + * @param \PHPCI\Builder $phpci + * @param array $options + */ public function __construct(\PHPCI\Builder $phpci, array $options = array()) { $this->phpci = $phpci; + $this->suffixes = isset($options['suffixes']) ? (array)$options['suffixes'] : array('php'); $this->directory = isset($options['directory']) ? $options['directory'] : $phpci->buildPath; $this->standard = isset($options['standard']) ? $options['standard'] : 'PSR2'; $this->tab_width = isset($options['tab_width']) ? $options['tab_width'] : ''; @@ -36,32 +67,32 @@ class PhpCodeSniffer implements \PHPCI\Plugin public function execute() { $ignore = ''; - if (count($this->phpci->ignore)) { $ignore = ' --ignore=' . implode(',', $this->phpci->ignore); } - $standard = ''; - if (strpos($this->standard, '/') !== false) { $standard = ' --standard='.$this->directory.$this->standard; } else { $standard = ' --standard='.$this->standard; } - $tab_width = ''; + $suffixes = ''; + if (count($this->suffixes)) { + $suffixes = ' --extensions=' . implode(',', $this->suffixes); + } + $tab_width = ''; if (strlen($this->tab_width)) { $tab_width = ' --tab-width='.$this->tab_width; } $encoding = ''; - if (strlen($this->encoding)) { $encoding = ' --encoding='.$this->encoding; } - $cmd = PHPCI_BIN_DIR . 'phpcs %s %s %s %s "%s"'; - return $this->phpci->executeCommand($cmd, $standard, $ignore, $tab_width, $encoding, $this->phpci->buildPath); + $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); } } diff --git a/PHPCI/Plugin/PhpMessDetector.php b/PHPCI/Plugin/PhpMessDetector.php index d2a2e3dc..545cb070 100644 --- a/PHPCI/Plugin/PhpMessDetector.php +++ b/PHPCI/Plugin/PhpMessDetector.php @@ -17,31 +17,57 @@ namespace PHPCI\Plugin; */ class PhpMessDetector implements \PHPCI\Plugin { - protected $directory; /** - * Array of PHPMD rules. Possible values: codesize, unusedcode, naming, design, controversial + * @var \PHPCI\Builder + */ + protected $phpci; + + /** + * @var array + */ + protected $suffixes; + + /** + * Array of PHPMD rules. Can be one of the builtins (codesize, unusedcode, naming, design, controversial) + * or a filenname (detected by checking for a / in it), either absolute or relative to the project root. * @var array */ protected $rules; + /** + * @param \PHPCI\Builder $phpci + * @param array $options + */ public function __construct(\PHPCI\Builder $phpci, array $options = array()) { - $this->phpci = $phpci; - $this->rules = isset($options['rules']) ? (array)$options['rules'] : array('codesize', 'unusedcode', 'naming'); + $this->phpci = $phpci; + + $this->suffixes = isset($options['suffixes']) ? (array)$options['suffixes'] : array('php'); + + $this->rules = isset($options['rules']) ? (array)$options['rules'] : array('codesize', 'unusedcode', 'naming'); + foreach ($this->rules as &$rule) { + if ($rule[0] !== '/' && strpos($rule, '/') !== FALSE) { + $rule = $this->phpci->buildPath . $rule; + } + } } /** - * Runs PHP Mess Detector in a specified directory. - */ + * Runs PHP Mess Detector in a specified directory. + */ public function execute() { $ignore = ''; - if (count($this->phpci->ignore)) { $ignore = ' --exclude ' . implode(',', $this->phpci->ignore); } - $cmd = PHPCI_BIN_DIR . 'phpmd "%s" text %s %s'; - return $this->phpci->executeCommand($cmd, $this->phpci->buildPath, implode(',', $this->rules), $ignore); + $suffixes = ''; + if (count($this->suffixes)) { + $suffixes = ' --suffixes ' . implode(',', $this->suffixes); + } + + $cmd = PHPCI_BIN_DIR . 'phpmd "%s" text %s %s %s'; + return $this->phpci->executeCommand($cmd, $this->phpci->buildPath, implode(',', $this->rules), $ignore, $suffixes); } } diff --git a/PHPCI/View/Session/login.phtml b/PHPCI/View/Session/login.phtml index 168d9625..adcc8210 100644 --- a/PHPCI/View/Session/login.phtml +++ b/PHPCI/View/Session/login.phtml @@ -6,7 +6,7 @@ - +