includes
7 months ago
composer.json
7 months ago
mcp-adapter.php
9 months ago
phpcs.xml.dist
9 months ago
phpstan.neon.dist
7 months ago
phpcs.xml.dist
224 lines
| 1 | <?xml version="1.0"?> |
| 2 | <ruleset |
| 3 | name="WPCS - MCP Adapter" |
| 4 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 5 | xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd" |
| 6 | > |
| 7 | <description>Sniffs for the MCP Adapter plugin</description> |
| 8 | |
| 9 | <!-- What to scan: include any root-level PHP files, and the /includes folder --> |
| 10 | <file>./includes/</file> |
| 11 | <file>./mcp-adapter.php</file> |
| 12 | |
| 13 | <!-- These are excluded from the above paths.--> |
| 14 | <exclude-pattern>**/build/**</exclude-pattern> |
| 15 | <exclude-pattern>**/node_modules/**</exclude-pattern> |
| 16 | <exclude-pattern>**/vendor/**</exclude-pattern> |
| 17 | |
| 18 | <!-- How to scan: include CLI args so you don't need to pass them manually --> |
| 19 | <!-- Usage instructions: https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage --> |
| 20 | <!-- Annotated ruleset: |
| 21 | https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-ruleset.xml --> |
| 22 | <!-- Show sniff and progress --> |
| 23 | <arg value="sp" /> |
| 24 | <!-- Strip the file paths down to the relevant bit --> |
| 25 | <arg name="basepath" value="./" /> |
| 26 | <!-- Enable colors in report --> |
| 27 | <arg name="colors" /> |
| 28 | <!-- Only lint php files by default --> |
| 29 | <arg name="extensions" value="php" /> |
| 30 | <!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next |
| 31 | scan. --> |
| 32 | <arg name="cache" value="tests/_output/phpcs-cache.json" /> |
| 33 | <!-- Enables parallel processing when available for faster results. --> |
| 34 | <arg name="parallel" value="20" /> |
| 35 | <!-- Set severity to 1 to see everything that isn't effectively turned off. --> |
| 36 | <arg name="severity" value="1" /> |
| 37 | |
| 38 | <!-- Ruleset Config: set these to match your project constraints. --> |
| 39 | |
| 40 | <!-- |
| 41 | Tests for PHP version compatibility. |
| 42 | https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#Recomended-additional-rulesets |
| 43 | --> |
| 44 | <config name="testVersion" value="7.4-" /> |
| 45 | |
| 46 | <!-- |
| 47 | Tests for WordPress version compatibility. |
| 48 | https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties |
| 49 | --> |
| 50 | <config name="minimum_wp_version" value="6.8" /> |
| 51 | |
| 52 | <!-- |
| 53 | Load WordPress VIP Go standards |
| 54 | We do this first, since we don't trust them to disable rules that we want to use. |
| 55 | @see: https://docs.wpvip.com/technical-references/vip-code-analysis-bot/phpcs-report/ |
| 56 | --> |
| 57 | <rule ref="WordPress-VIP-Go"> |
| 58 | <!-- Deprecated: @todo remove in PHPCS 4.0 --> |
| 59 | <exclude name="WordPressVIPMinimum.JS" /> |
| 60 | </rule> |
| 61 | <rule ref="WordPress-Extra"> |
| 62 | <!-- @todo: TO EVALUATE. --> |
| 63 | <!-- Allow PSR-4 class/file naming instead of WordPress class/file naming scheme --> |
| 64 | <!-- @TODO to evaluate --> |
| 65 | <exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound" /> |
| 66 | <exclude name="WordPress.NamingConventions.PrefixAllGlobals.InvalidPrefixPassed" /> |
| 67 | <exclude name="WordPress.Files.FileName" /> |
| 68 | <!-- Allow modern PHP syntax --> |
| 69 | <exclude name="Universal.Operators.DisallowShortTernary" /> |
| 70 | <!-- Needed to typehint, see: https://github.com/WordPress/WordPress-Coding-Standards/issues/403 --> |
| 71 | <exclude name="Generic.Commenting.DocComment.MissingShort" /> |
| 72 | <!-- Allow internal hook names without prefixes --> |
| 73 | <exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound" /> |
| 74 | <!-- Allow unused parameters in interface implementations --> |
| 75 | <exclude name="Generic.CodeAnalysis.UnusedFunctionParameter" /> |
| 76 | </rule> |
| 77 | |
| 78 | <!-- |
| 79 | Load PHPCompatibility & PHPCompatibilityWP |
| 80 | @see: https://github.com/PHPCompatibility/PHPCompatibilityWP |
| 81 | --> |
| 82 | <rule ref="PHPCompatibilityWP" /> |
| 83 | |
| 84 | <!-- |
| 85 | Checks from PCP |
| 86 | @see https://github.com/wordpress/plugin-check |
| 87 | --> |
| 88 | <rule |
| 89 | ref="./vendor/wpackagist-plugin/plugin-check/vendor/plugin-check/phpcs-sniffs/PluginCheck/ruleset.xml" /> |
| 90 | <rule ref="./vendor/wpackagist-plugin/plugin-check/phpcs-rulesets/plugin-check.ruleset.xml" /> |
| 91 | |
| 92 | <!-- Check for superfluous whitespace - These get suppressed in VIP-GO.--> |
| 93 | <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"> |
| 94 | <severity>5</severity> |
| 95 | </rule> |
| 96 | <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines"> |
| 97 | <severity>5</severity> |
| 98 | </rule> |
| 99 | <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine"> |
| 100 | <severity>5</severity> |
| 101 | </rule> |
| 102 | <rule ref="WordPress.WhiteSpace.ControlStructureSpacing"> |
| 103 | <properties> |
| 104 | <property name="blank_line_check" value="true" /> |
| 105 | </properties> |
| 106 | </rule> |
| 107 | |
| 108 | <!-- |
| 109 | Slevomat Coding Standards to keep our code clean and modern. |
| 110 | See: https://github.com/slevomat/coding-standard/tree/master#alphabetical-list-of-sniffs |
| 111 | --> |
| 112 | <rule ref="SlevomatCodingStandard.Arrays.ArrayAccess" /> |
| 113 | <rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation" /> |
| 114 | <rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement" /> |
| 115 | |
| 116 | <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility" /> |
| 117 | <rule ref="SlevomatCodingStandard.Classes.DisallowConstructorPropertyPromotion" /> |
| 118 | <rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants" /> |
| 119 | <rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition" /> |
| 120 | <rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition" /> |
| 121 | <rule ref="SlevomatCodingStandard.Classes.DisallowStringExpressionPropertyFetch" /> |
| 122 | <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"> |
| 123 | <properties> |
| 124 | <!-- Doesn't use PHPCompatibility--> |
| 125 | <property name="enableOnObjects" value="false" /> |
| 126 | </properties> |
| 127 | </rule> |
| 128 | <rule ref="SlevomatCodingStandard.Classes.RequireSelfReference" /> |
| 129 | <rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding" /> |
| 130 | |
| 131 | <rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch" /> |
| 132 | <rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit" /> |
| 133 | <rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses" /> |
| 134 | <rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn" /> |
| 135 | <rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator" /> |
| 136 | |
| 137 | <rule ref="SlevomatCodingStandard.Exceptions.DeadCatch" /> |
| 138 | <rule ref="SlevomatCodingStandard.Exceptions.DisallowNonCapturingCatch" /> |
| 139 | <rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly" /> |
| 140 | |
| 141 | <rule ref="SlevomatCodingStandard.Functions.StaticClosure" /> |
| 142 | <rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure" /> |
| 143 | <rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue" /> |
| 144 | |
| 145 | <rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"> |
| 146 | <properties> |
| 147 | <property name="caseSensitive" value="true" /> |
| 148 | </properties> |
| 149 | </rule> |
| 150 | <rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse" /> |
| 151 | <rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"> |
| 152 | <properties> |
| 153 | <!-- Support PHPStan annotations --> |
| 154 | <property name="ignoredAnnotationNames" type="array"> |
| 155 | <element value="@phpstan-import-type" /> |
| 156 | <element value="@phpstan-param" /> |
| 157 | <element value="@phpstan-return" /> |
| 158 | <element value="@phpstan-template" /> |
| 159 | <element value="@phpstan-type" /> |
| 160 | <element value="@phpstan-var" /> |
| 161 | </property> |
| 162 | </properties> |
| 163 | </rule> |
| 164 | <rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions" /> |
| 165 | <rule ref="SlevomatCodingStandard.Namespaces.UnusedUses" /> |
| 166 | <rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash" /> |
| 167 | <rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace" /> |
| 168 | |
| 169 | <rule ref="SlevomatCodingStandard.PHP.DisallowDirectMagicInvokeCall" /> |
| 170 | <rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking" /> |
| 171 | <rule ref="SlevomatCodingStandard.PHP.ShortList" /> |
| 172 | <rule ref="SlevomatCodingStandard.PHP.TypeCast" /> |
| 173 | <rule ref="SlevomatCodingStandard.PHP.UselessParentheses" /> |
| 174 | <rule ref="SlevomatCodingStandard.PHP.UselessSemicolon" /> |
| 175 | |
| 176 | <rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints" /> |
| 177 | <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue" /> |
| 178 | <rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition" /> |
| 179 | |
| 180 | <rule ref="SlevomatCodingStandard.Variables.DisallowVariableVariable" /> |
| 181 | <rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable" /> |
| 182 | <rule ref="SlevomatCodingStandard.Variables.UnusedVariable"> |
| 183 | <properties> |
| 184 | <property name="ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach" value="true" /> |
| 185 | </properties> |
| 186 | </rule> |
| 187 | <rule ref="SlevomatCodingStandard.Variables.UselessVariable" /> |
| 188 | |
| 189 | <!-- |
| 190 | Ignore Rules for Tests |
| 191 | --> |
| 192 | <rule ref="PluginCheck.CodeAnalysis.Offloading.OffloadedContent"> |
| 193 | <exclude-pattern>/tests/*</exclude-pattern> |
| 194 | </rule> |
| 195 | |
| 196 | <!-- Do not apply filename rules for unit tests --> |
| 197 | <rule ref="WordPress.Files.FileName.NotHyphenatedLowercase"> |
| 198 | <exclude-pattern>tests/*</exclude-pattern> |
| 199 | </rule> |
| 200 | <rule ref="WordPress.Files.FileName.InvalidClassFileName"> |
| 201 | <exclude-pattern>tests/*</exclude-pattern> |
| 202 | </rule> |
| 203 | |
| 204 | <rule ref="WordPress.NamingConventions.PrefixAllGlobals"> |
| 205 | <properties> |
| 206 | <property name="prefixes" type="array"> |
| 207 | <element value="mcp-adapter" /> |
| 208 | <element value="WPMCP" /> |
| 209 | </property> |
| 210 | </properties> |
| 211 | </rule> |
| 212 | |
| 213 | <!-- Plugin-specific rule configs--> |
| 214 | <rule ref="WordPress.NamingConventions.PrefixAllGlobals"> |
| 215 | <properties> |
| 216 | <property name="prefixes" type="array"> |
| 217 | <!-- @todo: Should we use a namespace or prefix ? --> |
| 218 | <element value="mcp-adapter" /> |
| 219 | <element value="WP_MCP" /> |
| 220 | </property> |
| 221 | </properties> |
| 222 | </rule> |
| 223 | </ruleset> |
| 224 |