Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ease enabling rules one-by-one #260

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 12 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,95 +17,23 @@ includes:
- vendor/shipmonk/phpstan-rules/rules.neon
```

You can easily disable or reconfigure any rule. Here is a default setup used in `rules.neon` you can change:
You can easily disable or reconfigure any rule, for example:
```neon
parameters:
shipmonkRules:
allowComparingOnlyComparableTypes:
enabled: true
backedEnumGenerics:
enabled: true
classSuffixNaming:
enabled: true
superclassToSuffixMapping: []
enforceClosureParamNativeTypehint:
enabled: true
allowMissingTypeWhenInferred: false
enforceEnumMatch:
enabled: true
enforceIteratorToArrayPreserveKeys:
enabled: true
enforceListReturn:
enabled: true
enforceNativeReturnTypehint:
enabled: true
enforceReadonlyPublicProperty:
enabled: true
forbidArithmeticOperationOnNonNumber:
enabled: true
allowNumericString: false
forbidCast:
enabled: true
blacklist: ['(array)', '(object)', '(unset)']
forbidCheckedExceptionInCallable:
enabled: true
allowedCheckedExceptionCallables: []
forbidCheckedExceptionInYieldingMethod:
enabled: true
forbidCustomFunctions:
enabled: true
list: []
forbidEnumInFunctionArguments:
enabled: true
forbidFetchOnMixed:
enabled: true
forbidIdenticalClassComparison:
enabled: true
blacklist: ['DateTimeInterface']
forbidIncrementDecrementOnNonInteger:
enabled: true
forbidMatchDefaultArmForEnums:
enabled: true
forbidMethodCallOnMixed:
enabled: true
forbidNotNormalizedType:
enabled: true
checkDisjunctiveNormalForm: true
forbidNullInAssignOperations:
enabled: true
blacklist: ['??=']
forbidNullInBinaryOperations:
enabled: true
blacklist: ['===', '!==', '??']
forbidNullInInterpolatedString:
enabled: true
forbidPhpDocNullabilityMismatchWithNativeTypehint:
enabled: true
forbidProtectedEnumMethod:
enabled: true
forbidReturnValueInYieldingMethod:
enabled: true
reportRegardlessOfReturnType: true
enabled: false
forbidUnsafeArrayKey:
enabled: true
reportMixed: true
reportInsideIsset: true
forbidVariableTypeOverwriting:
enabled: true
forbidUnsetClassField:
enabled: true
forbidUselessNullableReturn:
enabled: true
forbidUnusedException:
enabled: true
forbidUnusedMatchResult:
enabled: true
requirePreviousExceptionPass:
enabled: true
reportEvenIfExceptionIsNotAcceptableByRethrownOne: true
uselessPrivatePropertyDefaultValue:
enabled: true
uselessPrivatePropertyNullability:
reportMixed: false
```

Or you can disable all rules and enable only those you want:
```neon
parameters:
shipmonkRules:
enableAllRules: false

allowComparingOnlyComparableTypes:
enabled: true
```

Expand Down
12 changes: 0 additions & 12 deletions bin/verify-readme-default-config.php

This file was deleted.

4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,14 @@
"@check:tests",
"@check:dependencies",
"@check:collisions",
"@check:ignores",
"@check:readme"
"@check:ignores"
],
"check:collisions": "detect-collisions src tests",
"check:composer": "composer normalize --dry-run --no-check-lock --no-update-lock",
"check:cs": "phpcs",
"check:dependencies": "composer-dependency-analyser",
"check:ec": "ec src tests",
"check:ignores": "php bin/verify-inline-ignore.php",
"check:readme": "php bin/verify-readme-default-config.php",
"check:tests": "phpunit -vvv tests",
"check:types": "phpstan analyse -vvv --ansi",
"fix:cs": "phpcbf"
Expand Down
76 changes: 40 additions & 36 deletions rules.neon
Original file line number Diff line number Diff line change
@@ -1,94 +1,98 @@
parameters:
shipmonkRules:
enableAllRules: true

allowComparingOnlyComparableTypes:
enabled: true
enabled: %shipmonkRules.enableAllRules%
backedEnumGenerics:
enabled: true
enabled: %shipmonkRules.enableAllRules%
classSuffixNaming:
enabled: true
enabled: %shipmonkRules.enableAllRules%
superclassToSuffixMapping: []
enforceClosureParamNativeTypehint:
enabled: true
enabled: %shipmonkRules.enableAllRules%
allowMissingTypeWhenInferred: false
enforceEnumMatch:
enabled: true
enabled: %shipmonkRules.enableAllRules%
enforceIteratorToArrayPreserveKeys:
enabled: true
enabled: %shipmonkRules.enableAllRules%
enforceListReturn:
enabled: true
enabled: %shipmonkRules.enableAllRules%
enforceNativeReturnTypehint:
enabled: true
enabled: %shipmonkRules.enableAllRules%
enforceReadonlyPublicProperty:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidArithmeticOperationOnNonNumber:
enabled: true
enabled: %shipmonkRules.enableAllRules%
allowNumericString: false
forbidCast:
enabled: true
enabled: %shipmonkRules.enableAllRules%
blacklist: ['(array)', '(object)', '(unset)']
forbidCheckedExceptionInCallable:
enabled: true
enabled: %shipmonkRules.enableAllRules%
allowedCheckedExceptionCallables: []
forbidCheckedExceptionInYieldingMethod:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidCustomFunctions:
enabled: true
enabled: %shipmonkRules.enableAllRules%
list: []
forbidEnumInFunctionArguments:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidFetchOnMixed:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidIdenticalClassComparison:
enabled: true
enabled: %shipmonkRules.enableAllRules%
blacklist: ['DateTimeInterface']
forbidIncrementDecrementOnNonInteger:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidMatchDefaultArmForEnums:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidMethodCallOnMixed:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidNotNormalizedType:
enabled: true
enabled: %shipmonkRules.enableAllRules%
checkDisjunctiveNormalForm: true
forbidNullInAssignOperations:
enabled: true
enabled: %shipmonkRules.enableAllRules%
blacklist: ['??=']
forbidNullInBinaryOperations:
enabled: true
enabled: %shipmonkRules.enableAllRules%
blacklist: ['===', '!==', '??']
forbidNullInInterpolatedString:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidPhpDocNullabilityMismatchWithNativeTypehint:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidProtectedEnumMethod:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidReturnValueInYieldingMethod:
enabled: true
enabled: %shipmonkRules.enableAllRules%
reportRegardlessOfReturnType: true
forbidUnsafeArrayKey:
enabled: true
enabled: %shipmonkRules.enableAllRules%
reportMixed: true
reportInsideIsset: true
forbidVariableTypeOverwriting:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidUnsetClassField:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidUselessNullableReturn:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidUnusedException:
enabled: true
enabled: %shipmonkRules.enableAllRules%
forbidUnusedMatchResult:
enabled: true
enabled: %shipmonkRules.enableAllRules%
requirePreviousExceptionPass:
enabled: true
enabled: %shipmonkRules.enableAllRules%
reportEvenIfExceptionIsNotAcceptableByRethrownOne: true
uselessPrivatePropertyDefaultValue:
enabled: true
enabled: %shipmonkRules.enableAllRules%
uselessPrivatePropertyNullability:
enabled: true
enabled: %shipmonkRules.enableAllRules%

parametersSchema:
shipmonkRules: structure([
enableAllRules: bool()

allowComparingOnlyComparableTypes: structure([
enabled: bool()
])
Expand Down
Loading