Skip to content

Commit

Permalink
Update lint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHenryIE committed Oct 21, 2022
1 parent 62b2462 commit 06e9f44
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
29 changes: 28 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@
<arg name="colors"/>

<exclude-pattern>/assets/</exclude-pattern>
<exclude-pattern>/dist-archive/</exclude-pattern>
<exclude-pattern>/scratch/</exclude-pattern>
<exclude-pattern>/src/strauss/*</exclude-pattern>
<exclude-pattern>/vendor-prefixed/*</exclude-pattern>
<exclude-pattern>/tests/_data/</exclude-pattern>
<exclude-pattern>/tests/_output/</exclude-pattern>
<exclude-pattern>/tests/_support/</exclude-pattern>
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/wordpress/</exclude-pattern>
<exclude-pattern>/wp-content/</exclude-pattern>

<!-- for abstract-name.php classes -->
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<exclude-pattern>*</exclude-pattern>
</rule>

<!-- Enforce fewer rules on tests -->
<rule ref="Generic.Commenting.DocComment.MissingShort">
<exclude-pattern>*/tests/*</exclude-pattern>
Expand Down Expand Up @@ -52,6 +58,15 @@
<rule ref="Squiz.PHP.DisallowMultipleAssignments.Found">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.DB.DirectDatabaseQuery.DirectQuery">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.DB.DirectDatabaseQuery.NoCaching">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.DB.DirectDatabaseQuery.SchemaChange">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
Expand All @@ -67,6 +82,18 @@
<rule ref="WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.Security.NonceVerification.Recommended">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.Security.ValidatedSanitizedInput.InputNotValidated">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.Security.ValidatedSanitizedInput.InputNotSanitized">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.Security.ValidatedSanitizedInput.MissingUnslash">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
Expand Down
16 changes: 10 additions & 6 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@ parameters:
paths:
- src
excludePaths:
- src/strauss/*
- vendor-prefixed
bootstrapFiles:
- phpstanbootstrap.php
- src/autoload.php
- autoload.php
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
- vendor/wp-cli/wp-cli/php/class-wp-cli-command.php
# - vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php
# - vendor/php-stubs/woocommerce-stubs/woocommerce-packages-stubs.php
scanFiles:
- vendor/antecedent/patchwork/Patchwork.php
scanDirectories:
- src/strauss
- wp-content/plugins
- vendor-prefixed
# - wp-content/plugins
- vendor/wp-cli
ignoreErrors:
# LoggerAwareTrait allows for null $logger, but we set it in the constructor.
- '#LoggerInterface\|null#'
# PHPStan shows errors when filters have more than two parameters.
- '#^Function apply_filters(_ref_array)? invoked with \d parameters, 2 required\.$#'
# PHPStan show errors when filters have more than two parameters.
- '#^Function apply_filters(_ref_array)? invoked with \d parameters, 2 required\.$#'
# Parameter #1 $message of method a expects b, c given.
- '/Parameter .* of .* expects .* given\./'
# Setting an empty array with type associative array in the comments prints this.
- '/does not accept default value of type array\(\)/'

0 comments on commit 06e9f44

Please sign in to comment.