redundant boolean literal in conditional return statement
343 dNorthing >= (m_stStartNode.stNodeLocation.dNorthing - constants::ASTAR_MAXIMUM_SEARCH_GRID - constants::ASTAR_NODE_SIZE) &&
344 dNorthing <= (m_stStartNode.stNodeLocation.dNorthing + constants::ASTAR_MAXIMUM_SEARCH_GRID + constants::ASTAR_NODE_SIZE))
345 {
346 return true;347 }
348 // Return false if boundary check failed.
349 return false;
Description
Boolean expressions involving boolean constants can be simplified to use the appropriate boolean expression directly, using DeMorgan's Theorem. This helps in improving code readability and reducing unnecessary complexity.
Bad Practice
if (b == true); // can be simplified to if (b)
if (b == false); // can be simplified to if (!b)
if (b && true); // can be simplified to if (b)
if (b && false); // can be simplified to if (false)
if (b || true); // can be simplified to if (true)
if (b || false); // can be simplified to if (b)
e ? true : false; // can be simplified to e
e ? false : true; // can be simplified to !e
if (true) t(); else f(); // can be simplified to t();
if (!a || !b); // can be simplified to if (a && b);
Recommended
if (b) // simplified form
if (!b) // simplified form
if (b) // simplified form
if (false) // simplified form
if (true) // simplified form
if (b) // simplified form
e // simplified form
!e // simplified form
t(); // simplified form
if (a && b); // simplified