php-vivace/db

View on GitHub

Showing 71 of 71 total issues

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

    public function build($statement): array
    {
        $stack = [];
        $sql = [];
        $values = [];
Severity: Major
Found in src/sql/PostgreSQL/Driver.php - About 4 hrs to fix

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

        public function build($statement): array
        {
            $stack = [];
            $sql = [];
            $values = [];
    Severity: Major
    Found in src/sql/MySQL/Driver.php - About 4 hrs to fix

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

          public function save(array $data): bool
          {
              $columns = [];
              $values = [];
      
      
      Severity: Minor
      Found in src/sql/Storage.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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              if (!isset($value[0])) {
                  $sep = false;
                  $isMulti = count($value) > 1;
                  $isMulti && self::literal($stack, '(');
                  foreach ($value as $key => $val) {
      Severity: Major
      Found in src/sql/MySQL/Driver.php and 1 other location - About 4 hrs to fix
      src/sql/PostgreSQL/Driver.php on lines 117..134

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 165.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              if (!isset($value[0])) {
                  $sep = false;
                  $isMulti = count($value) > 1;
                  $isMulti && self::literal($stack, '(');
                  foreach ($value as $key => $val) {
      Severity: Major
      Found in src/sql/PostgreSQL/Driver.php and 1 other location - About 4 hrs to fix
      src/sql/MySQL/Driver.php on lines 115..132

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 165.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

          protected function normalizeFilter(?array $projection, array $filter): array
          {
              if (!$filter) {
                  return $filter;
              }
      Severity: Minor
      Found in src/sql/Finder.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

      Method schema has 101 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function schema(string $source, bool $refresh = false): Schema
          {
              if (!$refresh && isset($this->schemas[$source])) {
                  return $this->schemas[$source];
              }
      Severity: Major
      Found in src/sql/Driver.php - About 4 hrs to fix

        Function insert has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function insert(array &$stack, Statement\Insert $statement)
            {
                self::literal($stack, 'INSERT INTO ');
                self::identifier($stack, $statement->source);
                self::literal($stack, ' (');
        Severity: Minor
        Found in src/sql/PostgreSQL/Driver.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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            protected static function columns(array &$stack, Statement\Columns $statement)
            {
                if (strpos($statement->sourceName, '.') !== false) {
                    [$schema, $table] = array_map(function ($val) {
                        return "'$val'";
        Severity: Major
        Found in src/sql/PostgreSQL/Driver.php and 1 other location - About 3 hrs to fix
        src/sql/MySQL/Driver.php on lines 313..325

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 157.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            protected static function columns(array &$stack, Statement\Columns $statement)
            {
                if (strpos($statement->sourceName, '.') !== false) {
                    [$db, $table] = array_map(function ($val) {
                        return "\"$val\"";
        Severity: Major
        Found in src/sql/MySQL/Driver.php and 1 other location - About 3 hrs to fix
        src/sql/PostgreSQL/Driver.php on lines 137..150

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 157.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

            protected static function select(array &$stack, Statement\Select $statement)
            {
                self::literal($stack, 'SELECT ');
        
                if (!$statement->projection) {
        Severity: Major
        Found in src/sql/PostgreSQL/Driver.php - About 2 hrs to fix

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

              protected function insert(array &$stack, Statement\Insert $statement)
              {
                  self::literal($stack, 'INSERT INTO ');
                  self::identifier($stack, $statement->source);
                  self::literal($stack, ' (');
          Severity: Minor
          Found in src/sql/MySQL/Driver.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 normalizeFilter has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function normalizeFilter(?array $projection, array $filter): array
              {
                  if (!$filter) {
                      return $filter;
                  }
          Severity: Major
          Found in src/sql/Finder.php - About 2 hrs to fix

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

                protected function update(array &$stack, Statement\Update $statement)
                {
                    self::literal($stack, 'UPDATE ');
                    if ($statement->offset) {
                        self::identifier($stack, $statement->source);
            Severity: Minor
            Found in src/sql/MySQL/Driver.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

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                protected static function join(array &$stack, Statement\Join $statement)
                {
                    switch ($statement->type) {
                        case Statement\Join::LEFT:
                            self::literal($stack, ' LEFT JOIN ');
            Severity: Major
            Found in src/sql/PostgreSQL/Driver.php and 1 other location - About 2 hrs to fix
            src/sql/MySQL/Driver.php on lines 327..343

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 127.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                protected static function join(array &$stack, Statement\Join $statement)
                {
                    switch ($statement->type) {
                        case Statement\Join::LEFT:
                            self::literal($stack, ' LEFT JOIN ');
            Severity: Major
            Found in src/sql/MySQL/Driver.php and 1 other location - About 2 hrs to fix
            src/sql/PostgreSQL/Driver.php on lines 152..168

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 127.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method populate has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function populate(array &$data, string $field)
                {
                    $finder = $this->storage->find();
                    if ($this->filter) {
                        $finder = $finder->filter($this->filter);
            Severity: Major
            Found in src/Relation/Single.php - About 2 hrs to fix

              Method populate has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function populate(array &$data, string $field)
                  {
                      $finder = $this->storage->find();
                      if ($this->filter) {
                          $finder = $finder->filter($this->filter);
              Severity: Major
              Found in src/Relation/Many.php - About 2 hrs to fix

                Method select has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected static function select(array &$stack, Statement\Select $statement)
                    {
                        self::literal($stack, 'SELECT ');
                
                        if (!$statement->projection) {
                Severity: Major
                Found in src/sql/MySQL/Driver.php - About 2 hrs to fix

                  Function delete has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function delete(array &$stack, Statement\Delete $statement)
                      {
                          if ($statement->offset || $statement->order || $statement->limit) {
                  
                  
                  
                  Severity: Minor
                  Found in src/sql/PostgreSQL/Driver.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

                  Severity
                  Category
                  Status
                  Source
                  Language