Showing 49 of 49 total issues

File Query.php has 711 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Atk4\Dsql;
Severity: Major
Found in src/Query.php - About 1 day to fix

    Method connectDbalConnection has 219 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected static function connectDbalConnection(array $dsn)
        {
            if (isset($dsn['pdo'])) {
                $pdo = $dsn['pdo'];
            } else {
    Severity: Major
    Found in src/Connection.php - About 1 day to fix

      Query has 53 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Query extends Expression
      {
          /**
           * Query will use one of the predefined templates. The $mode will contain
           * name of template used. Basically it's part of Query property name -
      Severity: Major
      Found in src/Query.php - About 7 hrs to fix

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

                            public function getUpdateExtendedPropertySQL(
                                $name,
                                $value = null,
                                $level0Type = null,
                                $level0Name = null,
        Severity: Major
        Found in src/Connection.php and 1 other location - About 7 hrs to fix
        src/Connection.php on lines 328..350

        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 224.

        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

                            public function getAddExtendedPropertySQL(
                                $name,
                                $value = null,
                                $level0Type = null,
                                $level0Name = null,
        Severity: Major
        Found in src/Connection.php and 1 other location - About 7 hrs to fix
        src/Connection.php on lines 375..397

        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 224.

        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

        File Connection.php has 402 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        declare(strict_types=1);
        
        namespace Atk4\Dsql;
        Severity: Minor
        Found in src/Connection.php - About 5 hrs to fix

          File Expression.php has 393 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          declare(strict_types=1);
          
          namespace Atk4\Dsql;
          Severity: Minor
          Found in src/Expression.php - About 5 hrs to fix

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

                public function execute(object $connection = null): object
                {
                    if ($connection === null) {
                        $connection = $this->connection;
                    }
            Severity: Minor
            Found in src/Expression.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 _sub_render_condition has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function _sub_render_condition(array $row): string
                {
                    if (count($row) === 3) {
                        [$field, $cond, $value] = $row;
                    } elseif (count($row) === 2) {
            Severity: Minor
            Found in src/Query.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 join has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

                public function join(
                    $foreign_table,
                    $master_field = null,
                    $join_kind = null,
                    $_foreign_alias = null
            Severity: Minor
            Found in src/Query.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

            Expression has 25 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Expression implements Expressionable, \ArrayAccess
            {
                /** @const string "[]" in template, escape as parameter */
                protected const ESCAPE_PARAM = 'param';
                /** @const string "{}" in template, escape as identifier */
            Severity: Minor
            Found in src/Expression.php - About 2 hrs to fix

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

                  protected static function connectDbalConnection(array $dsn)
                  {
                      // for some reasons, the following error:
                      // PDOException: SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12516: TNS:listener could not find available handler with matching protocol stack
                      // is shown randomly when a lot of connections are created in tests,
              Severity: Minor
              Found in src/Oracle/Connection.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 execute has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function execute(object $connection = null): object
                  {
                      if ($connection === null) {
                          $connection = $this->connection;
                      }
              Severity: Major
              Found in src/Expression.php - About 2 hrs to fix

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

                    public function render(): string
                    {
                        $hadUnderscoreParamBase = $this->_paramBase !== null;
                        if (!$hadUnderscoreParamBase) {
                            $hadUnderscoreParamBase = false;
                Severity: Major
                Found in src/Expression.php - About 2 hrs to fix

                  Method where has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function where($field, $cond = null, $value = null, $kind = 'where', $num_args = null)
                      {
                          // Number of passed arguments will be used to determine if arguments were specified or not
                          if ($num_args === null) {
                              $num_args = func_num_args();
                  Severity: Major
                  Found in src/Query.php - About 2 hrs to fix

                    Method _sub_render_condition has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function _sub_render_condition(array $row): string
                        {
                            if (count($row) === 3) {
                                [$field, $cond, $value] = $row;
                            } elseif (count($row) === 2) {
                    Severity: Major
                    Found in src/Query.php - About 2 hrs to fix

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

                          public function where($field, $cond = null, $value = null, $kind = 'where', $num_args = null)
                          {
                              // Number of passed arguments will be used to determine if arguments were specified or not
                              if ($num_args === null) {
                                  $num_args = func_num_args();
                      Severity: Minor
                      Found in src/Query.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 join has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function join(
                              $foreign_table,
                              $master_field = null,
                              $join_kind = null,
                              $_foreign_alias = null
                      Severity: Minor
                      Found in src/Query.php - About 1 hr to fix

                        Function _render_case has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function _render_case(): ?string
                            {
                                if (!isset($this->args['case_when'])) {
                                    return null;
                                }
                        Severity: Minor
                        Found in src/Query.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 getDebugQuery has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function getDebugQuery(): string
                            {
                                $result = $this->render();
                        
                                foreach (array_reverse($this->params) as $key => $val) {
                        Severity: Minor
                        Found in src/Expression.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

                        Severity
                        Category
                        Status
                        Source
                        Language