Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ New sniff to verify that spaces are used for mid-line alignment #942

Merged
merged 2 commits into from May 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions WordPress-Core/ruleset.xml
Expand Up @@ -54,6 +54,8 @@
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.SpaceInEmptyArray"/>
</rule>

<!-- Covers rule: ... while spaces can be used mid-line for alignment. -->
<rule ref="WordPress.WhiteSpace.DisallowInlineTabs"/>

<!--
#############################################################################
Expand Down
12 changes: 6 additions & 6 deletions WordPress/AbstractArrayAssignmentRestrictionsSniff.php
Expand Up @@ -68,12 +68,12 @@ public function register() {
* This method should be overridden in extending classes.
*
* Example: groups => array(
* 'groupname' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'keys' => array( 'key1', 'another_key' ),
* 'callback' => array( 'class', 'method' ), // Optional.
* )
* 'groupname' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'keys' => array( 'key1', 'another_key' ),
* 'callback' => array( 'class', 'method' ), // Optional.
* )
* )
*
* @return array
Expand Down
10 changes: 5 additions & 5 deletions WordPress/AbstractClassRestrictionsSniff.php
Expand Up @@ -36,11 +36,11 @@ abstract class WordPress_AbstractClassRestrictionsSniff extends WordPress_Abstra
* This method should be overridden in extending classes.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Avoid direct calls to the database.',
* 'classes' => array( 'PDO', '\Namespace\Classname' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Avoid direct calls to the database.',
* 'classes' => array( 'PDO', '\Namespace\Classname' ),
* )
* )
*
* You can use * wildcards to target a group of (namespaced) classes.
Expand Down
14 changes: 7 additions & 7 deletions WordPress/AbstractVariableRestrictionsSniff.php
Expand Up @@ -71,13 +71,13 @@ public function register() {
* This method should be overridden in extending classes.
*
* Example: groups => array(
* 'wpdb' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'variables' => array( '$val', '$var' ),
* 'object_vars' => array( '$foo->bar', .. ),
* 'array_members' => array( '$foo['bar']', .. ),
* )
* 'wpdb' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'variables' => array( '$val', '$var' ),
* 'object_vars' => array( '$foo->bar', .. ),
* 'array_members' => array( '$foo['bar']', .. ),
* )
* )
*
* @return array
Expand Down
2 changes: 1 addition & 1 deletion WordPress/Sniff.php
Expand Up @@ -269,7 +269,7 @@ abstract class WordPress_Sniff implements PHP_CodeSniffer_Sniff {
'sanitize_email' => true,
'sanitize_file_name' => true,
'sanitize_hex_color_no_hash' => true,
'sanitize_hex_color' => true,
'sanitize_hex_color' => true,
'sanitize_html_class' => true,
'sanitize_meta' => true,
'sanitize_mime_type' => true,
Expand Down
13 changes: 6 additions & 7 deletions WordPress/Sniffs/Arrays/ArrayAssignmentRestrictionsSniff.php
Expand Up @@ -27,13 +27,12 @@ class WordPress_Sniffs_Arrays_ArrayAssignmentRestrictionsSniff extends WordPress
* Groups of variables to restrict.
*
* Example: groups => array(
* 'wpdb' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'variables' => array( '$val', '$var' ),
* 'object_vars' => array( '$foo->bar', .. ),
* 'array_members' => array( '$foo['bar']', .. ),
* )
* 'groupname' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'keys' => array( 'key1', 'another_key' ),
* 'callback' => array( 'class', 'method' ), // Optional.
* )
* )
*
* @return array
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/DB/RestrictedClassesSniff.php
Expand Up @@ -27,11 +27,11 @@ class WordPress_Sniffs_DB_RestrictedClassesSniff extends WordPress_AbstractClass
* Groups of classes to restrict.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Avoid direct calls to the database.',
* 'classes' => array( 'PDO', '\Namespace\Classname' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Avoid direct calls to the database.',
* 'classes' => array( 'PDO', '\Namespace\Classname' ),
* )
* )
*
* @return array
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/DB/RestrictedFunctionsSniff.php
Expand Up @@ -27,11 +27,11 @@ class WordPress_Sniffs_DB_RestrictedFunctionsSniff extends WordPress_AbstractFun
* Groups of functions to restrict.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* )
*
* @return array
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/Functions/DontExtractSniff.php
Expand Up @@ -22,11 +22,11 @@ class WordPress_Sniffs_Functions_DontExtractSniff extends WordPress_AbstractFunc
* Groups of functions to restrict.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* )
*
* @return array
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/Functions/FunctionRestrictionsSniff.php
Expand Up @@ -26,11 +26,11 @@ class WordPress_Sniffs_Functions_FunctionRestrictionsSniff extends WordPress_Abs
* Groups of functions to restrict.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'eval', 'create_function' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be an unrelated change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above:

