From 69cc83a04abd526af8b275e66556e5b5fe71f0b6 Mon Sep 17 00:00:00 2001 From: Cam Spiers Date: Sat, 10 Aug 2013 13:34:19 +1200 Subject: [PATCH 1/7] Check if build artifacts exist before deleting them --- PHPCI/Plugin/Pdepend.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/PHPCI/Plugin/Pdepend.php b/PHPCI/Plugin/Pdepend.php index 95a7a8c0..285c86bc 100644 --- a/PHPCI/Plugin/Pdepend.php +++ b/PHPCI/Plugin/Pdepend.php @@ -68,11 +68,7 @@ class Pdepend implements \PHPCI\Plugin $cmd = PHPCI_BIN_DIR . 'pdepend --summary-xml=%s --jdepend-chart=%s --overview-pyramid=%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(); $success = $this->phpci->executeCommand( $cmd, $this->location . DIRECTORY_SEPARATOR . $this->summary, @@ -101,4 +97,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); + } + } + } +} From 15ffbf963d7962fa74c46ba753448057cadcb294 Mon Sep 17 00:00:00 2001 From: Cam Spiers Date: Sat, 10 Aug 2013 13:36:55 +1200 Subject: [PATCH 2/7] Allow project names with spaces to work with depend build artefacts --- PHPCI/Plugin/Pdepend.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PHPCI/Plugin/Pdepend.php b/PHPCI/Plugin/Pdepend.php index 95a7a8c0..73ca2287 100644 --- a/PHPCI/Plugin/Pdepend.php +++ b/PHPCI/Plugin/Pdepend.php @@ -66,7 +66,7 @@ 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"'; //Remove the created files first unlink($this->location . DIRECTORY_SEPARATOR . $this->summary); From 5f2b5fc2e727d9e31bbaba3c0bf2560b8eb4e287 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Thu, 15 Aug 2013 16:22:47 +0200 Subject: [PATCH 3/7] Support local PHPMD rules and suffixes Allows to specify rules as a relative path in the project. The suffixes to scan can be given in options now, default is just php. --- PHPCI/Plugin/PhpMessDetector.php | 44 +++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 9 deletions(-) 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); } } From aedac8498b0ee2f1ddeac1a73e6b8340372d2f44 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Thu, 15 Aug 2013 16:23:53 +0200 Subject: [PATCH 4/7] Support suffixes for PHPCS The suffixes to scan can be given in options now, default is just php. --- PHPCI/Plugin/PhpCodeSniffer.php | 49 +++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 9 deletions(-) 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); } } From 0c95d27056564471149e3f4a177fefec1db01627 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Thu, 15 Aug 2013 17:28:25 +0200 Subject: [PATCH 5/7] Use composer without ANSI output and interaction --- PHPCI/Plugin/Composer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); } } From 2a8098f431177f5d79fa920b7e892334a8576301 Mon Sep 17 00:00:00 2001 From: Cam Spiers Date: Sat, 10 Aug 2013 13:28:51 +1200 Subject: [PATCH 6/7] Honour the ignore directive in Pdepend plugin --- PHPCI/Plugin/Pdepend.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/PHPCI/Plugin/Pdepend.php b/PHPCI/Plugin/Pdepend.php index 74c3be81..2a26cbb0 100644 --- a/PHPCI/Plugin/Pdepend.php +++ b/PHPCI/Plugin/Pdepend.php @@ -66,14 +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"'; $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 ); From 5b148ecc8ea69e5e26f61b05880f936ed65ffee4 Mon Sep 17 00:00:00 2001 From: Cam Spiers Date: Tue, 20 Aug 2013 21:58:26 +1200 Subject: [PATCH 7/7] Fix issue with non-use resources are loaded from an ssl served document --- PHPCI/View/Session/login.phtml | 2 +- PHPCI/View/layout.phtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 @@ - +