-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding psalm, have a validation on code coverage, php 8.0
- Loading branch information
Showing
6 changed files
with
98 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
$inputFile = $argv[1]; | ||
$percentage = min(100, max(0, (int) $argv[2])); | ||
|
||
if (!file_exists($inputFile)) { | ||
throw new InvalidArgumentException('Invalid input file provided'); | ||
} | ||
|
||
if (!$percentage) { | ||
throw new InvalidArgumentException('An integer checked percentage must be given as second parameter'); | ||
} | ||
|
||
$xml = new SimpleXMLElement(file_get_contents($inputFile)); | ||
$metrics = $xml->xpath('//metrics'); | ||
$totalElements = 0; | ||
$checkedElements = 0; | ||
|
||
foreach ($metrics as $metric) { | ||
$totalElements += (int) $metric['elements']; | ||
$checkedElements += (int) $metric['coveredelements']; | ||
} | ||
|
||
$coverage = ($checkedElements / $totalElements) * 100; | ||
|
||
if ($coverage < $percentage) { | ||
echo 'Code coverage is ' . $coverage . '%, which is below the accepted ' . $percentage . '%' . PHP_EOL; | ||
exit(1); | ||
} | ||
|
||
echo 'Code coverage is ' . $coverage . '% - OK!' . PHP_EOL; |
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,55 @@ | ||
<?xml version="1.0"?> | ||
<psalm | ||
errorLevel="3" | ||
resolveFromConfigFile="true" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="https://getpsalm.org/schema/config" | ||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | ||
> | ||
<projectFiles> | ||
<directory name="src" /> | ||
<directory name="tests" /> | ||
<ignoreFiles> | ||
<directory name="vendor" /> | ||
</ignoreFiles> | ||
</projectFiles> | ||
|
||
<issueHandlers> | ||
<PropertyNotSetInConstructor> | ||
<errorLevel type="suppress"> | ||
<directory name="tests"/> | ||
</errorLevel> | ||
</PropertyNotSetInConstructor> | ||
|
||
<PossiblyUndefinedMethod> | ||
<errorLevel type="suppress"> | ||
<directory name="tests"/> | ||
</errorLevel> | ||
</PossiblyUndefinedMethod> | ||
|
||
<PossiblyInvalidArgument> | ||
<errorLevel type="suppress"> | ||
<directory name="tests"/> | ||
</errorLevel> | ||
</PossiblyInvalidArgument> | ||
|
||
<MismatchingDocblockPropertyType> | ||
<errorLevel type="suppress"> | ||
<directory name="tests"/> | ||
</errorLevel> | ||
</MismatchingDocblockPropertyType> | ||
|
||
<MixedMethodCall> | ||
<errorLevel type="suppress"> | ||
<directory name="tests"/> | ||
</errorLevel> | ||
</MixedMethodCall> | ||
|
||
<InvalidThrow> | ||
<errorLevel type="suppress"> | ||
<file name="src/Repository/CacheRepository.php"/> | ||
<file name="tests/Unit/Repository/CacheRepositoryTest.php"/> | ||
</errorLevel> | ||
</InvalidThrow> | ||
</issueHandlers> | ||
</psalm> |
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