Merge pull request #1005 from ylkyrg/code-standards

Update ruleset
This commit is contained in:
Holger 2019-07-16 09:12:53 +02:00 committed by GitHub
commit c2a06502b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 194 additions and 71 deletions

View File

@ -86,4 +86,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #error-404-wrapper --> </div><!-- #error-404-wrapper -->
<?php get_footer(); ?> <?php get_footer();

View File

@ -70,4 +70,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #archive-wrapper --> </div><!-- #archive-wrapper -->
<?php get_footer(); ?> <?php get_footer();

View File

@ -52,7 +52,7 @@ $container = get_theme_mod( 'understrap_container_type' );
<?php if ( ! empty( $curauth->user_description ) ) : ?> <?php if ( ! empty( $curauth->user_description ) ) : ?>
<dt><?php esc_html_e( 'Profile', 'understrap' ); ?></dt> <dt><?php esc_html_e( 'Profile', 'understrap' ); ?></dt>
<dd><?php esc_html_e( $curauth->user_description ); ?></dd> <dd><?php esc_html_e( $curauth->user_description, 'understrap' ); ?></dd>
<?php endif; ?> <?php endif; ?>
</dl> </dl>
<?php endif; ?> <?php endif; ?>
@ -105,4 +105,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #author-wrapper --> </div><!-- #author-wrapper -->
<?php get_footer(); ?> <?php get_footer();

View File

@ -15,10 +15,11 @@
}, },
"require-dev": { "require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"wp-coding-standards/wpcs": "^2.1" "wp-coding-standards/wpcs": "^2.1",
"phpcompatibility/php-compatibility": "^9.2"
}, },
"scripts": { "scripts": {
"test": ["phpcs"], "test": ["vendor/bin/phpcs"],
"fix": ["phpcbf"] "fix": ["vendor/bin/phpcbf"]
} }
} }

64
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "6f047956cbb4861fde466b775966f717", "content-hash": "6e38e340aaa610ed48211f151263555e",
"packages": [ "packages": [
{ {
"name": "composer/installers", "name": "composer/installers",
@ -194,6 +194,64 @@
], ],
"time": "2018-10-26T13:21:45+00:00" "time": "2018-10-26T13:21:45+00:00"
}, },
{
"name": "phpcompatibility/php-compatibility",
"version": "9.2.0",
"source": {
"type": "git",
"url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
"reference": "3db1bf1e28123fd574a4ae2e9a84072826d51b5e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/3db1bf1e28123fd574a4ae2e9a84072826d51b5e",
"reference": "3db1bf1e28123fd574a4ae2e9a84072826d51b5e",
"shasum": ""
},
"require": {
"php": ">=5.3",
"squizlabs/php_codesniffer": "^2.3 || ^3.0.2"
},
"conflict": {
"squizlabs/php_codesniffer": "2.6.2"
},
"require-dev": {
"phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0-or-later"
],
"authors": [
{
"name": "Contributors",
"homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors"
},
{
"name": "Wim Godden",
"homepage": "https://github.com/wimg",
"role": "lead"
},
{
"name": "Juliette Reinders Folmer",
"homepage": "https://github.com/jrfnl",
"role": "lead"
}
],
"description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.",
"homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
"keywords": [
"compatibility",
"phpcs",
"standards"
],
"time": "2019-06-27T19:58:56+00:00"
},
{ {
"name": "squizlabs/php_codesniffer", "name": "squizlabs/php_codesniffer",
"version": "3.4.2", "version": "3.4.2",
@ -250,12 +308,12 @@
"version": "2.1.1", "version": "2.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git",
"reference": "bd9c33152115e6741e3510ff7189605b35167908" "reference": "bd9c33152115e6741e3510ff7189605b35167908"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/bd9c33152115e6741e3510ff7189605b35167908", "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/bd9c33152115e6741e3510ff7189605b35167908",
"reference": "bd9c33152115e6741e3510ff7189605b35167908", "reference": "bd9c33152115e6741e3510ff7189605b35167908",
"shasum": "" "shasum": ""
}, },

