Skip to content

Commit 7920531

Browse files
authored
Merge pull request #285 from rebeccahum/rebecca/remove_string_concat_error_msg
Remove string concatenation from message for better readability.
2 parents 59fb245 + 58f935a commit 7920531

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

WordPressVIPMinimum/Sniffs/Functions/CreateFunctionSniff.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ public function process( File $phpcsFile, $stackPtr ) {
8080
}
8181

8282
$phpcsFile->addError(
83-
'create_function() is deprecated as of ' .
84-
'PHP 7.2.0',
83+
'create_function() is deprecated as of PHP 7.2.0.',
8584
$functionName,
8685
'CreateFunction'
8786
);

WordPressVIPMinimum/Sniffs/Functions/DynamicCallsSniff.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,17 +251,10 @@ private function find_dynamic_calls() {
251251

252252
// We do, so report.
253253
$this->_phpcsFile->addError(
254-
sprintf(
255-
'Dynamic calling is not recommended ' .
256-
'in the case of %s',
257-
$this->_variables_arr[
258-
$this->_tokens[
259-
$this->_stackPtr
260-
]['content']
261-
]
262-
),
254+
'Dynamic calling is not recommended in the case of %s',
263255
$t_item_key,
264-
'DynamicCalls'
256+
'DynamicCalls',
257+
[ $this->_variables_arr[ $this->_tokens[ $this->_stackPtr ]['content'] ] ]
265258
);
266259
}
267260
}

WordPressVIPMinimum/Sniffs/JS/WindowSniff.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,21 @@ public function process( File $phpcsFile, $stackPtr ) {
132132
$prevTokenPtr = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true, null, true );
133133
if ( T_EQUAL === $tokens[ $prevTokenPtr ]['code'] ) {
134134
// Variable assignment.
135-
$phpcsFile->addWarning( sprintf( 'Data from JS global "' . $windowProperty . '" may contain user-supplied values and should be checked.', $tokens[ $stackPtr ]['content'] ), $stackPtr, 'VarAssignment' );
135+
$phpcsFile->addWarning(
136+
'Data from JS global "%s" may contain user-supplied values and should be checked.',
137+
$stackPtr,
138+
'VarAssignment',
139+
[ $windowProperty ]
140+
);
136141
return;
137142
}
138143

139-
$phpcsFile->addError( sprintf( 'Data from JS global "' . $windowProperty . '" may contain user-supplied values and should be sanitized before output to prevent XSS.', $tokens[ $stackPtr ]['content'] ), $stackPtr, $nextNextToken );
144+
$phpcsFile->addError(
145+
'Data from JS global "%s" may contain user-supplied values and should be sanitized before output to prevent XSS.',
146+
$stackPtr,
147+
$nextNextToken,
148+
[ $windowProperty ]
149+
);
140150
}
141151

142152
}

0 commit comments

Comments
 (0)