Skip to content

Commit

Permalink
Fixed a problem where excluding a message from a custom standard's ow…
Browse files Browse the repository at this point in the history
…n sniff would exclude the whole sniff (ref #1480)
  • Loading branch information
gsherwood committed Jun 6, 2017
1 parent e5790ec commit 046deb2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- If ommitted, the namespace is assumed to be the same as the directory name containing the ruleset.xml file
-- The namespace is set in the ruleset tag of the ruleset.xml file
-- e.g., ruleset name="My Coding Standard" namespace="MyProject\CS\Standard"
- Fixed a problem where excluding a message from a custom standard's own sniff would exclude the whole sniff
-- This caused some PSR2 errors to be under-reported
- Fixed bug #1442 : T_NULLABLE detection not working for nullable parameters and return type hints in some cases
- Fixed bug #1447 : Running the unit tests with a phpunit config file breaks the test suite
-- Unknown arguments were not being handled correctly, but are now stored in $config->unknown
Expand Down
19 changes: 11 additions & 8 deletions src/Ruleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,17 @@ public function processRuleset($rulesetPath, $depth=0)
echo "\t\t=> severity set to 5".PHP_EOL;
}
} else if (empty($newSniffs) === false) {
// Including a sniff that hasn't been included higher up, but
// only including a single message from it. So turn off all messages in
// the sniff, except this one.
$this->ruleset[$sniffCode]['severity'] = 0;
$this->ruleset[(string) $rule['ref']]['severity'] = 5;
if (PHP_CODESNIFFER_VERBOSITY > 1) {
echo str_repeat("\t", $depth);
echo "\t\tExcluding sniff \"".$sniffCode.'" except for "'.$parts[3].'"'.PHP_EOL;
$newSniff = $newSniffs[0];
if (in_array($newSniff, $ownSniffs) === false) {
// Including a sniff that hasn't been included higher up, but
// only including a single message from it. So turn off all messages in
// the sniff, except this one.
$this->ruleset[$sniffCode]['severity'] = 0;
$this->ruleset[(string) $rule['ref']]['severity'] = 5;
if (PHP_CODESNIFFER_VERBOSITY > 1) {
echo str_repeat("\t", $depth);
echo "\t\tExcluding sniff \"".$sniffCode.'" except for "'.$parts[3].'"'.PHP_EOL;
}
}
}//end if
}//end if
Expand Down

0 comments on commit 046deb2

Please sign in to comment.