jackkum/PHPPDU

View on GitHub

Showing 23 of 23 total issues

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

<?php

/* 
 * Copyright (C) 2014 jackkum
 *
Severity: Major
Found in PDU/Type/Report.php and 1 other location - About 3 hrs to fix
PDU/Type/Deliver.php on lines 1..37

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

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

<?php

/* 
 * Copyright (C) 2014 jackkum
 *
Severity: Major
Found in PDU/Type/Deliver.php and 1 other location - About 3 hrs to fix
PDU/Type/Report.php on lines 1..37

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

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 _prepareParts has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function _prepareParts()
    {
        // 
        $headerSize = self::HEADER_SIZE;
        $max        = Helper::getLimit('normal');
Severity: Major
Found in PDU/Data.php - About 2 hrs to fix

    PDU has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class PDU {
        
        /**
         * Service Centre Address
         * @var PDU\SCA
    Severity: Minor
    Found in PDU.php - About 2 hrs to fix

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

          public function getValue()
          {
              $this->_encodeGroup = 0x00;
              
              // set data encoding, from alphabet and message class
      Severity: Minor
      Found in PDU/DCS.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 parse has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function parse($isAddress = TRUE)
          {
              $SCA     = new self($isAddress);
              $size    = hexdec(PDU::getPduSubstr(2));
              
      Severity: Minor
      Found in PDU/SCA.php - About 1 hr to fix

        Function __toString has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __toString()
            {
                // get pdu type
                $type = $this->getPdu()->getType();
                
        Severity: Minor
        Found in PDU/VP.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 getValue has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getValue()
            {
                $this->_encodeGroup = 0x00;
                
                // set data encoding, from alphabet and message class
        Severity: Minor
        Found in PDU/DCS.php - About 1 hr to fix

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

              public static function parse(Data $data)
              {
                  $alphabet = $data->getPdu()->getDcs()->getTextAlphabet();
                  $header   = NULL;
                  $length   = $data->getPdu()->getUdl() * ($alphabet == PDU\DCS::ALPHABET_UCS2 ? 4 : 2);
          Severity: Minor
          Found in PDU/Data/Part.php - About 1 hr to fix

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

                public static function parse()
                {
                    $DCS  = new self();
                    $byte = hexdec(PDU::getPduSubstr(2));
                    
            Severity: Minor
            Found in PDU/DCS.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 parse has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function parse()
                {
                    $DCS  = new self();
                    $byte = hexdec(PDU::getPduSubstr(2));
                    
            Severity: Minor
            Found in PDU/DCS.php - About 1 hr to fix

              Function _prepareParts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function _prepareParts()
                  {
                      // 
                      $headerSize = self::HEADER_SIZE;
                      $max        = Helper::getLimit('normal');
              Severity: Minor
              Found in PDU/Data.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 parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function parse($isAddress = TRUE)
                  {
                      $SCA     = new self($isAddress);
                      $size    = hexdec(PDU::getPduSubstr(2));
                      
              Severity: Minor
              Found in PDU/SCA.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 parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function parse(Submit $pdu)
                  {
                      $vp = new self($pdu);
                      
                      switch($pdu->getType()->getVpf()){
              Severity: Minor
              Found in PDU/VP.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

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

                  public function getStart()
                  {
                      $PDU  = (string) $this->getSca();
                      $PDU .= (string) $this->getType();
                      $PDU .= (string) $this->getAddress();
              Severity: Minor
              Found in Deliver.php and 1 other location - About 30 mins to fix
              Deliver.php on lines 90..100

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

              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

              Avoid too many return statements within this method.
              Open

                              return sprintf("%02X", ($weeks > 63 ? 63 : $weeks)+192);
              Severity: Major
              Found in PDU/VP.php - About 30 mins to fix

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

                    public function __toString()
                    {
                        $PDU  = (string) $this->getSca();
                        $PDU .= (string) $this->getType();
                        $PDU .= (string) $this->getAddress();
                Severity: Minor
                Found in Deliver.php and 1 other location - About 30 mins to fix
                Deliver.php on lines 102..112

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

                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

                Avoid too many return statements within this method.
                Open

                            case 0x0E: return "c";
                Severity: Major
                Found in PDU/SCA.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              default: return $letter;
                  Severity: Major
                  Found in PDU/SCA.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return "";
                    Severity: Major
                    Found in PDU/VP.php - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language