View File

@ -21,4 +21,4 @@ defined( 'ABSPATH' ) || exit;
</div> </div>
<?php endif; ?> <?php endif;

View File

@ -17,4 +17,4 @@ defined( 'ABSPATH' ) || exit;
<?php get_template_part( 'sidebar-templates/sidebar', 'right' ); ?> <?php get_template_part( 'sidebar-templates/sidebar', 'right' ); ?>
<?php endif; ?> <?php endif;

View File

@ -8,13 +8,14 @@
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
if ( ! function_exists( 'understrap_slbd_count_widgets' ) ) {
/** /**
* Count number of widgets in a sidebar * Count number of widgets in a sidebar
* Used to add classes to widget areas so widgets can be displayed one, two, three or four per row * Used to add classes to widget areas so widgets can be displayed one, two, three or four per row
* *
* @param int $sidebar_id The ID of the sidebar.
* @deprecated 0.8.9 * @deprecated 0.8.9
*/ */
if ( ! function_exists( 'understrap_slbd_count_widgets' ) ) {
function understrap_slbd_count_widgets( $sidebar_id ) { function understrap_slbd_count_widgets( $sidebar_id ) {
// If loading from front page, consult $_wp_sidebars_widgets rather than options // If loading from front page, consult $_wp_sidebars_widgets rather than options
// to see if wp_convert_widget_settings() has made manipulations in memory. // to see if wp_convert_widget_settings() has made manipulations in memory.

View File

@ -55,4 +55,4 @@ if ( ! function_exists( 'understrap_pagination' ) ) {
} }
} }
?>

View File

@ -72,4 +72,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #index-wrapper --> </div><!-- #index-wrapper -->
<?php get_footer(); ?> <?php get_footer();

View File

@ -57,4 +57,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #page-wrapper --> </div><!-- #page-wrapper -->
<?php get_footer(); ?> <?php get_footer();

View File

@ -52,4 +52,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #full-width-page-wrapper --> </div><!-- #full-width-page-wrapper -->
<?php get_footer(); ?> <?php get_footer();

View File

@ -51,4 +51,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #page-wrapper --> </div><!-- #page-wrapper -->
<?php get_footer(); ?> <?php get_footer();

View File

@ -51,4 +51,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #page-wrapper --> </div><!-- #page-wrapper -->
<?php get_footer(); ?> <?php get_footer();

View File

@ -54,4 +54,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #page-wrapper --> </div><!-- #page-wrapper -->
<?php get_footer(); ?> <?php get_footer();

106
phpcs.xml
View File

@ -1,10 +1,17 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<ruleset name="WordPress Theme Coding Standards"> <ruleset name="UnderStrap Coding Standards">
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/WordPress-Core/ruleset.xml -->
<!-- Set a description for this ruleset. --> <!-- Set a description for this ruleset. -->
<description>A custom set of code standard rules to check for WordPress themes.</description> <description>A custom set of code standard rules for UnderStrap.</description>
<!-- Show colors in console -->
<arg value="-colors"/>
<!-- Show sniff codes in all reports -->
<arg value="s"/>
<!-- Don't show warnings -->
<arg value="n"/>
<!-- Only check the PHP files --> <!-- Only check the PHP files -->
<arg name="extensions" value="php"/> <arg name="extensions" value="php"/>
@ -13,31 +20,86 @@
<file>.</file> <file>.</file>
<!-- Ignore the vendor directory --> <!-- Ignore the vendor directory -->
<exclude-pattern>./vendor</exclude-pattern> <exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<!-- Show colors in console --> <!-- Use the WordPress Ruleset -->
<arg value="-colors"/> <rule ref="WordPress">
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
<exclude name="WordPress.PHP.YodaConditions.NotYoda"/>
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.BlankLineAfterEnd"/>
<exclude name="WordPress.WhiteSpace.DisallowInlineTabs.NonIndentTabsUsed"/>
<exclude name="WordPress.Security.EscapeOutput.UnsafePrintingFunction"/>
<exclude name="WordPress.Security.EscapeOutput.OutputNotEscaped"/>
<exclude name="WordPress.Security.ValidatedSanitizedInput.InputNotSanitized"/>
<exclude name="WordPress.WP.GlobalVariablesOverride.Prohibited"/>
<exclude name="WordPress.WP.I18n.MissingTranslatorsComment"/>
<exclude name="WordPress.WP.I18n.NonSingularStringLiteralText"/>
<!-- Show sniff codes in all reports --> <exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma"/>
<arg value="s"/> <exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed"/>
<exclude name="Generic.WhiteSpace.ScopeIndent"/>
<!-- Include the WordPress ruleset, with space for exclusions if necessary. -->
<rule ref="WordPress-Core">
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" />
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"/>
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine"/>
<exclude name="PEAR.Functions.FunctionCallSignature.Indent"/> <exclude name="PEAR.Functions.FunctionCallSignature.Indent"/>
<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments"/>
<exclude name="Squiz.Commenting.FileComment.SpacingAfterComment" /> <exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag" /> <exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/>
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar"/> <exclude name="Squiz.Commenting.InlineComment.InvalidEndChar"/>
<exclude name="Squiz.Commenting.InlineComment.NotCapital" /> <exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"/>
</rule> <exclude name="Squiz.PHP.DisallowMultipleAssignments.Found"/>
<rule ref="WordPress-Docs"> <exclude name="Squiz.PHP.EmbeddedPhp"/>
</rule> </rule>
<rule ref="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"> <!--
<severity>0</severity> Verify that the text_domain is set to the desired text-domain.
Multiple valid text domains can be provided as a comma-delimited list.
-->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="understrap"/>
</properties>
</rule> </rule>
<!--
Allow for theme specific exceptions to the file name rules based
on the theme hierarchy.
-->
<rule ref="WordPress.Files.FileName">
<properties>
<property name="is_theme" value="true"/>
</properties>
</rule>
<!-- A closing tag is not permitted at the end of a PHP file -->
<rule ref="Zend.Files.ClosingTag"/>
<!-- Use the PHPCompatibility Ruleset -->
<config name="testVersion" value="5.2-99.0"/>
<rule ref="PHPCompatibility">
<!--
Whitelist PHP native classes, interfaces, functions and constants which
are back-filled by WP.
Based on:
* /wp-includes/compat.php
* /wp-includes/random_compat/random.php
-->
<exclude name="PHPCompatibility.PHP.NewClasses.errorFound"/>
<exclude name="PHPCompatibility.PHP.NewClasses.typeerrorFound"/>
<exclude name="PHPCompatibility.PHP.NewConstants.json_pretty_printFound"/>
<exclude name="PHPCompatibility.PHP.NewConstants.php_version_idFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.hash_equalsFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.json_last_error_msgFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.random_intFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.random_bytesFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound"/>
<exclude name="PHPCompatibility.PHP.NewInterfaces.jsonserializableFound"/>
</rule>
</ruleset> </ruleset>

View File

@ -75,4 +75,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #search-wrapper --> </div><!-- #search-wrapper -->
<?php get_footer(); ?> <?php get_footer();

View File

@ -30,4 +30,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #wrapper-footer-full --> </div><!-- #wrapper-footer-full -->
<?php endif; ?> <?php endif;

View File

@ -43,4 +43,4 @@ defined( 'ABSPATH' ) || exit;
jQuery( ".carousel-item" ).first().addClass( "active" ); jQuery( ".carousel-item" ).first().addClass( "active" );
</script> </script>
<?php endif; ?> <?php endif;

View File

@ -15,4 +15,4 @@ defined( 'ABSPATH' ) || exit;
<?php dynamic_sidebar( 'herocanvas' ); ?> <?php dynamic_sidebar( 'herocanvas' ); ?>
<?php endif; ?> <?php endif;

View File

@ -29,4 +29,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #wrapper-static-hero --> </div><!-- #wrapper-static-hero -->
<?php endif; ?> <?php endif;

View File

@ -49,4 +49,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #single-wrapper --> </div><!-- #single-wrapper -->
<?php get_footer(); ?> <?php get_footer();

View File

@ -28,4 +28,4 @@ if ( wc_get_page_id( 'shop' ) > 0 ) : ?>
<?php esc_html_e( 'Return to shop', 'understrap' ); ?> <?php esc_html_e( 'Return to shop', 'understrap' ); ?>
</a> </a>
</p> </p>
<?php endif; ?> <?php endif;

View File

@ -164,4 +164,4 @@ do_action( 'woocommerce_before_cart' ); ?>
?> ?>
</div> </div>
<?php do_action( 'woocommerce_after_cart' ); ?> <?php do_action( 'woocommerce_after_cart' );

View File

@ -17,6 +17,7 @@
* @package WooCommerce/Templates * @package WooCommerce/Templates
* @version 3.6.1 * @version 3.6.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -82,4 +83,4 @@ do_action( 'woocommerce_before_mini_cart' ); ?>
<?php endif; ?> <?php endif; ?>
<?php do_action( 'woocommerce_after_mini_cart' ); ?> <?php do_action( 'woocommerce_after_mini_cart' );

View File

@ -61,4 +61,4 @@ if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_requir
</form> </form>
<?php do_action( 'woocommerce_after_checkout_form', $checkout ); ?> <?php do_action( 'woocommerce_after_checkout_form', $checkout );

View File

@ -44,4 +44,4 @@ do_action( 'woocommerce_before_account_downloads', $has_downloads ); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php do_action( 'woocommerce_after_account_downloads', $has_downloads ); ?> <?php do_action( 'woocommerce_after_account_downloads', $has_downloads );

View File

@ -73,4 +73,4 @@ do_action( 'woocommerce_before_edit_account_form' ); ?>
<?php do_action( 'woocommerce_edit_account_form_end' ); ?> <?php do_action( 'woocommerce_edit_account_form_end' ); ?>
</form> </form>
<?php do_action( 'woocommerce_after_edit_account_form' ); ?> <?php do_action( 'woocommerce_after_edit_account_form' );

View File

@ -53,4 +53,4 @@ do_action( 'woocommerce_before_edit_account_address_form' ); ?>
<?php endif; ?> <?php endif; ?>
<?php do_action( 'woocommerce_after_edit_account_address_form' ); ?> <?php do_action( 'woocommerce_after_edit_account_address_form' );

View File

@ -117,4 +117,4 @@ do_action( 'woocommerce_before_customer_login_form' ); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php do_action( 'woocommerce_after_customer_login_form' ); ?> <?php do_action( 'woocommerce_after_customer_login_form' );

View File

@ -84,4 +84,4 @@ if ( $customer_orders ) : ?>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php endif; ?> <?php endif;

View File

@ -32,4 +32,4 @@ do_action( 'woocommerce_before_account_navigation' );
</div> </div>
</nav> </nav>
<?php do_action( 'woocommerce_after_account_navigation' ); ?> <?php do_action( 'woocommerce_after_account_navigation' );

View File

@ -104,4 +104,4 @@ do_action( 'woocommerce_before_account_orders', $has_orders ); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php do_action( 'woocommerce_after_account_orders', $has_orders ); ?> <?php do_action( 'woocommerce_after_account_orders', $has_orders );

View File

@ -51,4 +51,4 @@ if ( $product->is_in_stock() ) : ?>
<?php do_action( 'woocommerce_after_add_to_cart_form' ); ?> <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>
<?php endif; ?> <?php endif;