CORE-POS/Common-Bundle

View on GitHub

Showing 1,039 of 1,039 total issues

Method printMarkdown has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function printMarkdown($files)
    {
        $tables = array();
        $tables = array_reduce($files,
            function ($carry, $file) {
Severity: Minor
Found in src/BasicModel.php - About 1 hr to fix

    Method transfer has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function transfer($source_db,$select_query,$dest_db,$insert_query)
        {
            $result = $this->query($select_query,$source_db);
            if (!$result) {
                return false;
    Severity: Minor
    Found in src/SQLManager.php - About 1 hr to fix

      Function normalizeChangeCase has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          private function normalizeChangeCase($db_name, $mode=BasicModel::NORMALIZE_MODE_CHECK)
          {
              $current = $this->connection->detailedDefinition($this->name);
              $lowercase_current = array();
              $casemap = array();
      Severity: Minor
      Found in src/BasicModel.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 transfer has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function transfer($source_db,$select_query,$dest_db,$insert_query)
          {
              $result = $this->query($select_query,$source_db);
              if (!$result) {
                  return false;
      Severity: Minor
      Found in src/SQLManager.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

      The class BasicModel has 16 fields. Consider redesigning BasicModel to keep the number of fields under 15.
      Open

      class BasicModel 
      {
          /**
            Name of the table
          */
      Severity: Minor
      Found in src/BasicModel.php by phpmd

      TooManyFields

      Since: 0.1

      Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

      Example

      class Person {
         protected $one;
         private $two;
         private $three;
         [... many more fields ...]
      }

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

      Method save has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function save()
          {
              if (!is_array($this->hooks) || empty($this->hooks)) {
                  $this->loadHooks();
              }
      Severity: Minor
      Found in src/BasicModel.php - About 1 hr to fix

        Method drawPage has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function drawPage()
            {
                $this->preFlight();
                if ($this->preprocess()) {
        
        
        Severity: Minor
        Found in src/ui/CorePage.php - About 1 hr to fix

          Method load has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function load()
              {
                  if (empty($this->unique)) {
                      return false;
                  }
          Severity: Minor
          Found in src/BasicModel.php - About 1 hr to fix

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

                public function drawPage()
                {
                    $this->preFlight();
                    if ($this->preprocess()) {
            
            
            Severity: Minor
            Found in src/ui/CorePage.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 normalizeChangeCase has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function normalizeChangeCase($db_name, $mode=BasicModel::NORMALIZE_MODE_CHECK)
                {
                    $current = $this->connection->detailedDefinition($this->name);
                    $lowercase_current = array();
                    $casemap = array();
            Severity: Minor
            Found in src/BasicModel.php - About 1 hr to fix

              Avoid using short method names like BasicModel::db(). The configured minimum method name length is 3.
              Open

                  public function db()
                  { 
                      return $this->connection;
                  }
              Severity: Minor
              Found in src/BasicModel.php by phpmd

              ShortMethodName

              Since: 0.2

              Detects when very short method names are used.

              Example

              class ShortMethod {
                  public function a( $index ) { // Violation
                  }
              }

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

              Method insertRecord has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function insertRecord()
                  {
                      $sql = 'INSERT INTO '.$this->fq_name;
                      $cols = '(';
                      $vals = '(';
              Severity: Minor
              Found in src/BasicModel.php - About 1 hr to fix

                Method unitTest has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function unitTest($phpunit)
                    {
                        $this->__routes = array(
                            'get',
                            'get<id>',
                Severity: Minor
                Found in src/ui/CoreRESTfulRouter.php - About 1 hr to fix

                  Method updateRecord has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function updateRecord()
                      {
                          $sql = 'UPDATE '.$this->fq_name;
                          $sets = '';
                          $where = '1=1';
                  Severity: Minor
                  Found in src/BasicModel.php - About 1 hr to fix

                    Method addConnection has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function addConnection($server,$type,$database,$username,$password='',$persistent=false,$new=false)
                        {
                            if (empty($type)) {
                                return false;
                            } elseif (strtolower($type) == 'postgres9') {
                    Severity: Minor
                    Found in src/SQLManager.php - About 1 hr to fix

                      Method fieldType has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function fieldType($result_object,$index,$which_connection='')
                          {
                              if ($which_connection == '') {
                                  $which_connection = $this->default_db;
                              }
                      Severity: Minor
                      Found in src/SQLManager.php - About 1 hr to fix

                        Avoid using undefined variables such as '$FANNIE_SERVER_USER' which will lead to PHP notices.
                        Open

                                    $this->connection = new \COREPOS\common\SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW, true);
                        Severity: Minor
                        Found in src/ui/CorePage.php by phpmd

                        UndefinedVariable

                        Since: 2.8.0

                        Detects when a variable is used that has not been defined before.

                        Example

                        class Foo
                        {
                            private function bar()
                            {
                                // $message is undefined
                                echo $message;
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                        Avoid using undefined variables such as '$FANNIE_SERVER_DBMS' which will lead to PHP notices.
                        Open

                                    $this->connection = new \COREPOS\common\SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW, true);
                        Severity: Minor
                        Found in src/ui/CorePage.php by phpmd

                        UndefinedVariable

                        Since: 2.8.0

                        Detects when a variable is used that has not been defined before.

                        Example

                        class Foo
                        {
                            private function bar()
                            {
                                // $message is undefined
                                echo $message;
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                        Avoid using undefined variables such as '$FANNIE_SERVER' which will lead to PHP notices.
                        Open

                                    $this->connection = new \COREPOS\common\SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW, true);
                        Severity: Minor
                        Found in src/ui/CorePage.php by phpmd

                        UndefinedVariable

                        Since: 2.8.0

                        Detects when a variable is used that has not been defined before.

                        Example

                        class Foo
                        {
                            private function bar()
                            {
                                // $message is undefined
                                echo $message;
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                        Avoid using undefined variables such as '$FANNIE_SERVER_PW' which will lead to PHP notices.
                        Open

                                    $this->connection = new \COREPOS\common\SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW, true);
                        Severity: Minor
                        Found in src/ui/CorePage.php by phpmd

                        UndefinedVariable

                        Since: 2.8.0

                        Detects when a variable is used that has not been defined before.

                        Example

                        class Foo
                        {
                            private function bar()
                            {
                                // $message is undefined
                                echo $message;
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                        Severity
                        Category
                        Status
                        Source
                        Language