Your project should not use function in loops conditions 3

More information: https://insight.symfony.com/what-we-analyse/php.for_loop_uses_test_function

  1. // Keep highest priority, cancel others
  2. $kept = $objectives[0];
  3. $cancelled = [];
  4. for ($i = 1; $i < count($objectives); $i++) {
    This loop uses a function. To avoid the overhead of executing the function n times, you should precalculate it before the loop.
    Time to fix: about 15 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by clicshopping
  5. $obj = $objectives[$i];
  6. $registry->cancelObjective($obj->getId(), 'Cancelled due to conflict with higher priority objective');
  7. $cancelled[] = $obj->getId();
  8. }
  1. {
  2. // Find logical inconsistencies
  3. $inconsistencies = [];
  4. // Simple contradiction detection
  5. for ($i = 0; $i < count($statements); $i++) {
    This loop uses a function. To avoid the overhead of executing the function n times, you should precalculate it before the loop.
    Time to fix: about 15 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by clicshopping
  6. for ($j = $i + 1; $j < count($statements); $j++) {
  7. if ($this->areContradictory($statements[$i], $statements[$j])) {
  8. $inconsistencies[] = [
  9. 'statement1' => $statements[$i],
  10. 'statement2' => $statements[$j],
  1. // Find logical inconsistencies
  2. $inconsistencies = [];
  3. // Simple contradiction detection
  4. for ($i = 0; $i < count($statements); $i++) {
  5. for ($j = $i + 1; $j < count($statements); $j++) {
    This loop uses a function. To avoid the overhead of executing the function n times, you should precalculate it before the loop.
    Time to fix: about 15 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by clicshopping
  6. if ($this->areContradictory($statements[$i], $statements[$j])) {
  7. $inconsistencies[] = [
  8. 'statement1' => $statements[$i],
  9. 'statement2' => $statements[$j],
  10. 'type' => 'contradiction'