diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2021-01-04 15:05:49 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-04 15:05:49 +0300 |
commit | 70b6441475e03693aba195400a9193e941b1e43e (patch) | |
tree | 9dc6f6032b99f6776a4ecb9184677effc745537a | |
parent | d31d2a2ebb4af4039fa1eb9449661963977bcdcd (diff) | |
parent | 3c16d2785c11dfa6f9df57acece0670e9590bf1d (diff) |
Merge pull request #612 from nextcloud/enh/psalmv21.0.0beta5
Add Psalm
-rw-r--r-- | .github/workflows/static-analysis.yml | 26 | ||||
-rw-r--r-- | composer.json | 6 | ||||
-rw-r--r-- | composer.lock | 36 | ||||
-rw-r--r-- | lib/Controller/AlbumsController.php | 6 | ||||
-rw-r--r-- | lib/Controller/ApiController.php | 2 | ||||
-rw-r--r-- | psalm.xml | 32 | ||||
-rw-r--r-- | tests/psalm-baseline.xml | 24 |
7 files changed, 125 insertions, 7 deletions
diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 00000000..4f40268c --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -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 diff --git a/composer.json b/composer.json index f5e7f9c3..731f06a1 100644 --- a/composer.json +++ b/composer.json @@ -10,10 +10,12 @@ "scripts": { "cs:fix": "php-cs-fixer fix", "cs:check": "php-cs-fixer fix --dry-run --diff", - "lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l" + "lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l", + "psalm": "psalm.phar" }, "require-dev": { "nextcloud/coding-standard": "^0.4.0", - "phpunit/phpunit": "^7" + "phpunit/phpunit": "^7", + "psalm/phar": "^4.3" } } diff --git a/composer.lock b/composer.lock index 6c11c389..cb9f6ae2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ebb4ce5e997a9089c170172fbfb9e83f", + "content-hash": "8bfeacd0cfc0148e47f2c358d639fab9", "packages": [], "packages-dev": [ { @@ -1262,6 +1262,37 @@ "time": "2020-01-08T08:45:45+00:00" }, { + "name": "psalm/phar", + "version": "4.3.1", + "source": { + "type": "git", + "url": "https://github.com/psalm/phar.git", + "reference": "f61d8f0eaaf5f7c26f1269ddeaf1fbe29dff1bee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/psalm/phar/zipball/f61d8f0eaaf5f7c26f1269ddeaf1fbe29dff1bee", + "reference": "f61d8f0eaaf5f7c26f1269ddeaf1fbe29dff1bee", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "vimeo/psalm": "*" + }, + "bin": [ + "psalm.phar" + ], + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer-based Psalm Phar", + "time": "2020-12-03T21:44:12+00:00" + }, + { "name": "psr/container", "version": "1.0.0", "source": { @@ -3505,5 +3536,8 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], + "platform-overrides": { + "php": "7.3" + }, "plugin-api-version": "1.1.0" } diff --git a/lib/Controller/AlbumsController.php b/lib/Controller/AlbumsController.php index 67560248..48862927 100644 --- a/lib/Controller/AlbumsController.php +++ b/lib/Controller/AlbumsController.php @@ -33,7 +33,7 @@ use OCP\AppFramework\Http\JSONResponse; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; -use OCP\FIles\Node; +use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\Files\StorageNotAvailableException; use OCP\IPreview; @@ -43,10 +43,10 @@ class AlbumsController extends Controller { /** @var string */ private $userId; - + /** @var IRootFolder */ private $rootFolder; - + /** @var IPreview */ private $previewManager; diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index 0b247249..4c89566e 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -77,7 +77,7 @@ class ApiController extends Controller { * @NoAdminRequired * @NoCSRFRequired */ - public function serviceWorker() { + public function serviceWorker(): StreamResponse { $response = new StreamResponse(__DIR__.'/../../js/photos-service-worker.js'); $response->setHeaders([ 'Content-Type' => 'application/javascript', diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 00000000..77f99494 --- /dev/null +++ b/psalm.xml @@ -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> diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml new file mode 100644 index 00000000..a5efd6d7 --- /dev/null +++ b/tests/psalm-baseline.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<files psalm-version="4.3.1@2feba22a005a18bf31d4c7b9bdb9252c73897476"> + <file src="lib/Controller/AlbumsController.php"> + <MissingDependency occurrences="5"> + <code>$this->rootFolder</code> + <code>$this->rootFolder</code> + <code>IRootFolder</code> + <code>IRootFolder</code> + <code>StorageNotAvailableException</code> + </MissingDependency> + <UndefinedClass occurrences="2"> + <code>SharedStorage</code> + <code>\OCA\GroupFolders\Mount\GroupFolderStorage</code> + </UndefinedClass> + </file> + <file src="lib/Controller/PageController.php"> + <UndefinedClass occurrences="4"> + <code>LoadSidebar</code> + <code>LoadSidebar</code> + <code>LoadViewer</code> + <code>LoadViewer</code> + </UndefinedClass> + </file> +</files> |