Skip to content

Commit

Permalink
Improve linting
Browse files Browse the repository at this point in the history
  • Loading branch information
titouanmathis committed Mar 8, 2024
1 parent 172b5b4 commit 09dac66
Show file tree
Hide file tree
Showing 27 changed files with 2,346 additions and 2,193 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ insert_final_newline = true
trim_trailing_whitespace = false

[*.php]
indent_style = tab
indent_size = 4
15 changes: 11 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.4",
"wp-coding-standards/wpcs": "^2.1",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"szepeviktor/phpstan-wordpress": "^1.1",
"php-stubs/wordpress-stubs": "^5.5",
Expand All @@ -29,9 +28,17 @@
]
},
"scripts": {
"phpcs": "phpcs -s --colors --standard=./phpcs.xml",
"phpstan": "phpstan analyse --memory-limit=512M",
"phpunit": "phpunit"
"lint": [
"@lint:style",
"@lint:static"
],
"lint:style": "phpcs",
"lint:static": "phpstan analyse --memory-limit=512M",
"fix": [
"@fix:style"
],
"fix:style": "phpcbf",
"test": "phpunit"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
53 changes: 1 addition & 52 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 10 additions & 21 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,39 +1,28 @@
<?xml version="1.0"?>
<ruleset name="studiometa-wp-toolkit">
<arg name="extensions" value="php"/>
<arg name="colors" />
<arg name="cache" />
<arg value="sp" />

<!-- Define file and folders to lint -->
<file>./src/</file>
<file>./tests/</file>

<!-- Don't check composer dependencies -->
<exclude-pattern>/vendor/</exclude-pattern>

<!--
Ending tags '?>' can be really painful to debug.
Just disallow them in the end of the file
-->
<rule ref="PSR2.Files.ClosingTag.NotAllowed"/>

<!-- <?php tags and constants (true,false,null) need to be lowercase -->
<rule ref="Generic.PHP.LowerCaseKeyword"/>
<rule ref="Generic.PHP.LowerCaseConstant"/>
<rule ref="PSR2" />

<rule ref="WordPress">
<!-- There are numerous cases where we want to override WP globals -->
<exclude name="WordPress.WP.GlobalVariablesOverride" />
<!-- WordPress filenames are not compatible with autoload -->
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"></exclude>
<exclude name="WordPress.Files.FileName.InvalidClassFileName"></exclude>
</rule>

<rule ref="Squiz.Commenting.FileComment.Missing">
<exclude-pattern>*/tests/*</exclude-pattern>
<rule ref="PSR1">
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
</rule>

<rule ref="Squiz.Commenting.FunctionComment.Missing">
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>

<rule ref="Generic.Files.OneObjectStructurePerFile.MultipleFound">
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
</ruleset>
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ includes:

parameters:
level: max
cache:
nodesByStringCountMax: 512
inferPrivatePropertyTypeFromConstructor: true
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false
Expand Down
Loading

0 comments on commit 09dac66

Please sign in to comment.