menu

prefer-multiplication-over-power

Prefer multiplication over squaring with exponentiation

Exponentiation performs a general power operation when an expression is only squared. Instead, you SHOULD multiply the base by itself when its evaluation may be duplicated.

Reported

1function square(value: float64): float64 {2    return value ** 2;3}

Accepted

1function square(value: float64): float64 {2    return value * value;3}