Skip to content

Commit

Permalink
Добавляет конфигурацию Code_Sniffer и статический анализатор Psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
mihdan committed Mar 24, 2023
1 parent c410a19 commit 28e10e3
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 19 deletions.
62 changes: 43 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
{
"name": "mihdan/wp-oop-settings-api",
"description": "WP-OOP-Settings-API is a Settings API wrapper built with Object Oriented Programming practices.",
"type": "library",
"license": "GPL-2.0",
"authors": [
{
"name": "Mikhail Kobzarev",
"email": "[email protected]"
},
{
"name": "Ahmad Awais",
"email": "[email protected]"
}
],
"autoload" : {
"psr-4" : {
"Mihdan\\WPOSA\\" : "src/"
}
}
"name": "mihdan/wp-oop-settings-api",
"description": "WP-OOP-Settings-API is a Settings API wrapper built with Object Oriented Programming practices.",
"type": "library",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Mikhail Kobzarev",
"email": "[email protected]"
},
{
"name": "Ahmad Awais",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
"Mihdan\\WPOSA\\": "src/"
}
},
"config": {
"platform": {
"php": "7.4"
}
},
"require": {
"php": ">=7.4",
"ext-json": "*"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"squizlabs/php_codesniffer": "^3.6",
"phpcompatibility/php-compatibility": "^9.3",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"wp-coding-standards/wpcs": "^2.3",
"php-coveralls/php-coveralls": "^v2.4",
"vimeo/psalm": "^4.20",
"humanmade/psalm-plugin-wordpress": "^2.0"
},
"scripts": {
"phpcs": "phpcs --standard=./phpcs.xml",
"phpcbf": "phpcbf --standard=./phpcs.xml",
"psalm": "psalm --config=./psalm.xml"
}
}
43 changes: 43 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<ruleset name="WordPress Plugin Coding Standards">
<description>A custom set of code standard rules to check for WordPress plugins.</description>

<!-- What to scan -->
<file>.</file>
<exclude-pattern>*/\.github/*</exclude-pattern>
<exclude-pattern>*/examples/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>

<!-- How to scan -->
<arg value="sp"/><!-- Show sniff and progress -->
<arg name="basepath" value="./"/><!-- Strip the file paths down to the relevant bit -->
<arg name="extensions" value="php"/>
<arg name="parallel" value="12"/><!-- Enables parallel processing when available for faster results. -->
<arg name="cache" value=".phpcs.cache"/>

<config name="installed_paths" value="vendor/phpcompatibility/php-compatibility,vendor/phpcompatibility/phpcompatibility-paragonie,vendor/phpcompatibility/phpcompatibility-wp,vendor/wp-coding-standards/wpcs"/>
<config name="testVersion" value="7.4-"/>

<!-- Rules: Check PHP version compatibility -->
<rule ref="PHPCompatibility"/>
<rule ref="PHPCompatibilityWP"/>

<!-- Rules: WordPress Coding Standards -->
<config name="minimum_supported_wp_version" value="5.1"/>

<rule ref="WordPress">
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found"/>
<exclude name="WordPress.PHP.DisallowShortTernary.Found"/>
<exclude name="WordPress.PHP.YodaConditions" />
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
<exclude name="PEAR.NamingConventions.ValidClassName.Invalid" />
</rule>

<!-- Allow symbol `/` in hook names. -->
<rule ref="WordPress.NamingConventions.ValidHookName">
<properties>
<property name="additionalWordDelimiters" value="/" />
</properties>
</rule>
</ruleset>
18 changes: 18 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<psalm
errorLevel="3"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
<directory name="examples"/>
</ignoreFiles>
</projectFiles>
<plugins>
<pluginClass class="PsalmWordPress\Plugin"/></plugins>
</psalm>

0 comments on commit 28e10e3

Please sign in to comment.