Skip to content

Commit

Permalink
Merge pull request #1309 from nextcloud/enh/psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusknorr authored Dec 29, 2020
2 parents 1e4f63c + af4d014 commit abfe2fe
Show file tree
Hide file tree
Showing 5 changed files with 261 additions and 3 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Static analysis

on: [pull_request]

jobs:
static-psalm-analysis:
runs-on: ubuntu-latest
strategy:
matrix:
ocp-version: [ 'dev-master' ]
name: Nextcloud ${{ matrix.ocp-version }}
steps:
- name: Checkout
uses: actions/checkout@master
- name: Set up php
uses: shivammathur/setup-php@master
with:
php-version: 7.4
tools: composer:v1
coverage: none
- name: Install dependencies
run: composer i
- name: Install dependencies
run: composer require --dev christophwurst/nextcloud:${{ matrix.ocp-version }}
- name: Run coding standards check
run: composer run psalm
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"roave/security-advisories": "dev-master",
"christophwurst/nextcloud": "^20.0",
"jakub-onderka/php-parallel-lint": "^1.0.0",
"nextcloud/coding-standard": "^0.4.0"
"nextcloud/coding-standard": "^0.4.0",
"psalm/phar": "^4.3"
},
"license": "AGPLv3",
"authors": [
Expand All @@ -18,6 +19,7 @@
"scripts": {
"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix"
"cs:fix": "php-cs-fixer fix",
"psalm": "psalm.phar"
}
}
33 changes: 32 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
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"
errorBaseline="tests/psalm-baseline.xml"
>
<projectFiles>
<directory name="lib" />
</projectFiles>
<extraFiles>
<directory name="vendor/christophwurst/nextcloud" />
</extraFiles>
<issueHandlers>
<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="OC" />
<referencedClass name="Doctrine\DBAL\Types\Type"/>
</errorLevel>
</UndefinedClass>
<UndefinedDocblockClass>
<errorLevel type="suppress">
<referencedClass name="Doctrine\DBAL\Driver\Statement" />
<referencedClass name="Doctrine\DBAL\Schema\Schema" />
<referencedClass name="Doctrine\DBAL\Schema\SchemaException" />
<referencedClass name="Doctrine\DBAL\Schema\Table" />
<referencedClass name="Doctrine\DBAL\Statement" />
</errorLevel>
</UndefinedDocblockClass>
</issueHandlers>
</psalm>
167 changes: 167 additions & 0 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.3.1@2feba22a005a18bf31d4c7b9bdb9252c73897476">
<file src="lib/AppInfo/Application.php">
<UndefinedClass occurrences="3">
<code>BeforeTemplateRenderedEvent</code>
<code>LoadAdditionalScriptsEvent</code>
<code>LoadViewer</code>
</UndefinedClass>
</file>
<file src="lib/Command/ResetDocument.php">
<ImplementedReturnTypeMismatch occurrences="1">
<code>void</code>
</ImplementedReturnTypeMismatch>
</file>
<file src="lib/Controller/DirectSessionController.php">
<UndefinedClass occurrences="1">
<code>InvalidTokenException</code>
</UndefinedClass>
</file>
<file src="lib/Controller/PublicSessionController.php">
<MissingDependency occurrences="1">
<code>ShareNotFound</code>
</MissingDependency>
</file>
<file src="lib/Controller/SettingsController.php">
<UndefinedThisPropertyAssignment occurrences="1">
<code>$this-&gt;userId</code>
</UndefinedThisPropertyAssignment>
<UndefinedThisPropertyFetch occurrences="1">
<code>$this-&gt;userId</code>
</UndefinedThisPropertyFetch>
</file>
<file src="lib/Controller/WorkspaceController.php">
<InvalidReturnType occurrences="3">
<code>DataResponse</code>
<code>DataResponse</code>
<code>DataResponse</code>
</InvalidReturnType>
<MissingDependency occurrences="6">
<code>$this-&gt;rootFolder</code>
<code>$this-&gt;rootFolder</code>
<code>IRootFolder</code>
<code>IRootFolder</code>
<code>ShareNotFound</code>
<code>StorageNotAvailableException</code>
</MissingDependency>
<UndefinedClass occurrences="1">
<code>Exception</code>
</UndefinedClass>
<UndefinedInterfaceMethod occurrences="1">
<code>open</code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/DAV/WorkspacePlugin.php">
<UndefinedClass occurrences="1">
<code>ServerPlugin</code>
</UndefinedClass>
</file>
<file src="lib/Db/SessionMapper.php">
<MoreSpecificImplementedParamType occurrences="1"/>
</file>
<file src="lib/Db/StepMapper.php">
<InvalidReturnStatement occurrences="1"/>
<InvalidReturnType occurrences="1">
<code>int</code>
</InvalidReturnType>
</file>
<file src="lib/DirectEditing/TextDirectEditor.php">
<LessSpecificImplementedReturnType occurrences="3">
<code>array</code>
<code>array</code>
<code>array</code>
</LessSpecificImplementedReturnType>
<UndefinedInterfaceMethod occurrences="1">
<code>getToken</code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/Listeners/FilesLoadAdditionalScriptsListener.php">
<UndefinedClass occurrences="1">
<code>LoadAdditionalScriptsEvent</code>
</UndefinedClass>
</file>
<file src="lib/Listeners/LoadViewerListener.php">
<UndefinedClass occurrences="1">
<code>LoadViewer</code>
</UndefinedClass>
</file>
<file src="lib/Service/ApiService.php">
<InvalidArgument occurrences="1">
<code>$file</code>
</InvalidArgument>
<UndefinedDocblockClass occurrences="1"/>
</file>
<file src="lib/Service/DocumentService.php">
<MismatchingDocblockReturnType occurrences="1">
<code>Entity</code>
</MismatchingDocblockReturnType>
<MissingDependency occurrences="7">
<code>$this-&gt;rootFolder</code>
<code>IRootFolder</code>
<code>IRootFolder</code>
<code>ShareNotFound</code>
<code>ShareNotFound</code>
<code>ShareNotFound</code>
<code>ShareNotFound</code>
</MissingDependency>
<UndefinedClass occurrences="2">
<code>File</code>
<code>\OC\User\NoUserException</code>
</UndefinedClass>
<UndefinedMagicMethod occurrences="18">
<code>getCurrentVersion</code>
<code>getCurrentVersion</code>
<code>getCurrentVersion</code>
<code>getCurrentVersion</code>
<code>getCurrentVersion</code>
<code>getLastSavedVersion</code>
<code>getLastSavedVersion</code>
<code>getLastSavedVersionEtag</code>
<code>getLastSavedVersionTime</code>
<code>setCurrentVersion</code>
<code>setCurrentVersion</code>
<code>setData</code>
<code>setDocumentId</code>
<code>setLastSavedVersion</code>
<code>setLastSavedVersionEtag</code>
<code>setLastSavedVersionTime</code>
<code>setSessionId</code>
<code>setVersion</code>
</UndefinedMagicMethod>
<UndefinedThisPropertyFetch occurrences="1">
<code>$this-&gt;lockingProvider</code>
</UndefinedThisPropertyFetch>
</file>
<file src="lib/Service/SessionService.php">
<UndefinedDocblockClass occurrences="4">
<code>$color-&gt;b</code>
<code>$color-&gt;g</code>
<code>$color-&gt;r</code>
<code>$this-&gt;avatarManager-&gt;getGuestAvatar($userName)-&gt;avatarBackgroundColor($userName)</code>
</UndefinedDocblockClass>
<UndefinedMagicMethod occurrences="6">
<code>setColor</code>
<code>setDocumentId</code>
<code>setGuestName</code>
<code>setGuestName</code>
<code>setToken</code>
<code>setUserId</code>
</UndefinedMagicMethod>
</file>
<file src="lib/Service/WorkspaceService.php">
<InvalidNullableReturnType occurrences="1">
<code>\OCP\Files\File</code>
</InvalidNullableReturnType>
<MissingDependency occurrences="1">
<code>StorageNotAvailableException</code>
</MissingDependency>
<NullableReturnStatement occurrences="1">
<code>null</code>
</NullableReturnStatement>
</file>
<file src="vendor/christophwurst/nextcloud/OCP/BackgroundJob/TimedJob.php">
<ImplementedParamTypeMismatch occurrences="1">
<code>$jobList</code>
</ImplementedParamTypeMismatch>
</file>
</files>

0 comments on commit abfe2fe

Please sign in to comment.