Last active
February 22, 2024 07:19
-
-
Save AgelxNash/1b2696f16774342df03f3c8a7282b6cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
includes: | |
- vendor/larastan/larastan/extension.neon | |
- vendor/canvural/larastan-strict-rules/rules.neon | |
#- vendor/symplify/phpstan-rules/config/code-complexity-rules.neon | |
- vendor/symplify/phpstan-rules/config/collector-rules.neon | |
- vendor/symplify/phpstan-rules/config/naming-rules.neon | |
- vendor/symplify/phpstan-rules/config/regex-rules.neon | |
- vendor/symplify/phpstan-rules/config/static-rules.neon | |
- vendor/symplify/phpstan-rules/config/services/services.neon | |
- vendor/phpstan/phpstan-strict-rules/rules.neon | |
- vendor/phpstan/phpstan-deprecation-rules/rules.neon | |
- vendor/tomasvotruba/type-coverage/config/extension.neon | |
- vendor/tomasvotruba/cognitive-complexity/config/extension.neon | |
parameters: | |
paths: | |
- app/ | |
# Level 9 is the highest level | |
level: 5 | |
type_coverage: | |
return_type: 90 | |
param_type: 90 | |
property_type: 90 | |
cognitive_complexity: | |
#class: 50 | |
#function: 8 | |
dependency_tree: 150 | |
strictRules: | |
disallowedLooseComparison: true | |
booleansInConditions: true | |
uselessCast: true | |
requireParentConstructorCall: true | |
disallowedConstructs: true | |
overwriteVariablesWithLoop: true | |
closureUsesThis: true | |
matchingInheritedMethodNames: true | |
numericOperandsInArithmeticOperators: true | |
strictCalls: false | |
switchConditionsMatchingType: false | |
noVariableVariables: false | |
# ignoreErrors: | |
# - '#PHPDoc tag @var#' | |
# excludePaths: | |
# - ./*/*/FileToBeExcluded.php | |
# checkMissingIterableValueType: false | |
services: | |
- | |
class: Symplify\PHPStanRules\Rules\NoDuplicatedShortClassNameRule | |
tags: [phpstan.rules.rule] | |
arguments: | |
toleratedNestingLevel: 2 | |
- | |
class: Symplify\PHPStanRules\ObjectCalisthenics\Rules\NoShortNameRule | |
tags: [phpstan.rules.rule] | |
arguments: | |
minNameLength: 2 | |
- | |
class: Symplify\PHPStanRules\Rules\ForbiddenNodeRule | |
tags: [phpstan.rules.rule] | |
arguments: | |
forbiddenNodes: | |
- PhpParser\Node\Expr\Empty_ | |
- PhpParser\Node\Expr\ErrorSuppress | |
- PhpParser\Node\Scalar\Encapsed | |
- PhpParser\Node\Scalar\EncapsedStringPart | |
# use pre* nodes instead | |
- PhpParser\Node\Expr\PostInc | |
- PhpParser\Node\Expr\PostDec | |
- | |
class: Symplify\PHPStanRules\Rules\PreferredClassRule | |
tags: [phpstan.rules.rule] | |
arguments: | |
oldToPreferredClasses: | |
# prevents typos | |
PHPStan\Node\ClassMethod: 'PhpParser\Node\Stmt\ClassMethod' | |
'PhpCsFixer\Finder': 'Symfony\Component\Finder\Finder' | |
- | |
class: Symplify\PHPStanRules\Rules\ForbiddenFuncCallRule | |
tags: [phpstan.rules.rule] | |
arguments: | |
forbiddenFunctions: | |
- 'd' | |
- 'dd' | |
- 'dump' | |
- 'var_dump' | |
- 'extract' | |
- 'curl_*' | |
- 'compact' | |
- 'method_exists' | |
- 'property_exists' | |
- 'spl_autoload_register' | |
- 'spl_autoload_unregister' | |
- array_walk | |
- | |
class: Symplify\PHPStanRules\Rules\SeeAnnotationToTestRule | |
tags: [phpstan.rules.rule] | |
arguments: | |
requiredSeeTypes: | |
- PHPStan\Rules\Rule | |
- PHP_CodeSniffer\Sniffs\Sniff | |
- PHP_CodeSniffer\Fixer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function install { | |
composer require larastan/larastan \ | |
canvural/larastan-strict-rules \ | |
driftingly/rector-laravel \ | |
phpstan/phpstan-deprecation-rules \ | |
phpstan/phpstan-strict-rules \ | |
spatie/laravel-ignition \ | |
staabm/phpstan-baseline-analysis \ | |
symplify/phpstan-rules \ | |
tomasvotruba/cognitive-complexity \ | |
tomasvotruba/type-coverage --dev | |
wget https://gist.githubusercontent.com/AgelxNash/1b2696f16774342df03f3c8a7282b6cc/raw/688f38d53e8c8be9c7e56fece4e804579a611420/phpstan.neon -O phpstan.neon | |
} | |
function analyze { | |
date=$(git log --pretty=format:'%as' -n 1) | |
file="codereport/$date.json" | |
vendor/bin/phpstan analyse --generate-baseline | |
vendor/bin/phpstan-baseline-analyze phpstan-baseline.neon | |
vendor/bin/phpstan-baseline-analyze phpstan-baseline.neon --json > "$file" | |
oldDate=$(sed -E 's/.*"Date":"?([^"]*)"?.*/\1/' "$file") | |
newDate=$(git log --pretty=format:'%aD' -n 1) | |
sed -i "s/$oldDate/$newDate/g" "$file" | |
} | |
function main { | |
mkdir -p codereport | |
analyze | |
for i in {1..15} | |
do | |
git checkout `git rev-list -n 1 --before="{$i} week ago" HEAD` | |
analyze | |
done | |
vendor/bin/phpstan-baseline-graph 'codereport/*.json' > codereport/index.html | |
} | |
#install | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment