Skip to content

Commit

Permalink
Psalm - analyze errors in travis.ci
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenekdrahos committed Sep 30, 2017
1 parent 946d30e commit 718e5fb
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/ci.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

./phpqa --verbose --report --config tests/.travis --tools phpcs:0,php-cs-fixer:0,phpmd:0,phpcpd:0,parallel-lint:0,phpstan:0,phpmetrics:0,phploc,pdepend,phpunit:0,psalm
./phpqa --verbose --report --config tests/.travis --tools phpcs:0,php-cs-fixer:0,phpmd:0,phpcpd:0,parallel-lint:0,phpstan:0,phpmetrics:0,phploc,pdepend,phpunit:0,psalm:0
2 changes: 1 addition & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private function loadConfig($directory, $isUserDirectory = false)
$configDir = $directory . '/';
$configFile = "{$configDir}.phpqa.yml";
if (file_exists($configFile)) {
$config = Yaml::parse(file_get_contents($configFile));
$config = Yaml::parse((string) file_get_contents($configFile));
$this->configs = array_merge(
array($configDir => $config),
$this->configs
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/GetVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private function findComposerPackages()
return [];
}

$installedTools = json_decode(file_get_contents($installedJson));
$installedTools = json_decode((string) file_get_contents($installedJson));
if (!is_array($installedTools)) {
return [];
}
Expand Down
4 changes: 4 additions & 0 deletions tests/.travis/.phpqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ phpcs:
info: phpcs-info.txt
full: phpcs-full.txt

psalm:
config: psalm.xml
deadCode: true

phpstan:
level: 7
# https://github.com/phpstan/phpstan#configuration
Expand Down
69 changes: 69 additions & 0 deletions tests/.travis/psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0"?>
<psalm
name="Example Psalm config with recommended defaults"
stopOnFirstError="false"
useDocblockTypes="true"
totallyTyped="false"
>
<projectFiles>
<directory name="./" />
<ignoreFiles>
<directory name="vendor" />
<file name="src/Task/NonParallelExecV0.php" />
<file name="src/Task/NonParallelExecV1.php" />
<file name="src/Task/RoboAdapter.php" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<!-- phpqa specifics (compatibility classes, dynamic tools, ...) -->
<UnusedClass>
<errorLevel type="info">
<directory name="tests" />
<directory name="src/Tools/Analyzer" />
</errorLevel>
</UnusedClass>
<UndefinedClass>
<errorLevel type="info">
<file name="src/Tools/Analyzer/Phpcs.php" />
<file name="src/Tools/Analyzer/PhpcsV3.php" />
</errorLevel>
</UndefinedClass>
<PossiblyUnusedMethod>
<errorLevel type="info">
<file name="src/CodeAnalysisTasks.php" />
<file name="src/Tools/Tool.php" />
<file name="src/RunningTool.php" />
</errorLevel>
<errorLevel type="suppress">
<directory name="tests" />
</errorLevel>
</PossiblyUnusedMethod>
<DeprecatedMethod errorLevel="info" />

<!-- Ignored rules -->
<PropertyNotSetInConstructor errorLevel="info" />
<UndefinedConstant errorLevel="info" />
<MissingReturnType errorLevel="suppress" />
<MissingPropertyType errorLevel="suppress" />
<MissingClosureReturnType errorLevel="suppress" />
<MissingPropertyDeclaration errorLevel="suppress" />
<UntypedParam errorLevel="suppress" />

<!-- false positive -->
<UnusedVariable errorLevel="info" />
<PossiblyUnusedVariable errorLevel="info" />
<UndefinedThisPropertyAssignment errorLevel="info" />
<TooFewArguments>
<errorLevel type="info">
<file name="src/report.php" /><!-- Too few arguments for method XSLTProcessor::setparameter -->
</errorLevel>
</TooFewArguments>
<TooManyArguments>
<errorLevel type="suppress">
<directory name="tests" /><!-- Too many arguments for method assertthat -->
</errorLevel>
</TooManyArguments>

</issueHandlers>
</psalm>

0 comments on commit 718e5fb

Please # to comment.