Skip to content

Commit 9bf8134

Browse files
authored
Merge pull request #1025 from nextcloud/chore/add-psalm
chore: Add psalm for PHP static code analysis
2 parents 08a4205 + d30a75b commit 9bf8134

File tree

12 files changed

+2683
-125
lines changed

12 files changed

+2683
-125
lines changed

.github/workflows/psalm.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
9+
name: Static analysis
10+
11+
on: pull_request
12+
13+
concurrency:
14+
group: psalm-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
static-analysis:
19+
runs-on: ubuntu-latest
20+
21+
name: static-psalm-analysis
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
25+
26+
- name: Get php version
27+
id: versions
28+
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
29+
30+
- name: Set up php${{ steps.versions.outputs.php-available }}
31+
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
32+
with:
33+
php-version: ${{ steps.versions.outputs.php-available }}
34+
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
35+
coverage: none
36+
ini-file: development
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Install dependencies
41+
run: composer i
42+
43+
- name: Run coding standards check
44+
run: composer run psalm

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ nbproject
6161
/tests/karma-coverage
6262
.php_cs.cache
6363
node_modules
64-
/vendor
64+
**/vendor/
6565
/build
6666
composer.phar

REUSE.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SPDX-FileCopyrightText = "2023 Nextcloud GmbH and Nextcloud contributors"
1818
SPDX-License-Identifier = "AGPL-3.0-or-later"
1919

2020
[[annotations]]
21-
path = ["composer.json", "composer.lock", "package-lock.json", "package.json"]
21+
path = ["**/composer.json", "**/composer.lock", "package-lock.json", "package.json"]
2222
precedence = "aggregate"
2323
SPDX-FileCopyrightText = "2020 Nextcloud GmbH and Nextcloud contributors"
2424
SPDX-License-Identifier = "AGPL-3.0-or-later"

composer.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,27 @@
44
"optimize-autoloader": true,
55
"classmap-authoritative": true,
66
"platform": {
7-
"php": "7.4"
7+
"php": "8.1"
8+
},
9+
"allow-plugins": {
10+
"bamarni/composer-bin-plugin": true
811
}
912
},
1013
"scripts": {
14+
"post-install-cmd": [
15+
"@composer bin psalm install --ansi"
16+
],
1117
"cs:fix": "php-cs-fixer fix",
1218
"cs:check": "php-cs-fixer fix --dry-run --diff",
1319
"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
20+
"psalm": "psalm --threads=1",
21+
"psalm:update-baseline": "psalm --threads=1 --update-baseline",
22+
"psalm:clear": "psalm --clear-cache && psalm --clear-global-cache",
1423
"test:unit": "phpunit -c tests/phpunit.xml"
1524
},
1625
"require-dev": {
17-
"nextcloud/coding-standard": "^1.0.0",
18-
"phpunit/phpunit": "^9"
26+
"nextcloud/coding-standard": "^1.1.1",
27+
"phpunit/phpunit": "^9",
28+
"bamarni/composer-bin-plugin": "^1.8"
1929
}
2030
}

0 commit comments

Comments
 (0)