#642·rickshaw

codeql complains about "Identical operands" in `discoverRange`

Author: jsorefCreated Nov 13, 2025Updated Nov 13, 2025

Identical operands

Passing identical, or seemingly identical, operands to an operator such as subtraction or conjunction may indicate a typo; even if it is intentional, it makes the code hard to read.

The operands are for - in the first array slot of the call to domain() in each of these two lines:

https://github.com/shutterstock/rickshaw/blob/0e0671e6fdd843b6b0ea881600804fc57667925d/src/js/Rickshaw.Graph.js#L125

diff
- .domain([domain.x[0] - domain.x[0], domain.x[1] - domain.x[0]]) 
+ .domain([0, domain.x[1] - domain.x[0]]) 

https://github.com/shutterstock/rickshaw/blob/0e0671e6fdd843b6b0ea881600804fc57667925d/src/js/Rickshaw.Graph.js#L129

diff
- .domain([domain.y[0] - domain.y[0], domain.y[1] - domain.y[0]]) 
+ .domain([0, domain.y[1] - domain.y[0]]) 

The diffs I'm providing are equivalent minus being much cheaper. I'm not saying that's necessarily the intent of the code, but it's what's happening here (minus extra cycles either at compile time or runtime).

  • #134 mentions this code