-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from phpmd/master
merge master
- Loading branch information
Showing
59 changed files
with
1,519 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace PHPMD\Baseline; | ||
|
||
class BaselineMode | ||
{ | ||
/** | ||
* Do not generate or update any baseline file | ||
*/ | ||
const NONE = 'none'; | ||
|
||
/** | ||
* Generate a baseline file for _all_ current violations | ||
*/ | ||
const GENERATE = 'generate'; | ||
|
||
/** | ||
* Remove any non existing violations from the baseline file. Do not baseline any new violations. | ||
*/ | ||
const UPDATE = 'update'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace PHPMD\Baseline; | ||
|
||
use PHPMD\RuleViolation; | ||
|
||
class BaselineValidator | ||
{ | ||
/** @var string */ | ||
private $baselineMode; | ||
|
||
/** @var BaselineSet */ | ||
private $baselineSet; | ||
|
||
/** | ||
* @param string $baselineMode | ||
*/ | ||
public function __construct(BaselineSet $baselineSet, $baselineMode) | ||
{ | ||
$this->baselineMode = $baselineMode; | ||
$this->baselineSet = $baselineSet; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isBaselined(RuleViolation $violation) | ||
{ | ||
$contains = $this->baselineSet->contains( | ||
get_class($violation->getRule()), | ||
$violation->getFileName(), | ||
$violation->getMethodName() | ||
); | ||
|
||
// regular baseline: violations is baselined if it is in the BaselineSet | ||
if ($this->baselineMode === BaselineMode::NONE) { | ||
return $contains; | ||
} | ||
|
||
// update baseline: violation _can_ be baselined if it was already in the BaselineSet | ||
if ($this->baselineMode === BaselineMode::UPDATE) { | ||
return $contains === false; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.