Mostly involved getGroups() function example comments. Some of these have also been adjusted slightly to be in line with an earlier change (#812) in which these were missed and/or with the comment from the abstract parent class.

* )
* )
*
* @return array
Expand Down
Expand Up @@ -115,7 +115,7 @@ protected function processTokenWithinScope( PHP_CodeSniffer_File $phpcsFile, $st
return;
}

$className = $phpcsFile->getDeclarationName( $currScope );
$className = $phpcsFile->getDeclarationName( $currScope );

// Ignore special functions.
if ( '' === ltrim( $methodName, '_' ) ) {
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/PHP/DevelopmentFunctionsSniff.php
Expand Up @@ -20,11 +20,11 @@ class WordPress_Sniffs_PHP_DevelopmentFunctionsSniff extends WordPress_AbstractF
* Groups of functions to restrict.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* )
*
* @return array
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/PHP/DiscouragedPHPFunctionsSniff.php
Expand Up @@ -20,11 +20,11 @@ class WordPress_Sniffs_PHP_DiscouragedPHPFunctionsSniff extends WordPress_Abstra
* Groups of functions to discourage.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* )
*
* @return array
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/PHP/POSIXFunctionsSniff.php
Expand Up @@ -25,11 +25,11 @@ class WordPress_Sniffs_PHP_POSIXFunctionsSniff extends WordPress_AbstractFunctio
* Groups of functions to restrict.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* )
*
* @return array
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/VIP/FileSystemWritesDisallowSniff.php
Expand Up @@ -31,11 +31,11 @@ class WordPress_Sniffs_VIP_FileSystemWritesDisallowSniff extends WordPress_Abstr
* Groups of functions to restrict.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'eval', 'create_function' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* )
*
* @return array
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/VIP/RestrictedFunctionsSniff.php
Expand Up @@ -31,11 +31,11 @@ class WordPress_Sniffs_VIP_RestrictedFunctionsSniff extends WordPress_AbstractFu
* Groups of functions to restrict.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* )
*
* @return array
Expand Down
14 changes: 7 additions & 7 deletions WordPress/Sniffs/VIP/RestrictedVariablesSniff.php
Expand Up @@ -22,13 +22,13 @@ class WordPress_Sniffs_VIP_RestrictedVariablesSniff extends WordPress_AbstractVa
* Groups of variables to restrict.
*
* Example: groups => array(
* 'wpdb' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'variables' => array( '$val', '$var' ),
* 'object_vars' => array( '$foo->bar', .. ),
* 'array_members' => array( '$foo['bar']', .. ),
* )
* 'wpdb' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'variables' => array( '$val', '$var' ),
* 'object_vars' => array( '$foo->bar', .. ),
* 'array_members' => array( '$foo['bar']', .. ),
* )
* )
*
* @return array
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/VIP/SessionFunctionsUsageSniff.php
Expand Up @@ -24,11 +24,11 @@ class WordPress_Sniffs_VIP_SessionFunctionsUsageSniff extends WordPress_Abstract
* Groups of functions to restrict.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'eval', 'create_function' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* )
*
* @return array
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/VIP/TimezoneChangeSniff.php
Expand Up @@ -24,11 +24,11 @@ class WordPress_Sniffs_VIP_TimezoneChangeSniff extends WordPress_AbstractFunctio
* Groups of functions to restrict.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'eval', 'create_function' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* )
*
* @return array
Expand Down
14 changes: 7 additions & 7 deletions WordPress/Sniffs/Variables/VariableRestrictionsSniff.php
Expand Up @@ -27,13 +27,13 @@ class WordPress_Sniffs_Variables_VariableRestrictionsSniff extends WordPress_Abs
* Groups of variables to restrict.
*
* Example: groups => array(
* 'wpdb' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'variables' => array( '$val', '$var' ),
* 'object_vars' => array( '$foo->bar', .. ),
* 'array_members' => array( '$foo['bar']', .. ),
* )
* 'wpdb' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'variables' => array( '$val', '$var' ),
* 'object_vars' => array( '$foo->bar', .. ),
* 'array_members' => array( '$foo['bar']', .. ),
* )
* )
*
* @return array
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/WP/AlternativeFunctionsSniff.php
Expand Up @@ -20,11 +20,11 @@ class WordPress_Sniffs_WP_AlternativeFunctionsSniff extends WordPress_AbstractFu
* Groups of functions to restrict.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* )
*
* @return array
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/WP/DiscouragedFunctionsSniff.php
Expand Up @@ -20,11 +20,11 @@ class WordPress_Sniffs_WP_DiscouragedFunctionsSniff extends WordPress_AbstractFu
* Groups of functions to restrict.
*
* Example: groups => array(
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* 'lambda' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Use anonymous functions instead please!',
* 'functions' => array( 'file_get_contents', 'create_function' ),
* )
* )
*
* @return array
Expand Down