summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Brahmer <info@b-brahmer.de>2021-02-17 17:26:34 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-02-20 14:07:50 +0100
commit30ce6196b8979fbc00b0a12f29050239f9659c1d (patch)
tree1b05d03abf253e067d85a192e30eb23d9387075f
parent4a107b3d53c4fe651ac704251b99e04a53cd587f (diff)
Add phpstan plugins
remove leftovers from psalm move phpstan and phpcs to static code check Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
-rw-r--r--.github/workflows/api-php-static-code-check.yml51
-rw-r--r--.github/workflows/api-php-tests.yml6
-rw-r--r--composer.json3
-rw-r--r--composer.lock170
-rw-r--r--psalm.xml35
-rw-r--r--tests/psalm-autoload.php13
-rw-r--r--tests/psalm-baseline.xml76
7 files changed, 223 insertions, 131 deletions
diff --git a/.github/workflows/api-php-static-code-check.yml b/.github/workflows/api-php-static-code-check.yml
new file mode 100644
index 000000000..cefac1657
--- /dev/null
+++ b/.github/workflows/api-php-static-code-check.yml
@@ -0,0 +1,51 @@
+name: Static analysis
+on:
+ pull_request
+jobs:
+ static-phpstan-analysis:
+ runs-on: ubuntu-latest
+ continue-on-error: true
+ strategy:
+ matrix:
+ php-versions: [ '7.4' ]
+ nextcloud: [ 'stable21' ]
+ database: [ 'sqlite' ]
+ name: "phpstan: Nextcloud ${{ matrix.nextcloud }}"
+ steps:
+ - name: Checkout
+ uses: actions/checkout@master
+ - name: Set up php
+ uses: shivammathur/setup-php@master
+ with:
+ php-version: 7.4
+ extensions: pdo_sqlite,pdo_mysql,pdo_pgsql,gd,zip
+ coverage: none
+
+ - name: Set up server non MySQL
+ uses: SMillerDev/nextcloud-actions/setup-nextcloud@main
+ with:
+ cron: true
+ version: ${{ matrix.nextcloud }}
+ database-type: ${{ matrix.database }}
+
+ - name: Build app
+ run: make
+
+ - name: Configure server with app
+ uses: SMillerDev/nextcloud-actions/setup-nextcloud-app@main
+ with:
+ app: 'news'
+ check-code: true
+ force: true
+
+ - name: Prep code scanning
+ working-directory: ../server/apps/news
+ run: make php-test-dependencies
+
+ - name: PHPCS
+ working-directory: ../server/apps/news
+ run: pwd && make phpcs #debug pwd
+
+ - name: PHPStan
+ working-directory: ../server/apps/news
+ run: make phpstan \ No newline at end of file
diff --git a/.github/workflows/api-php-tests.yml b/.github/workflows/api-php-tests.yml
index fa4d4a9dd..2a152480b 100644
--- a/.github/workflows/api-php-tests.yml
+++ b/.github/workflows/api-php-tests.yml
@@ -47,12 +47,6 @@ jobs:
- name: Prep PHP tests
working-directory: ../server/apps/news
run: make php-test-dependencies
- - name: PHPCS
- working-directory: ../server/apps/news
- run: make phpcs
- - name: PHPStan
- working-directory: ../server/apps/news
- run: make phpstan
- name: Unittests
working-directory: ../server/apps/news
run: make unit-test
diff --git a/composer.json b/composer.json
index 0af736804..8858e3c83 100644
--- a/composer.json
+++ b/composer.json
@@ -57,6 +57,9 @@
"phpunit/phpunit": "9.5.*",
"squizlabs/php_codesniffer": "^3.5.6",
"phpstan/phpstan": "^0.12.43",
+ "phpstan/phpstan-doctrine": "^0.12.22",
+ "phpstan/phpstan-phpunit": "^0.12.16",
+ "phpstan/extension-installer": "^1.0",
"guzzlehttp/guzzle": "^7.2",
"doctrine/dbal": "^3.0",
"symfony/console": "^4.4.18",
diff --git a/composer.lock b/composer.lock
index e47ffbe69..19aa60029 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": "bdc53136c5f4755e561fa4d088ceac0d",
+ "content-hash": "2e3812e44e38a2c33ac501d96007c786",
"packages": [
{
"name": "andreskrey/readability.php",
@@ -1270,6 +1270,51 @@
"time": "2020-12-19T10:15:11+00:00"
},
{
+ "name": "phpstan/extension-installer",
+ "version": "1.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/extension-installer.git",
+ "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/66c7adc9dfa38b6b5838a9fb728b68a7d8348051",
+ "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051",
+ "shasum": ""
+ },
+ "require": {
+ "composer-plugin-api": "^1.1 || ^2.0",
+ "php": "^7.1 || ^8.0",
+ "phpstan/phpstan": ">=0.11.6"
+ },
+ "require-dev": {
+ "composer/composer": "^1.8",
+ "phing/phing": "^2.16.3",
+ "php-parallel-lint/php-parallel-lint": "^1.2.0",
+ "phpstan/phpstan-strict-rules": "^0.11 || ^0.12"
+ },
+ "type": "composer-plugin",
+ "extra": {
+ "class": "PHPStan\\ExtensionInstaller\\Plugin"
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\ExtensionInstaller\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Composer plugin for automatic installation of PHPStan extensions",
+ "support": {
+ "issues": "https://github.com/phpstan/extension-installer/issues",
+ "source": "https://github.com/phpstan/extension-installer/tree/1.1.0"
+ },
+ "time": "2020-12-13T13:06:13+00:00"
+ },
+ {
"name": "phpstan/phpstan",
"version": "0.12.77",
"source": {
@@ -1330,6 +1375,129 @@
"time": "2021-02-17T16:22:19+00:00"
},
{
+ "name": "phpstan/phpstan-doctrine",
+ "version": "0.12.32",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpstan-doctrine.git",
+ "reference": "815dd47ade8120c6850c5a3805649c96fbadbdca"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/815dd47ade8120c6850c5a3805649c96fbadbdca",
+ "reference": "815dd47ade8120c6850c5a3805649c96fbadbdca",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1 || ^8.0",
+ "phpstan/phpstan": "^0.12.56"
+ },
+ "conflict": {
+ "doctrine/collections": "<1.0",
+ "doctrine/common": "<2.7",
+ "doctrine/mongodb-odm": "<1.2",
+ "doctrine/orm": "<2.5",
+ "doctrine/persistence": "<1.3"
+ },
+ "require-dev": {
+ "doctrine/annotations": "^1.11.0",
+ "doctrine/collections": "^1.6",
+ "doctrine/common": "^2.7 || ^3.0",
+ "doctrine/dbal": "^2.11.0",
+ "doctrine/mongodb-odm": "^1.3 || ^2.1",
+ "doctrine/orm": "^2.5",
+ "doctrine/persistence": "^1.1 || ^2.0",
+ "phing/phing": "^2.16.3",
+ "php-parallel-lint/php-parallel-lint": "^1.2",
+ "phpstan/phpstan-phpunit": "^0.12.16",
+ "phpstan/phpstan-strict-rules": "^0.12.5",
+ "phpunit/phpunit": "^7.5.20",
+ "ramsey/uuid-doctrine": "^1.5.0"
+ },
+ "type": "phpstan-extension",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.12-dev"
+ },
+ "phpstan": {
+ "includes": [
+ "extension.neon",
+ "rules.neon"
+ ]
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Doctrine extensions for PHPStan",
+ "support": {
+ "issues": "https://github.com/phpstan/phpstan-doctrine/issues",
+ "source": "https://github.com/phpstan/phpstan-doctrine/tree/0.12.32"
+ },
+ "time": "2021-02-09T19:07:47+00:00"
+ },
+ {
+ "name": "phpstan/phpstan-phpunit",
+ "version": "0.12.17",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpstan-phpunit.git",
+ "reference": "432575b41cf2d4f44e460234acaf56119ed97d36"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/432575b41cf2d4f44e460234acaf56119ed97d36",
+ "reference": "432575b41cf2d4f44e460234acaf56119ed97d36",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1 || ^8.0",
+ "phpstan/phpstan": "^0.12.60"
+ },
+ "conflict": {
+ "phpunit/phpunit": "<7.0"
+ },
+ "require-dev": {
+ "phing/phing": "^2.16.3",
+ "php-parallel-lint/php-parallel-lint": "^1.2",
+ "phpstan/phpstan-strict-rules": "^0.12.6",
+ "phpunit/phpunit": "^7.5.20"
+ },
+ "type": "phpstan-extension",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.12-dev"
+ },
+ "phpstan": {
+ "includes": [
+ "extension.neon",
+ "rules.neon"
+ ]
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPUnit extensions and rules for PHPStan",
+ "support": {
+ "issues": "https://github.com/phpstan/phpstan-phpunit/issues",
+ "source": "https://github.com/phpstan/phpstan-phpunit/tree/0.12.17"
+ },
+ "time": "2020-12-13T12:12:51+00:00"
+ },
+ {
"name": "phpunit/php-code-coverage",
"version": "9.2.5",
"source": {
diff --git a/psalm.xml b/psalm.xml
deleted file mode 100644
index 45b8231b3..000000000
--- a/psalm.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0"?>
-<psalm
- totallyTyped="true"
- errorLevel="5"
- 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"
- autoloader="tests/psalm-autoload.php"
->
- <projectFiles>
- <directory name="lib" />
- <ignoreFiles>
- <directory name="vendor" />
- </ignoreFiles>
- </projectFiles>
- <extraFiles>
- <directory name="vendor" />
- <ignoreFiles>
- <directory name="vendor/phpunit/php-code-coverage" />
- </ignoreFiles>
- </extraFiles>
- <issueHandlers>
- <UndefinedClass>
- <errorLevel type="suppress">
- <referencedClass name="OC" />
- </errorLevel>
- </UndefinedClass>
- <UndefinedClass>
- <errorLevel type="suppress">
- <referencedClass name="OC\Hooks\Emitter" />
- </errorLevel>
- </UndefinedClass>
- </issueHandlers>
-</psalm>
diff --git a/tests/psalm-autoload.php b/tests/psalm-autoload.php
deleted file mode 100644
index 3da2d7f55..000000000
--- a/tests/psalm-autoload.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-/**
- * Nextcloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Sean Molenaar <sean@seanmolenaar.eu>
- * @copyright Sean Molenaar 2021
- */
-
-require_once __DIR__ . '/../../../3rdparty/autoload.php';
-require_once __DIR__ . '/../vendor/autoload.php';
diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml
deleted file mode 100644
index b22549184..000000000
--- a/tests/psalm-baseline.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<files psalm-version="4.4.1@9fd7a7d885b3a216cff8dec9d8c21a132f275224">
- <file src="lib/AppInfo/Application.php">
- <MissingDependency occurrences="4">
- <code>$fs</code>
- <code>$fs</code>
- <code>$fs</code>
- <code>IRootFolder</code>
- </MissingDependency>
- </file>
- <file src="lib/Cron/UpdaterJob.php">
- <UndefinedClass occurrences="1">
- <code>TimedJob</code>
- </UndefinedClass>
- </file>
- <file src="lib/Fetcher/Fetcher.php">
- <InvalidReturnStatement occurrences="1"/>
- <InvalidReturnType occurrences="1">
- <code>array</code>
- </InvalidReturnType>
- </file>
- <file src="lib/Hooks/UserDeleteHook.php">
- <MoreSpecificImplementedParamType occurrences="1">
- <code>$event</code>
- </MoreSpecificImplementedParamType>
- </file>
- <file src="lib/Service/Exceptions/ServiceConflictException.php">
- <MoreSpecificImplementedParamType occurrences="1">
- <code>$exception</code>
- </MoreSpecificImplementedParamType>
- </file>
- <file src="lib/Service/Exceptions/ServiceNotFoundException.php">
- <MoreSpecificImplementedParamType occurrences="1">
- <code>$exception</code>
- </MoreSpecificImplementedParamType>
- </file>
- <file src="lib/Service/Exceptions/ServiceValidationException.php">
- <MoreSpecificImplementedParamType occurrences="1">
- <code>$exception</code>
- </MoreSpecificImplementedParamType>
- </file>
- <file src="lib/Service/FeedServiceV2.php">
- <UndefinedMethod occurrences="3">
- <code>findAllFromFolder</code>
- <code>findByURL</code>
- <code>read</code>
- </UndefinedMethod>
- </file>
- <file src="lib/Service/FolderServiceV2.php">
- <UndefinedClass occurrences="1">
- <code>TimeFactory</code>
- </UndefinedClass>
- <UndefinedDocblockClass occurrences="2">
- <code>$this-&gt;timeFactory</code>
- <code>TimeFactory</code>
- </UndefinedDocblockClass>
- <UndefinedMethod occurrences="1">
- <code>read</code>
- </UndefinedMethod>
- </file>
- <file src="lib/Service/ItemServiceV2.php">
- <UndefinedMethod occurrences="11">
- <code>deleteOverThreshold</code>
- <code>findAllAfter</code>
- <code>findAllFeed</code>
- <code>findAllFolder</code>
- <code>findAllInFeedAfter</code>
- <code>findAllInFolderAfter</code>
- <code>findAllItems</code>
- <code>findByGuidHash</code>
- <code>findForUserByGuidHash</code>
- <code>newest</code>
- <code>readAll</code>
- </UndefinedMethod>
- </file>
-</files>