1.2.378. Double Instructions

Twice the same call in a row. This might be a typo, and the second call is useless.

It may also be an non-idempotent method: that is, a method which has a different result when called with the same arguments. For example, rand() or fgets().

<?php

// repetition of the same command, with the same effect each time.
$a = array_merge($b, $c);
$a = array_merge($b, $c);

// false positive : commands are identical, but the effect is compounded
$a = array_merge($a, $c);
$a = array_merge($a, $c);

?>

1.2.378.1. Suggestions

  • Remove double work

  • Avoid repetition by using loops, variadic or quantifiers (dirname($path, 2))

1.2.378.2. Specs

Short name

Structures/DoubleInstruction

Rulesets

All, Analyze

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Instant (5 mins)

Precision

Very high

Features

idempotent

Available in

Entreprise Edition, Exakat Cloud