From 2a0e6d2401328be10c8afdd38fae2c8287965ed7 Mon Sep 17 00:00:00 2001 From: Alexander Pirogov Date: Fri, 19 Jul 2013 16:40:16 +0300 Subject: [PATCH] added rules option to phpmd plugin --- PHPCI/Plugin/PhpMessDetector.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/PHPCI/Plugin/PhpMessDetector.php b/PHPCI/Plugin/PhpMessDetector.php index ea6ff959..d2a2e3dc 100644 --- a/PHPCI/Plugin/PhpMessDetector.php +++ b/PHPCI/Plugin/PhpMessDetector.php @@ -18,10 +18,16 @@ namespace PHPCI\Plugin; class PhpMessDetector implements \PHPCI\Plugin { protected $directory; + /** + * Array of PHPMD rules. Possible values: codesize, unusedcode, naming, design, controversial + * @var array + */ + protected $rules; public function __construct(\PHPCI\Builder $phpci, array $options = array()) { $this->phpci = $phpci; + $this->rules = isset($options['rules']) ? (array)$options['rules'] : array('codesize', 'unusedcode', 'naming'); } /** @@ -35,7 +41,7 @@ class PhpMessDetector implements \PHPCI\Plugin $ignore = ' --exclude ' . implode(',', $this->phpci->ignore); } - $cmd = PHPCI_BIN_DIR . 'phpmd "%s" text codesize,unusedcode,naming %s'; - return $this->phpci->executeCommand($cmd, $this->phpci->buildPath, $ignore); + $cmd = PHPCI_BIN_DIR . 'phpmd "%s" text %s %s'; + return $this->phpci->executeCommand($cmd, $this->phpci->buildPath, implode(',', $this->rules), $ignore); } }