Showing 106 of 106 total issues

File SQL.php has 375 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 *  This is Spoof.
 *  Copyright (C) 2011-2017  Spoof project.
Severity: Minor
Found in src/lib360/db/language/SQL.php - About 5 hrs to fix

    The class ModelList has 12 public methods. Consider refactoring ModelList to keep number of public methods under 10.
    Open

    class ModelList implements IModelList
    {
    
        /**
         * List of records to iterate over
    Severity: Minor
    Found in src/lib360/db/data/ModelList.php by phpmd

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

    Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

    The class SQL has an overall complexity of 73 which is very high. The configured complexity threshold is 50.
    Open

    class SQL implements ILanguage
    {
        const SELECT = 'select';
        const SELECT_AS = 'as';
        const SELECT_FIELD_SEPARATOR = ', ';
    Severity: Minor
    Found in src/lib360/db/language/SQL.php by phpmd

    Method __construct has 74 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __construct($value, $type = null)
        {
            // validate type and value
            if (is_null($type)) {
                $type = $this->determineType($value);
    Severity: Major
    Found in src/lib360/db/value/Value.php - About 2 hrs to fix

      Function __construct has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __construct($value, $type = null)
          {
              // validate type and value
              if (is_null($type)) {
                  $type = $this->determineType($value);
      Severity: Minor
      Found in src/lib360/db/value/Value.php - About 2 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

      Function getConditionOperator has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getConditionOperator(IDriver $driver, ICondition $condition)
          {
              switch ($condition->operator) {
                  case Condition::OPERATOR_EQUALS:
                      if ($condition->value2->getType() == Value::TYPE_NULL) {
      Severity: Minor
      Found in src/lib360/db/language/SQL.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

      Method getConditionOperator has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getConditionOperator(IDriver $driver, ICondition $condition)
          {
              switch ($condition->operator) {
                  case Condition::OPERATOR_EQUALS:
                      if ($condition->value2->getType() == Value::TYPE_NULL) {
      Severity: Minor
      Found in src/lib360/db/language/SQL.php - About 1 hr to fix

        Method getValue has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getValue(IDriver $driver, IValue $value)
            {
                $query = new Query();
                switch ($value->getType()) {
                    case Value::TYPE_PREPARED:
        Severity: Minor
        Found in src/lib360/db/language/SQL.php - About 1 hr to fix

          Method handleRequest has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function handleRequest(api\Request $request)
              {
                  $response = new api\Response();
                  try {
                      // map request to class and method
          Severity: Minor
          Found in src/lib360/api/router/Rest.php - About 1 hr to fix

            Method getJoin has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getJoin(IDriver $driver, IJoin $join)
                {
                    $query = new Query();
                    $query->setString($driver->tableQuoteStart . $join->tableBase . $driver->tableQuoteEnd);
                    foreach ($join->tableJoin as $i => $table) {
            Severity: Minor
            Found in src/lib360/db/language/SQL.php - About 1 hr to fix

              Function bindValues has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function bindValues(\PDOStatement $sth, array $values = null)
                  {
                      if (!is_null($values)) {
                          foreach ($values as $key => $value) {
                              $type = \PDO::PARAM_STR;
              Severity: Minor
              Found in src/lib360/db/executor/PDO.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

              Function getCondition has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function getCondition(array $conditions) {
                      $conditionGroup = null;
                      if (count($conditions) == 1) {
                          foreach ($conditions as $column => $value) {
                              $conditionGroup = new Condition(
              Severity: Minor
              Found in src/lib360/db/data/Table.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

              Method sendResponse has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function sendResponse(api\Response $response)
                  {
                      $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ?
                          $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
                      $body = null;
              Severity: Minor
              Found in src/lib360/api/request/handler/Rest.php - About 1 hr to fix

                Function get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function get($type, $name)
                    {
                        if (isset(self::$objects[$type]) && isset(self::$objects[$type][$name])) {
                            $object = self::$objects[$type][$name];
                        } else {
                Severity: Minor
                Found in src/lib360/db/object/Factory.php - About 55 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 getValue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getValue(IDriver $driver, IValue $value)
                    {
                        $query = new Query();
                        switch ($value->getType()) {
                            case Value::TYPE_PREPARED:
                Severity: Minor
                Found in src/lib360/db/language/SQL.php - About 55 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

                Avoid variables with short names like $db. Configured minimum length is 3.
                Open

                    public function setDB($db)
                Severity: Minor
                Found in src/lib360/db/data/Store.php by phpmd

                ShortVariable

                Since: 0.2

                Detects when a field, local, or parameter has a very short name.

                Example

                class Something {
                    private $q = 15; // VIOLATION - Field
                    public static function main( array $as ) { // VIOLATION - Formal
                        $r = 20 + $this->q; // VIOLATION - Local
                        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                            $r += $this->q;
                        }
                    }
                }

                Source https://phpmd.org/rules/naming.html#shortvariable

                Avoid variables with short names like $i. Configured minimum length is 3.
                Open

                        $i = 0;
                Severity: Minor
                Found in src/lib360/db/language/SQL.php by phpmd

                ShortVariable

                Since: 0.2

                Detects when a field, local, or parameter has a very short name.

                Example

                class Something {
                    private $q = 15; // VIOLATION - Field
                    public static function main( array $as ) { // VIOLATION - Formal
                        $r = 20 + $this->q; // VIOLATION - Local
                        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                            $r += $this->q;
                        }
                    }
                }

                Source https://phpmd.org/rules/naming.html#shortvariable

                Avoid variables with short names like $i. Configured minimum length is 3.
                Open

                        $i = 0;
                Severity: Minor
                Found in src/lib360/db/language/SQL.php by phpmd

                ShortVariable

                Since: 0.2

                Detects when a field, local, or parameter has a very short name.

                Example

                class Something {
                    private $q = 15; // VIOLATION - Field
                    public static function main( array $as ) { // VIOLATION - Formal
                        $r = 20 + $this->q; // VIOLATION - Local
                        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                            $r += $this->q;
                        }
                    }
                }

                Source https://phpmd.org/rules/naming.html#shortvariable

                Avoid variables with short names like $db. Configured minimum length is 3.
                Open

                        $db = Pool::getByName($this->db);
                Severity: Minor
                Found in src/lib360/db/data/Table.php by phpmd

                ShortVariable

                Since: 0.2

                Detects when a field, local, or parameter has a very short name.

                Example

                class Something {
                    private $q = 15; // VIOLATION - Field
                    public static function main( array $as ) { // VIOLATION - Formal
                        $r = 20 + $this->q; // VIOLATION - Local
                        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                            $r += $this->q;
                        }
                    }
                }

                Source https://phpmd.org/rules/naming.html#shortvariable

                Avoid variables with short names like $db. Configured minimum length is 3.
                Open

                        $db = Pool::getByName($this->db);
                Severity: Minor
                Found in src/lib360/db/data/Table.php by phpmd

                ShortVariable

                Since: 0.2

                Detects when a field, local, or parameter has a very short name.

                Example

                class Something {
                    private $q = 15; // VIOLATION - Field
                    public static function main( array $as ) { // VIOLATION - Formal
                        $r = 20 + $this->q; // VIOLATION - Local
                        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                            $r += $this->q;
                        }
                    }
                }

                Source https://phpmd.org/rules/naming.html#shortvariable

                Severity
                Category
                Status
                Source
                Language