Skip to content
Snippets Groups Projects
Select Git revision
  • 4d2d1a9316ccc8a9a3dc38ccdfd2e3664a80e675
  • main default protected
  • v0.10
  • 0.10.6
  • 0.10.5
  • 0.10.4
  • 0.10.3
  • 0.10.2
  • 0.10.1
  • 0.10.0
  • 0.9.1
  • 0.9.0
12 results

CHANGELOG.md

Blame
  • To find the state of this project's repository at the time of any of these versions, check out the tags.
    ruleset.xml 6.76 KiB
    <?xml version="1.0"?>
    <ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WPDeskPlugin">
    
    	<description>Sniffs for WordPress WPDesk plugins</description>
    
        <!-- Always exclude all files in version management related directories. -->
        <exclude-pattern>*/.git/*</exclude-pattern>
        <exclude-pattern>*/.wordpress-svn/*</exclude-pattern>
    
        <!-- Always exclude all files in dependency related directories. -->
        <exclude-pattern>*/node_modules/*</exclude-pattern>
        <exclude-pattern>*/vendor(_prefixed)?/*</exclude-pattern>
    
    	<!-- Always exclude all tests. Differences between PHPUnit, mocking libraries and WPCS make it hard to enforce some CS. -->
    	<exclude-pattern>*/tests/*</exclude-pattern>
    
    	<exclude-pattern>scoper\.inc\.php$</exclude-pattern>
    
        <rule ref="WordPress">
            <!-- Follow PSR-4 for autoloading naming convention -->
            <exclude name="WordPress.Files.FileName"/>
    
            <!-- WPCS demands long arrays. WPDeskCS demands short arrays. -->
            <exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
    
            <!-- Demanding Yoda conditions is stupid. -->
            <exclude name="WordPress.PHP.YodaConditions"/>
    
    		<!-- The only required comments are for the classes. -->
    		<exclude name="Squiz.Commenting.FunctionComment"/>
    		<exclude name="Generic.Commenting.DocComment.MissingShort"/>
    
    		<!-- You can use short if-else form. -->
    		<exclude name="Universal.Operators.DisallowShortTernary"/>
    
    		<!-- If a conscious choice has been made for a non-strict comparison, that's ok.
    			 I.e. when `strict` has been explicitly set to `false` in an array comparison,
    			 it will be allowed. -->
    		<exclude name="WordPress.PHP.StrictInArray.FoundNonStrictFalse"/>
    
    		<exclude name="WordPress.WP.AlternativeFunctions" />
    
    		<!-- Sometimes it's better not to use user's timezone. -->
    		<exclude name="WordPress.DateTime.RestrictedFunctions.date_date" />
    
    		<!-- Since WPCS 3.0 exceptions are treated as output and requires escaping. We don't want that... -->
    		<exclude name="WordPress.Security.EscapeOutput.ExceptionNotEscaped" />
    	</rule>
    
    	<!-- Allow slash in hook name. -->
    	<rule ref="WordPress.NamingConventions.ValidHookName">
    		<properties>
    			<property name="additionalWordDelimiters" value="/"/>
    		</properties>
    	</rule>
    
    	<!-- By default register WooCommerce capabilities as known. -->
    	<rule ref="WordPress.WP.Capabilities">
    		<properties>
    			<property name="custom_capabilities" type="array">
    				<element value="view_woocommerce_reports"/>
    				<element value="manage_woocommerce"/>
    				<element value="edit_shop_order"/>
    				<element value="read_shop_order"/>
    				<element value="delete_shop_order"/>
    				<element value="edit_shop_orders"/>
    				<element value="edit_others_shop_orders"/>
    				<element value="publish_shop_orders"/>
    				<element value="read_private_shop_orders"/>
    				<element value="delete_shop_orders"/>
    				<element value="delete_private_shop_orders"/>
    				<element value="delete_published_shop_orders"/>
    				<element value="delete_others_shop_orders"/>
    				<element value="edit_private_shop_orders"/>
    				<element value="edit_published_shop_orders"/>
    			</property>
    		</properties>
    	</rule>
    
    	<!-- Add WooCommerce security functions to whitelist -->
    	<rule ref="WordPress.Security.ValidatedSanitizedInput">
    		<properties>
    			<property name="customSanitizingFunctions" type="array" value="wc_clean,wc_sanitize_tooltip,wc_format_decimal,wc_stock_amount,wc_sanitize_permalink,wc_sanitize_textarea" />
    		</properties>
    	</rule>
    
    	<rule ref="WordPress.Security.EscapeOutput">
    		<properties>
    			<property name="customEscapingFunctions" type="array" value="wc_help_tip,wc_sanitize_tooltip,wc_selected,wc_kses_notice,wc_esc_json,wc_query_string_form_fields,wc_make_phone_clickable" />
    		</properties>
    	</rule>
    
    	<!-- Template files should have comment with passed variables. -->
    	<rule ref="Squiz.Commenting.FileComment">
    		<include-pattern>*/templates/*</include-pattern>
    		<exclude name="Squiz.Commenting.FileComment.MissingPackageTag"/>
    	</rule>
    
        <rule ref="WordPress.Arrays.MultipleStatementAlignment">
            <type>error</type>
            <properties>
                <!-- No need to adjust alignment of large arrays when the item with the largest key is removed. -->
                <property name="exact" value="false"/>
                <!-- Don't align multi-line items if ALL items in the array are multi-line. -->
                <property name="alignMultilineItems" value="!=100"/>
                <!-- Array Assignment operator should always be on the same line as the array key. -->
                <property name="ignoreNewlines" value="false"/>
            </properties>
        </rule>
    
        <!-- In contrast to WPCS: demand short arrays. -->
        <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
    
    	<!-- Check the complexity of code in advance to prevent too complex structures. -->
    	<rule ref="Generic.Metrics.CyclomaticComplexity">
    		<properties>
    			<property name="complexity" value="15"/>
    			<property name="absoluteComplexity" value="30"/>
    		</properties>
    	</rule>
    
    	<rule ref="Generic.Metrics.NestingLevel">
    		<properties>
    			<property name="nestingLevel" value="6" />
    			<property name="absoluteNestingLevel" value="10" />
    		</properties>
    	</rule>
    
    	<rule ref="PHPCompatibilityWP">
    		<include-pattern>*\.php$</include-pattern>
    	</rule>
    	<!--
    	#############################################################################
    	ADD SOME SPECIFIC EXTRA SNIFFS
    	These may make it into WPCS at some point. If so, they can be removed here.
    	#############################################################################
    	-->
    	<!-- CS: ensure exactly one blank line before each property declaration. -->
    	<rule ref="Squiz.WhiteSpace.MemberVarSpacing"/>
    
    	<!-- CS: don't allow "// end class" comments and the likes. -->
    	<rule ref="PSR12.Classes.ClosingBrace"/>
    
    	<!-- CS: enforce consistent indentation of chained object method calls. -->
    	<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent">
    		<properties>
    			<property name="multilevel" value="true"/>
    		</properties>
    	</rule>
    
    	<!-- CS: Disallow a leading backslash at the start of an import use statement. -->
    	<!-- PHPCS 3.5.0: This sniff may be added to WPCS in due time and can then be removed from this ruleset. -->
    	<rule ref="PSR12.Files.ImportStatement"/>
    
    	<!-- CS: Enforces that a PHP open tag is on a line by itself when used at the start of a PHP-only file. -->
    	<!-- PHPCS 3.5.0: This sniff may be added to WPCS in due time and can then be removed from this ruleset. -->
    	<rule ref="PSR12.Files.OpenTag"/>
    
    	<!-- ##### Documentation Sniffs vs empty index files ##### -->
    
        <!-- Exclude the 'empty' index files from some documentation checks -->
    	<rule ref="Squiz.Commenting.InlineComment.NoSpaceBefore">
            <exclude-pattern>*/index\.php$</exclude-pattern>
        </rule>
    	<rule ref="Squiz.Commenting.FileComment.WrongStyle">
    		<exclude-pattern>*/index\.php$</exclude-pattern>
    	</rule>
    </ruleset>