Permalink
Browse files

add --ignore-exit-violations CLI flag to allow exit code 0 event if v…

…iolation is found (will allow successfull build for CI)
  • Loading branch information...
jaymoulin committed Jun 24, 2016
1 parent 0995c85 commit 9f71d9847446a6efb92ffac1b53ab53ec8d98d0c
Showing with 24 additions and 2 deletions.
  1. +1 −1 src/main/php/PHPMD/TextUI/Command.php
  2. +23 −1 src/main/php/PHPMD/TextUI/CommandLineOptions.php
@@ -129,7 +129,7 @@ public function run(CommandLineOptions $opts, RuleSetFactory $ruleSetFactory)
$ruleSetFactory
);
if ($phpmd->hasViolations()) {
if ($phpmd->hasViolations() && !$opts->hasIgnoreExitViolations()) {
return self::EXIT_VIOLATION;
}
return self::EXIT_SUCCESS;
@@ -139,6 +139,13 @@ class CommandLineOptions
*/
protected $strict = false;
/**
* Should PHPMD exit without error code even if violation is found?
*
* @var boolean
*/
protected $ignoreExitViolations = false;
/**
* List of available rule-sets.
*
@@ -193,6 +200,9 @@ public function __construct(array $args, array $availableRuleSets = array())
case '--strict':
$this->strict = true;
break;
case '--ignore-exit-violations':
$this->ignoreExitViolations = true;
break;
case (preg_match('(^\-\-reportfile\-(xml|html|text)$)', $arg, $match) > 0):
$this->reportFiles[$match[1]] = array_shift($args);
break;
@@ -327,6 +337,16 @@ public function hasStrict()
return $this->strict;
}
/**
* Was the <b>--ignore-exit-violations</b> passed to PHPMD's command line interface?
*
* @return boolean
*/
public function hasIgnoreExitViolations()
{
return $this->ignoreExitViolations;
}
/**
* Creates a report renderer instance based on the user's command line
* argument.
@@ -438,7 +458,9 @@ public function usage()
'--exclude: comma-separated string of patterns that are used to ' .
'ignore directories' . \PHP_EOL .
'--strict: also report those nodes with a @SuppressWarnings ' .
'annotation' . \PHP_EOL;
'annotation' . \PHP_EOL .
'--ignore-exit-violations: will exit with 0 even if a ' .
'violation is found ' . \PHP_EOL;
}
/**

0 comments on commit 9f71d98

Please sign in to comment.