src/PHPixie/ORM/Mappers/Conditions/Optimizer.php

Summary

Maintainability
C
7 hrs
Test Coverage

Function extractCollections has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    protected function extractCollections($conditions, $parseLogic = false)
    {
        $extracted = array();
        $count = count($conditions);
        foreach($conditions as $key => $condition) {
Severity: Minor
Found in src/PHPixie/ORM/Mappers/Conditions/Optimizer.php - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method extractCollections has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function extractCollections($conditions, $parseLogic = false)
    {
        $extracted = array();
        $count = count($conditions);
        foreach($conditions as $key => $condition) {
Severity: Minor
Found in src/PHPixie/ORM/Mappers/Conditions/Optimizer.php - About 1 hr to fix

    Function findMergeTarget has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function findMergeTarget($conditionList, $newCondition)
        {
            $isNextFree = true;
            $newPrecedance = $this->logicPrecedance[$newCondition->logic()];
            
    Severity: Minor
    Found in src/PHPixie/ORM/Mappers/Conditions/Optimizer.php - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Avoid too many return statements within this method.
    Open

            return false;
    Severity: Major
    Found in src/PHPixie/ORM/Mappers/Conditions/Optimizer.php - About 30 mins to fix

      Function merge has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function merge($left, $right)
          {
              if(count($right) !== 1)
                  return $this->mergeConditions($left, $right);
              
      Severity: Minor
      Found in src/PHPixie/ORM/Mappers/Conditions/Optimizer.php - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function isExpandable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function isExpandable($group, $minPrecedance)
          {
              $conditions = $group->conditions();
              foreach($conditions as $key => $condition){
                  if($key == 0)
      Severity: Minor
      Found in src/PHPixie/ORM/Mappers/Conditions/Optimizer.php - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      There are no issues that match your filters.

      Category
      Status