Skip to content

Commit

Permalink
CS: clean up codebase for new rules / pre-increment
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Aug 12, 2022
1 parent 18a68be commit 2759030
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion WordPress/Sniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ protected function get_last_ptr_on_line( $stackPtr ) {
$nextPtr = ( $stackPtr + 1 );

while ( isset( $tokens[ $nextPtr ] ) && $tokens[ $nextPtr ]['line'] === $currentLine ) {
$nextPtr++;
++$nextPtr;
// Do nothing, we just want the last token of the line.
}

Expand Down
2 changes: 1 addition & 1 deletion WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ protected function process_multi_line_array( $stackPtr, $opener, $closer ) {
&& substr( rtrim( $this->tokens[ $end_of_comment ]['content'] ), -2 ) !== '*/'
&& ( $end_of_comment + 1 ) < $end_of_this_item
) {
$end_of_comment++;
++$end_of_comment;
}

if ( $this->tokens[ $end_of_comment ]['line'] !== $this->tokens[ $end_of_last_item ]['line'] ) {
Expand Down
2 changes: 1 addition & 1 deletion WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function process_token( $stackPtr ) {

if ( \T_WHITESPACE === $this->tokens[ $i ]['code'] ) {
if ( $this->tokens[ $i ]['content'] === $this->phpcsFile->eolChar ) {
$newlines++;
++$newlines;
} else {
$spaces += $this->tokens[ $i ]['length'];
}
Expand Down
6 changes: 3 additions & 3 deletions WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ protected function process_multi_line_array( $stackPtr, $items, $opener, $closer
$items[ $key ]['single_line'] = true;
} else {
$items[ $key ]['single_line'] = false;
$multi_line_count++;
++$multi_line_count;
}

if ( ( $index_end_position + 2 ) <= $this->maxColumn ) {
Expand All @@ -368,7 +368,7 @@ protected function process_multi_line_array( $stackPtr, $items, $opener, $closer
if ( ! isset( $double_arrow_cols[ $this->tokens[ $double_arrow ]['column'] ] ) ) {
$double_arrow_cols[ $this->tokens[ $double_arrow ]['column'] ] = 1;
} else {
$double_arrow_cols[ $this->tokens[ $double_arrow ]['column'] ]++;
++$double_arrow_cols[ $this->tokens[ $double_arrow ]['column'] ];
}
}
unset( $key, $item, $double_arrow, $has_array_opener, $last_index_token );
Expand Down Expand Up @@ -413,7 +413,7 @@ protected function process_multi_line_array( $stackPtr, $items, $opener, $closer
if ( ! isset( $double_arrow_cols[ $this->tokens[ $item['operatorPtr'] ]['column'] ] ) ) {
$double_arrow_cols[ $this->tokens[ $item['operatorPtr'] ]['column'] ] = 1;
} else {
$double_arrow_cols[ $this->tokens[ $item['operatorPtr'] ]['column'] ]++;
++$double_arrow_cols[ $this->tokens[ $item['operatorPtr'] ]['column'] ];
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p
}

if ( $string !== $case_transform ) {
$case_errors++;
++$case_errors;
}
if ( $string !== $punct_transform ) {
$underscores++;
++$underscores;
}
}

Expand Down Expand Up @@ -270,18 +270,18 @@ protected function transform_complex_string( $string, $regex, $transform_type =
$is_variable = true;
if ( '{' === $part ) {
$has_braces = true;
$braces++;
++$braces;
}
continue;
}

if ( true === $is_variable ) {
if ( '[' === $part ) {
$has_braces = true;
$braces++;
++$braces;
}
if ( \in_array( $part, array( '}', ']' ), true ) ) {
$braces--;
--$braces;
}
if ( false === $has_braces && ' ' === $part ) {
$is_variable = false;
Expand Down
4 changes: 2 additions & 2 deletions WordPress/Sniffs/Security/EscapeOutputSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function process_token( $stackPtr ) {
}

// Ignore the function itself.
$stackPtr++;
++$stackPtr;

$in_cast = false;

Expand Down Expand Up @@ -315,7 +315,7 @@ public function process_token( $stackPtr ) {

// Handle arrays for those functions that accept them.
if ( \T_ARRAY === $this->tokens[ $i ]['code'] ) {
$i++; // Skip the opening parenthesis.
++$i; // Skip the opening parenthesis.
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion WordPress/Sniffs/WP/GlobalVariablesOverrideSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ protected function process_global_statement( $stackPtr, $in_function_scope ) {
}
}

$ptr++;
++$ptr;
}
unset( $var );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ public function process_token( $stackPtr ) {
$i = ( $scopeCloser + 1 );
while ( $this->tokens[ $i ]['line'] !== $this->tokens[ $trailingContent ]['line'] ) {
$this->phpcsFile->fixer->replaceToken( $i, '' );
$i++;
++$i;
}

// TODO: Instead a separate error should be triggered when content comes right after closing brace.
Expand Down

0 comments on commit 2759030

Please sign in to comment.