Skip to content

Commit fc5fd81

Browse files
committed
chore: add linter and static analysis tools
1 parent e01b4d0 commit fc5fd81

8 files changed

Lines changed: 4853 additions & 23 deletions

File tree

.gitignore

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
1-
.DS_Store
2-
.rnd
3-
composer.lock
4-
vendor
5-
.idea
1+
### PHP-CS-Fixer template
2+
# Covers PHP CS Fixer
3+
# Reference: https://cs.symfony.com/
4+
5+
# Generated files
6+
.php-cs-fixer.cache
7+
8+
# Local config See: https://cs.symfony.com/doc/config.html
9+
.php-cs-fixer.php
10+
11+
### Composer template
12+
composer.phar
13+
/vendor/
14+
15+
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
16+
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
17+
# composer.lock
18+
19+
### PHPUnit template
20+
# Covers PHPUnit
21+
# Reference: https://phpunit.de/
22+
23+
# Generated files
24+
.phpunit.result.cache
25+
.phpunit.cache
26+
clover.xml
27+
28+
# PHPUnit
29+
/app/phpunit.xml
30+
/phpunit.xml
31+
32+
33+
# Build data
34+
/build/
35+
36+
### PHPCodeSniffer template
37+
# CodeSniffer
38+
phpcs.xml
39+
40+
/vendor/*
41+
/wpcs/*
42+
43+
!/.gitignore

.php-cs-fixer.dist.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude(['vendor', 'build'])
5+
->in(__DIR__);
6+
7+
return (new PhpCsFixer\Config())
8+
->setRules([
9+
'@PER-CS' => true,
10+
'array_syntax' => ['syntax' => 'short'],
11+
'declare_strict_types' => true,
12+
'strict_param' => true,
13+
'no_unused_imports' => true,
14+
])
15+
->setRiskyAllowed(true)
16+
->setFinder($finder)
17+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect());

codecov.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
codecov:
2+
require_ci_to_pass: yes
3+
4+
coverage:
5+
precision: 2
6+
round: down
7+
range: "70...100"
8+
status:
9+
project:
10+
default:
11+
target: auto
12+
threshold: 0%
13+
patch:
14+
default:
15+
target: auto
16+
threshold: 0%
17+
18+
parsers:
19+
gcov:
20+
branch_detection:
21+
conditional: yes
22+
loop: yes
23+
method: no
24+
macro: no
25+
26+
comment:
27+
layout: "reach,diff,flags,tree"
28+
behavior: default
29+
require_changes: false

composer.json

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,45 @@
1515
"require": {
1616
"php": "^8.3 || ^8.4",
1717
"lcobucci/jwt": "^5.5",
18-
"lcobucci/clock": "^3.3"
19-
18+
"lcobucci/clock": "^3.3"
2019
},
2120
"require-dev": {
21+
"brainmaestro/composer-git-hooks": "^3.0",
22+
"friendsofphp/php-cs-fixer": "^3.75",
2223
"phpseclib/phpseclib": "^2.0",
2324
"phpunit/phpunit": "^9.0"
2425
},
2526
"autoload": {
2627
"psr-4": {
27-
"Staffbase\\plugins\\sdk\\": "src",
28-
"Staffbase\\plugins\\test\\": "test"
28+
"Staffbase\\plugins\\sdk\\": "src/"
2929
}
3030
},
31+
"autoload-dev": {
32+
"psr-4": {
33+
"Staffbase\\plugins\\test\\": "test/"
34+
}
35+
},
36+
"config": {
37+
"sort-packages": true
38+
},
3139
"scripts": {
32-
"test": "phpunit --colors='always' --debug $PHPUNIT_ARGS",
33-
"lint": "phpcs --standard=PSR2 --extensions=php --ignore=*/vendor/* src test",
34-
"fix": "phpcbf --standard=PSR2 --extensions=php --ignore=*/vendor/* src test"
40+
"check": ["@cs-fixer:check", "@phpstan", "@test:coverage"],
41+
"lint": ["@cs-fixer:check", "@phpstan"],
42+
"fix": ["@cs-fixer:fix"],
43+
"cs-fixer:check": "php-cs-fixer fix --dry-run --diff -v",
44+
"cs-fixer:fix": "php-cs-fixer fix --diff -v",
45+
"phpstan": "phpstan analyse --memory-limit=1G",
46+
"test": "phpunit",
47+
"test:coverage": "phpunit --coverage-text --coverage-clover=clover.xml",
48+
"post-install-cmd": "cghooks add --ignore-lock",
49+
"post-update-cmd": "cghooks update"
50+
},
51+
"extra": {
52+
"hooks": {
53+
"pre-commit": [
54+
"composer -d packages/php fix",
55+
"composer -d packages/php phpstan"
56+
]
57+
}
3558
}
3659
}

0 commit comments

Comments
 (0)