CORE-POS/IS4C

View on GitHub
common/BasicModel.php

Summary

Maintainability
F
1 wk
Test Coverage
D
67%

File BasicModel.php has 1106 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*******************************************************************************

    Copyright 2013 Whole Foods Co-op

Severity: Major
Found in common/BasicModel.php - About 2 days to fix

    Function normalize has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

        public function normalize($db_name, $mode=BasicModel::NORMALIZE_MODE_CHECK)
        {
            if ($mode != BasicModel::NORMALIZE_MODE_CHECK && $mode != BasicModel::NORMALIZE_MODE_APPLY) {
                echo "Error: Unknown mode ($mode)\n";
                return false;
    Severity: Minor
    Found in common/BasicModel.php - About 1 day 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

    BasicModel has 54 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BasicModel 
    {
        /**
          Name of the table
        */
    Severity: Major
    Found in common/BasicModel.php - About 7 hrs to fix

      Method normalize has 111 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function normalize($db_name, $mode=BasicModel::NORMALIZE_MODE_CHECK)
          {
              if ($mode != BasicModel::NORMALIZE_MODE_CHECK && $mode != BasicModel::NORMALIZE_MODE_APPLY) {
                  echo "Error: Unknown mode ($mode)\n";
                  return false;
      Severity: Major
      Found in common/BasicModel.php - About 4 hrs to fix

        Function find has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

            public function find($sort='', $reverse=false)
            {
                if (!is_array($sort)) {
                    $sort = array($sort);
                }
        Severity: Minor
        Found in common/BasicModel.php - About 4 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 cli has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

            public function cli($argc, $argv)
            {
                if ($argc > 2 && $argv[1] == '--doc') {
                    array_shift($argv);
                    array_shift($argv);
        Severity: Minor
        Found in common/BasicModel.php - About 4 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 normalizeColumnAttributes has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            private function normalizeColumnAttributes($db_name, $mode=BasicModel::NORMALIZE_MODE_CHECK)
            {
                $current = $this->connection->detailedDefinition($this->name);
                $dbms = $this->connection->dbmsName();
                $recase_columns = array();
        Severity: Minor
        Found in common/BasicModel.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

        Function create has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public function create()
            {
                if ($this->connection->tableExists($this->fq_name)) {
                    return true;
                }
        Severity: Minor
        Found in common/BasicModel.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

        Method cli has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function cli($argc, $argv)
            {
                if ($argc > 2 && $argv[1] == '--doc') {
                    array_shift($argv);
                    array_shift($argv);
        Severity: Major
        Found in common/BasicModel.php - About 2 hrs to fix

          Function insertRecord has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function insertRecord()
              {
                  $sql = 'INSERT INTO '.$this->fq_name;
                  $cols = '(';
                  $vals = '(';
          Severity: Minor
          Found in common/BasicModel.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

          Method find has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function find($sort='', $reverse=false)
              {
                  if (!is_array($sort)) {
                      $sort = array($sort);
                  }
          Severity: Major
          Found in common/BasicModel.php - About 2 hrs to fix

            Function normalizeRename has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                private function normalizeRename($db_name, $mode=BasicModel::NORMALIZE_MODE_CHECK)
                {
                    $current = $this->connection->detailedDefinition($this->name);
                    $dbms = $this->connection->dbmsName();
                    $recase_columns = array();
            Severity: Minor
            Found in common/BasicModel.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 load has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function load()
                {
                    if (empty($this->unique)) {
                        return false;
                    }
            Severity: Minor
            Found in common/BasicModel.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 __call has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function __call($name, $arguments)
                {
                    if (!isset($this->columns[$name])) {
                        foreach ($this->columns as $col => $info) {
                            if (isset($info['replaces']) && $info['replaces'] == $name) {
            Severity: Minor
            Found in common/BasicModel.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

            Method create has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function create()
                {
                    if ($this->connection->tableExists($this->fq_name)) {
                        return true;
                    }
            Severity: Minor
            Found in common/BasicModel.php - About 1 hr to fix

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

                  protected function arrayToSQL($definition, $dbms)
                  {
                      $type = $this->getMeta($definition['type'], $dbms);
                      $sql = $type;
              
              
              Severity: Minor
              Found in common/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

              Method normalizeColumnAttributes has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function normalizeColumnAttributes($db_name, $mode=BasicModel::NORMALIZE_MODE_CHECK)
                  {
                      $current = $this->connection->detailedDefinition($this->name);
                      $dbms = $this->connection->dbmsName();
                      $recase_columns = array();
              Severity: Minor
              Found in common/BasicModel.php - About 1 hr to fix

                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 common/BasicModel.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 common/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 updateRecord has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function updateRecord()
                      {
                          $sql = 'UPDATE '.$this->fq_name;
                          $sets = '';
                          $where = '1=1';
                  Severity: Minor
                  Found in common/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

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

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

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

                        public function save()
                        {
                            if (!is_array($this->hooks) || empty($this->hooks)) {
                                $this->loadHooks();
                            }
                    Severity: Minor
                    Found in common/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

                    Method normalizeChangeCase has 35 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 common/BasicModel.php - About 1 hr to fix

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

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

                        Method updateRecord has 33 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 common/BasicModel.php - About 1 hr to fix

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

                              private function normalizeRename($db_name, $mode=BasicModel::NORMALIZE_MODE_CHECK)
                              {
                                  $current = $this->connection->detailedDefinition($this->name);
                                  $dbms = $this->connection->dbmsName();
                                  $recase_columns = array();
                          Severity: Minor
                          Found in common/BasicModel.php - About 1 hr to fix

                            Method save has 28 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 common/BasicModel.php - About 1 hr to fix

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

                                  public function toOptions($selected=0, $id_as_label=false)
                                  {
                                      if (count($this->unique) != 1) {
                                          return '';
                                      }
                              Severity: Minor
                              Found in common/BasicModel.php - About 1 hr to fix

                                Consider simplifying this complex logical expression.
                                Open

                                        if (($argc < 3 || $argc > 4) || ($argc == 3 && $argv[1] != "--new" && $argv[1] != '--new-view') || ($argc == 4 && $argv[1] != '--update')) {
                                            echo "Create new Model: php BasicModel.php --new <Model Name>\n";
                                            echo "Create new View Model: php BasicModel.php --new-view <Model Name>\n";
                                            echo "Update Table Structure: php BasicModel.php --update <Database name> <Subclass Filename>\n";
                                            echo "Generate markdown documentation: php BasicModel.php --doc <Model Filename(s)>\n";
                                Severity: Major
                                Found in common/BasicModel.php - About 1 hr to fix

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

                                      public function columnsDoc()
                                      {
                                          $ret = str_pad('Name', 25, ' ') . '|' . str_pad('Type', 15, ' ') . '|Info' . "\n";
                                          $ret .= str_repeat('-', 25) . '|' . str_repeat('-', 15) . '|' . str_repeat('-', 10) . "\n";
                                          foreach ($this->columns as $name => $info) {
                                  Severity: Minor
                                  Found in common/BasicModel.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 toOptions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function toOptions($selected=0, $id_as_label=false)
                                      {
                                          if (count($this->unique) != 1) {
                                              return '';
                                          }
                                  Severity: Minor
                                  Found in common/BasicModel.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 typesDiffer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      private function typesDiffer($oldtype, $newtype, $dbms)
                                      {
                                          // primarily, compare upper-cased type names as-is
                                          $newtype = strtoupper($newtype);
                                          if ($newtype == $oldtype) {
                                  Severity: Minor
                                  Found in common/BasicModel.php - About 45 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 normalizeReplacePK has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      private function normalizeReplacePK($db_name, $mode=BasicModel::NORMALIZE_MODE_CHECK)
                                      {
                                          $current = $this->connection->detailedDefinition($this->name);
                                          $dbms = $this->connection->dbmsName();
                                          echo ($mode==BasicModel::NORMALIZE_MODE_CHECK)?"Need to set primary key":"Setting primary key";
                                  Severity: Minor
                                  Found in common/BasicModel.php - About 45 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

                                  Consider simplifying this complex logical expression.
                                  Open

                                                  if ($this->typesDiffer($current[$col_name]['type'], $type, $dbms)) {
                                                      printf("%s column %s from %s to %s\n", 
                                                              ($mode==BasicModel::NORMALIZE_MODE_CHECK)?"Need to change":"Changing", 
                                                              $col_name, $current[$col_name]['type'], $type);
                                                      $rebuild = true;
                                  Severity: Major
                                  Found in common/BasicModel.php - About 40 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                    return 1;
                                    Severity: Major
                                    Found in common/BasicModel.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                      return $carry;
                                      Severity: Major
                                      Found in common/BasicModel.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                return 0;
                                        Severity: Major
                                        Found in common/BasicModel.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                      return -1*count($unknown);
                                          Severity: Major
                                          Found in common/BasicModel.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                    return true;
                                            Severity: Major
                                            Found in common/BasicModel.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                                  return true;
                                              Severity: Major
                                              Found in common/BasicModel.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                    return false;
                                                Severity: Major
                                                Found in common/BasicModel.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                                  return $carry . $item . "\n";
                                                  Severity: Major
                                                  Found in common/BasicModel.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                return false;
                                                    Severity: Major
                                                    Found in common/BasicModel.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                  return $alters;
                                                      Severity: Major
                                                      Found in common/BasicModel.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                    return false;
                                                        Severity: Major
                                                        Found in common/BasicModel.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                      return 1;
                                                          Severity: Major
                                                          Found in common/BasicModel.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                    return 0;
                                                            Severity: Major
                                                            Found in common/BasicModel.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                          return false;
                                                              Severity: Major
                                                              Found in common/BasicModel.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                                return $carry . '* [' . $item . '](#' . strtolower($item) . ')' . "\n";
                                                                Severity: Major
                                                                Found in common/BasicModel.php - About 30 mins to fix

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

                                                                      protected function setColumn($col, $val)
                                                                      {
                                                                          if (!isset($this->instance[$col]) || $this->instance[$col] != $val || (is_null($this->instance[$col]) && !is_null($val))) {
                                                                              if (!isset($this->columns[$col]['ignore_updates']) || $this->columns[$col]['ignore_updates'] == false) {
                                                                                  $this->record_changed = true;
                                                                  Severity: Minor
                                                                  Found in common/BasicModel.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