Skip to content

Commit 325f3ba

Browse files
committed
Only record param missing metric when the autoload parameter is optional
1 parent 21a5350 commit 325f3ba

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

WordPress/Sniffs/WP/OptionAutoloadSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ private function handle_wp_set_option_autoload_values( array $options_param ) {
293293
* @return void
294294
*/
295295
private function maybe_display_missing_autoload_warning( $stackPtr, $function_name ) {
296-
$this->phpcsFile->recordMetric( $stackPtr, self::METRIC_NAME, 'param missing' );
297-
298296
// Only display a warning for the functions in which the `$autoload` parameter is optional.
299297
if ( isset( $this->autoload_is_optional[ $function_name ] ) ) {
298+
$this->phpcsFile->recordMetric( $stackPtr, self::METRIC_NAME, 'param missing' );
299+
300300
$this->phpcsFile->addWarning(
301301
'It is recommended to always pass the `$autoload` parameter when using %s() function.',
302302
$stackPtr,

0 commit comments

Comments
 (0)