phpcs-variable-analysis icon indicating copy to clipboard operation
phpcs-variable-analysis copied to clipboard

Sniff for detecting single-use variables?

Open lkraav opened this issue 5 years ago • 1 comments

Trying to avoid this example BAD (due to refactoring, or simple human error):

$has_free_tag = has_tag( 'free' );

if ( $has_free_tag ) {
  ...
}

BETTER:

if ( has_tag( 'free' ) ) {
  ...
}

lkraav avatar Oct 16 '20 11:10 lkraav

That would be pretty cool! And not too hard, I think.

sirbrillig avatar Oct 16 '20 14:10 sirbrillig