keboola/php-datatypes

View on GitHub

Showing 97 of 102 total issues

Avoid too many return statements within this method.
Open

            return false;
Severity: Major
Found in src/Definition/Common.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                    return self::TYPE_VARCHAR;
    Severity: Major
    Found in src/Definition/Exasol.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return self::TYPE_NUMBER;
      Severity: Major
      Found in src/Definition/Snowflake.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return !($firstMustBeBigger && isset($parts[1]) && (int) $parts[1] > (int) $parts[0]);
        Severity: Major
        Found in src/Definition/Common.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return self::TYPE_NVARCHAR;
          Severity: Major
          Found in src/Definition/Synapse.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return self::TYPE_DECIMAL;
            Severity: Major
            Found in src/Definition/Exasol.php - About 30 mins to fix

              The method validateNumericLength has a boolean flag argument $firstMustBeBigger, which is a certain sign of a Single Responsibility Principle violation.
              Open

                      bool $firstMustBeBigger = true
              Severity: Minor
              Found in src/Definition/Common.php by phpmd

              BooleanArgumentFlag

              Since: 1.4.0

              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

              Example

              class Foo {
                  public function bar($flag = true) {
                  }
              }

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

              Avoid too many return statements within this method.
              Open

                              return self::TYPE_TIMESTAMP;
              Severity: Major
              Found in src/Definition/Snowflake.php - About 30 mins to fix

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

                    public function getBasetype(): string
                    {
                        $type = strtolower($this->type);
                        $baseType = BaseType::STRING;
                        if (in_array($type, self::DATE_TYPES)) {
                Severity: Minor
                Found in src/Definition/GenericStorage.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

                The method validateLength() has an NPath complexity of 1002. The configured NPath complexity threshold is 200.
                Open

                    private function validateLength(string $type, $length = null): void
                    {
                        $valid = true;
                        switch (strtoupper($type)) {
                            case self::TYPE_NUMBER:
                Severity: Minor
                Found in src/Definition/Snowflake.php by phpmd

                NPathComplexity

                Since: 0.1

                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                Example

                class Foo {
                    function bar() {
                        // lots of complicated code
                    }
                }

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

                Avoid unused parameters such as '$basetype'.
                Open

                    public static function getTypeByBasetype(string $basetype): string
                Severity: Minor
                Found in src/Definition/Teradata.php by phpmd

                UnusedFormalParameter

                Since: 0.2

                Avoid passing parameters to methods or constructors and then not using those parameters.

                Example

                class Foo
                {
                    private function bar($howdy)
                    {
                        // $howdy is not used
                    }
                }

                Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                The method validateLength() has an NPath complexity of 986. The configured NPath complexity threshold is 200.
                Open

                    private function validateLength(string $type, $length = null): void
                    {
                        $valid = true;
                        switch (strtoupper($type)) {
                            case 'DECIMAL':
                Severity: Minor
                Found in src/Definition/Redshift.php by phpmd

                NPathComplexity

                Since: 0.1

                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                Example

                class Foo {
                    function bar() {
                        // lots of complicated code
                    }
                }

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

                The method getSQLDefinition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $length = $this->getDefaultLength();
                            if ($length !== null) {
                                $definition .= sprintf('(%s)', $length);
                            }
                Severity: Minor
                Found in src/Definition/Synapse.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

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

                Avoid unused parameters such as '$basetype'.
                Open

                    public static function getTypeByBasetype(string $basetype): string
                Severity: Minor
                Found in src/Definition/GenericStorage.php by phpmd

                UnusedFormalParameter

                Since: 0.2

                Avoid passing parameters to methods or constructors and then not using those parameters.

                Example

                class Foo
                {
                    private function bar($howdy)
                    {
                        // $howdy is not used
                    }
                }

                Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                The method validateNumericLength() has an NPath complexity of 432. The configured NPath complexity threshold is 200.
                Open

                    protected function validateNumericLength(
                        $length,
                        int $firstMax,
                        int $secondMax,
                        bool $firstMustBeBigger = true
                Severity: Minor
                Found in src/Definition/Common.php by phpmd

                NPathComplexity

                Since: 0.1

                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                Example

                class Foo {
                    function bar() {
                        // lots of complicated code
                    }
                }

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

                Avoid unused parameters such as '$basetype'.
                Open

                    public static function getTypeByBasetype(string $basetype): string
                Severity: Minor
                Found in src/Definition/Redshift.php by phpmd

                UnusedFormalParameter

                Since: 0.2

                Avoid passing parameters to methods or constructors and then not using those parameters.

                Example

                class Foo
                {
                    private function bar($howdy)
                    {
                        // $howdy is not used
                    }
                }

                Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                Avoid using static access to class 'Keboola\Datatype\Definition\BaseType' in method 'getTypeByBasetype'.
                Open

                        if (!BaseType::isValid($basetype)) {
                Severity: Minor
                Found in src/Definition/Snowflake.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

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

                Avoid using static access to class 'Keboola\Datatype\Definition\BaseType' in method 'getTypeByBasetype'.
                Open

                        if (!BaseType::isValid($basetype)) {
                Severity: Minor
                Found in src/Definition/Synapse.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

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

                The method validateLength uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                                } else {
                                    $valid = false;
                                }
                Severity: Minor
                Found in src/Definition/Exasol.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

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

                Avoid unused parameters such as '$basetype'.
                Open

                    public static function getTypeByBasetype(string $basetype): string
                Severity: Minor
                Found in src/Definition/MySQL.php by phpmd

                UnusedFormalParameter

                Since: 0.2

                Avoid passing parameters to methods or constructors and then not using those parameters.

                Example

                class Foo
                {
                    private function bar($howdy)
                    {
                        // $howdy is not used
                    }
                }

                Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                Severity
                Category
                Status
                Source
                Language