keboola/php-datatypes

View on GitHub

Showing 97 of 102 total issues

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

    public const TYPES_WITH_SIMPLE_LENGTH = [
        self::TYPE_BYTE,
        self::TYPE_VARBYTE,
        self::TYPE_TIME,
        self::TYPE_TIMESTAMP,
Severity: Major
Found in src/Definition/Teradata.php and 1 other location - About 3 hrs to fix
src/Definition/Synapse.php on lines 47..58

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

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

The class Teradata has an overall complexity of 135 which is very high. The configured complexity threshold is 50.
Open

class Teradata extends Common
{
    //https://docs.teradata.com/r/Ri8d7iL59tIPr1FZNKPLMw/DlfSbsVEC48atCIcADa5IA
    /* numbers */
    public const TYPE_BYTEINT = 'BYTEINT'; // -128 to 127, 1B, BYTEINT [ attributes [...] ]
Severity: Minor
Found in src/Definition/Teradata.php by phpmd

The class Redshift has an overall complexity of 114 which is very high. The configured complexity threshold is 50.
Open

class Redshift extends Common
{
    public const TYPES = [
        'SMALLINT', 'INT2', 'INTEGER', 'INT', 'INT4', 'BIGINT', 'INT8',
        'DECIMAL', 'NUMERIC',
Severity: Minor
Found in src/Definition/Redshift.php by phpmd

The class Synapse has an overall complexity of 66 which is very high. The configured complexity threshold is 50.
Open

class Synapse extends Common
{
    public const METADATA_BACKEND = 'synapse';
    public const TYPE_DECIMAL = 'DECIMAL';
    public const TYPE_NUMERIC = 'NUMERIC';
Severity: Minor
Found in src/Definition/Synapse.php by phpmd

The class Exasol has an overall complexity of 92 which is very high. The configured complexity threshold is 50.
Open

class Exasol extends Common
{
    public const METADATA_BACKEND = 'exasol';
    /* core types */
    public const TYPE_DECIMAL = 'DECIMAL'; // DECIMAL(p,s) = s ≤ p ≤ 36
Severity: Minor
Found in src/Definition/Exasol.php by phpmd

Method validateLength has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function validateLength(string $type, $length = null): void
    {
        $valid = true;

        switch (strtoupper($type)) {
Severity: Major
Found in src/Definition/Teradata.php - About 3 hrs to fix

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

        private function validateLength(string $type, $length = null): void
        {
            $valid = true;
            switch (strtoupper($type)) {
                case self::TYPE_FLOAT:
    Severity: Minor
    Found in src/Definition/Synapse.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 validateCompression has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        private function validateCompression(string $type, string $compression): void
        {
            $valid = true;
            $type = strtoupper($type);
            switch (strtoupper($compression)) {
    Severity: Minor
    Found in src/Definition/Redshift.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 validateLength has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function validateLength(string $type, $length = null): void
        {
            $valid = true;
    
            switch (strtoupper($type)) {
    Severity: Major
    Found in src/Definition/Exasol.php - About 2 hrs to fix

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

          private function getDefaultLength()
          {
              $out = null;
              switch ($this->type) {
                  // decimals
      Severity: Major
      Found in src/Definition/Teradata.php - About 2 hrs to fix

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

            private function validateLength(string $type, $length = null): void
            {
                $valid = true;
        
                switch (strtoupper($type)) {
        Severity: Minor
        Found in src/Definition/Exasol.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

        File MySQL.php has 257 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        declare(strict_types=1);
        
        namespace Keboola\Datatype\Definition;
        Severity: Minor
        Found in src/Definition/MySQL.php - About 2 hrs to fix

          Method validateLength has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function validateLength(string $type, $length = null): void
              {
                  $valid = true;
                  switch (strtoupper($type)) {
                      case self::TYPE_FLOAT:
          Severity: Minor
          Found in src/Definition/Synapse.php - About 2 hrs to fix

            Method getBasetype has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getBasetype(): string
                {
                    switch (strtoupper($this->type)) {
                        case self::TYPE_INT:
                        case self::TYPE_INTEGER:
            Severity: Minor
            Found in src/Definition/Snowflake.php - About 1 hr to fix

              Method getBasetype has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getBasetype(): string
                  {
                      switch (strtoupper($this->type)) {
                          case 'SMALLINT':
                          case 'INT2':
              Severity: Minor
              Found in src/Definition/Redshift.php - About 1 hr to fix

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

                    public function getBasetype(): string
                    {
                        switch (strtoupper($this->type)) {
                            case self::TYPE_DECIMAL:
                            case self::TYPE_DEC:
                Severity: Minor
                Found in src/Definition/Exasol.php - About 1 hr to fix

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

                      private function getDefaultLength()
                      {
                          $out = null;
                          switch (strtoupper($this->type)) {
                              case self::TYPE_DECIMAL:
                  Severity: Minor
                  Found in src/Definition/Exasol.php - About 1 hr to fix

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

                        public function getBasetype(): string
                        {
                            switch (strtoupper($this->type)) {
                                case self::TYPE_BYTEINT:
                                case self::TYPE_INTEGER:
                    Severity: Minor
                    Found in src/Definition/Teradata.php - About 1 hr to fix

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

                          public function getBasetype(): string
                          {
                              switch (strtoupper($this->type)) {
                                  case self::TYPE_INT:
                                  case self::TYPE_BIGINT:
                      Severity: Minor
                      Found in src/Definition/Synapse.php - About 1 hr to fix

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

                            public function getBasetype(): string
                            {
                                switch (strtoupper($this->type)) {
                                    case 'INT':
                                    case 'INTEGER':
                        Severity: Minor
                        Found in src/Definition/MySQL.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language