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 -->
<?php get_footer(); ?>
<?php get_footer();

View File

@ -70,4 +70,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</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 ) ) : ?>
<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; ?>
</dl>
<?php endif; ?>
@ -105,4 +105,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #author-wrapper -->
<?php get_footer(); ?>
<?php get_footer();

View File

@ -15,10 +15,11 @@
},
"require-dev": {
"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": {
"test": ["phpcs"],
"fix": ["phpcbf"]
"test": ["vendor/bin/phpcs"],
"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",
"This file is @generated automatically"
],
"content-hash": "6f047956cbb4861fde466b775966f717",
"content-hash": "6e38e340aaa610ed48211f151263555e",
"packages": [
{
"name": "composer/installers",
@ -194,6 +194,64 @@
],
"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",
"version": "3.4.2",
@ -250,12 +308,12 @@
"version": "2.1.1",
"source": {
"type": "git",
"url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
"url": "https://github.com/WordPress/WordPress-Coding-Standards.git",
"reference": "bd9c33152115e6741e3510ff7189605b35167908"
},
"dist": {
"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",
"shasum": ""
},

View File

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

View File

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

View File

@ -8,13 +8,14 @@
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
/**
if ( ! function_exists( 'understrap_slbd_count_widgets' ) ) {
/**
* 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
*
* @param int $sidebar_id The ID of the sidebar.
* @deprecated 0.8.9
*/
if ( ! function_exists( 'understrap_slbd_count_widgets' ) ) {
function understrap_slbd_count_widgets( $sidebar_id ) {
// If loading from front page, consult $_wp_sidebars_widgets rather than options
// to see if wp_convert_widget_settings() has made manipulations in memory.

View File

@ -83,7 +83,7 @@ if ( ! function_exists( 'understrap_change_logo_class' ) ) {
* Display navigation to next/previous post when applicable.
*/
if ( ! function_exists ( 'understrap_post_nav' ) ) {
if ( ! function_exists( 'understrap_post_nav' ) ) {
function understrap_post_nav() {
// Don't print empty markup if there's nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );

View File

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

View File

@ -15,7 +15,7 @@ if ( ! isset( $content_width ) ) {
add_action( 'after_setup_theme', 'understrap_setup' );
if ( ! function_exists ( 'understrap_setup' ) ) {
if ( ! function_exists( 'understrap_setup' ) ) {
/**
* Sets up theme defaults and registers support for various WordPress features.
*

View File

@ -72,4 +72,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</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 -->
<?php get_footer(); ?>
<?php get_footer();

View File

@ -52,4 +52,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</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 -->
<?php get_footer(); ?>
<?php get_footer();

View File

@ -51,4 +51,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</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 -->
<?php get_footer(); ?>
<?php get_footer();

110
phpcs.xml
View File

@ -1,10 +1,17 @@
<?xml version="1.0"?>
<ruleset name="WordPress Theme 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 -->
<ruleset name="UnderStrap Coding Standards">
<!-- 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 -->
<arg name="extensions" value="php"/>
@ -13,31 +20,86 @@
<file>.</file>
<!-- Ignore the vendor directory -->
<exclude-pattern>./vendor</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<!-- Show colors in console -->
<arg value="-colors"/>
<!-- Use the WordPress Ruleset -->
<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 -->
<arg value="s"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma"/>
<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.Indent" />
<exclude name="Squiz.Commenting.FileComment.SpacingAfterComment" />
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag" />
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
<exclude name="Squiz.Commenting.InlineComment.NotCapital" />
</rule>
<rule ref="WordPress-Docs">
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"/>
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine"/>
<exclude name="PEAR.Functions.FunctionCallSignature.Indent"/>
<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments"/>
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/>
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar"/>
<exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"/>
<exclude name="Squiz.PHP.DisallowMultipleAssignments.Found"/>
<exclude name="Squiz.PHP.EmbeddedPhp"/>
</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>
<!--
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>

View File

@ -75,4 +75,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</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 -->
<?php endif; ?>
<?php endif;

View File

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

View File

@ -15,4 +15,4 @@ defined( 'ABSPATH' ) || exit;
<?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 -->
<?php endif; ?>
<?php endif;

View File

@ -49,4 +49,4 @@ $container = get_theme_mod( 'understrap_container_type' );
</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' ); ?>
</a>
</p>
<?php endif; ?>
<?php endif;

View File

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

View File

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

View File

@ -32,4 +32,4 @@ do_action( 'woocommerce_before_account_navigation' );
</div>
</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>
<?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 endif; ?>
<?php endif;