Add phpstan plugins

remove leftovers from psalm
move phpstan and phpcs to static code check

Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
This commit is contained in:
Benjamin Brahmer 2021-02-17 17:26:34 +01:00 committed by Sean Molenaar
parent 4a107b3d53
commit 30ce6196b8
7 changed files with 223 additions and 131 deletions

View File

@ -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

View File

@ -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

View File

@ -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",

170
composer.lock generated
View File

@ -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",
@ -1269,6 +1269,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",
@ -1329,6 +1374,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",

View File

@ -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>

View File

@ -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';

View File

@ -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>