marcelog/PAGI

View on GitHub

Showing 227 of 227 total issues

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

    protected function buildMainMenu(NodeController $nodeController)
    {
        $this->buildGenericNode('mainMenu', $nodeController)
            ->saySound('pp/3')
            ->maxAttemptsForInput(3)
Severity: Minor
Found in doc/examples/nodecontroller/example.php - About 1 hr to fix

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

        public function init()
        {
            $this->logger->info('Init');
            $this->agi = $this->getAgi();
            $this->asteriskLogger = $this->agi->getAsteriskLogger();
    Severity: Minor
    Found in doc/examples/nodecontroller/example.php - About 1 hr to fix

      The class Node has 29 fields. Consider redesigning Node to keep the number of fields under 15.
      Open

      class Node
      {
          /**
           * Any of the available DTMF digits in a classic telephone.
           * @var string
      Severity: Minor
      Found in src/PAGI/Node/Node.php by phpmd

      TooManyFields

      Since: 0.1

      Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

      Example

      class Person {
         protected $one;
         private $two;
         private $three;
         [... many more fields ...]
      }

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

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

          protected function callClientMethods($methods, $stopWhen = null)
          {
              $client = $this->getClient();
              $logger = $client->getLogger();
              $result = null;
      Severity: Minor
      Found in src/PAGI/Node/MockedNode.php - About 1 hr to fix

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

            public function validate()
            {
                foreach ($this->inputValidations as $name => $data) {
                    $validator = $data['callback'];
                    $result = $validator($this);
        Severity: Minor
        Found in src/PAGI/Node/Node.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

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

        $variables = array(
            'request' => 'request.php',
            'channel' => 'SIP/blah-00803890',
            'language' => 'ar',
            'type' => 'SIP',
        Severity: Major
        Found in doc/examples/mock/mocktest.php and 1 other location - About 1 hr to fix
        doc/examples/mock/MyPAGIApplication.php on lines 20..41

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

        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

        $variables = array(
            'request' => 'request.php',
            'channel' => 'SIP/blah-00803890',
            'language' => 'ar',
            'type' => 'SIP',
        Severity: Major
        Found in doc/examples/mock/MyPAGIApplication.php and 1 other location - About 1 hr to fix
        doc/examples/mock/mocktest.php on lines 10..31

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

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

            public function getCommonCallingCardValidations()
            {
                return array(
                    'cardExists' => Node::createValidatorInfo(
                        function(Node $node) {
        Severity: Minor
        Found in doc/examples/nodecontroller/example.php - About 1 hr to fix

          Method spool has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function spool(CallFile $call, $schedule = null)
              {
                  $filename = tempnam($this->tmpDir, 'PAGICallFile');
                  if ($filename === false) {
                      throw new CallSpoolException('Could generate temporary filename');
          Severity: Minor
          Found in src/PAGI/CallSpool/Impl/CallSpoolImpl.php - About 1 hr to fix

            The class AbstractClient has 55 public methods and attributes. Consider reducing the number of public items to less than 45.
            Open

            abstract class AbstractClient implements IClient
            {
                /**
                 * PSR-3 logger.
                 * @var LoggerInterface
            Severity: Minor
            Found in src/PAGI/Client/AbstractClient.php by phpmd

            ExcessivePublicCount

            Since: 0.1

            A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.

            Example

            public class Foo {
                public $value;
                public $something;
                public $var;
                // [... more more public attributes ...]
            
                public function doWork() {}
                public function doMoreWork() {}
                public function doWorkAgain() {}
                // [... more more public methods ...]
            }

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

            The class MockedClientImpl has 60 public methods and attributes. Consider reducing the number of public items to less than 45.
            Open

            class MockedClientImpl extends AbstractClient
            {
                /**
                 * Mocked result strings.
                 * @var string[]

            ExcessivePublicCount

            Since: 0.1

            A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.

            Example

            public class Foo {
                public $value;
                public $something;
                public $var;
                // [... more more public attributes ...]
            
                public function doWork() {}
                public function doMoreWork() {}
                public function doWorkAgain() {}
                // [... more more public methods ...]
            }

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

            The class Node has 48 public methods and attributes. Consider reducing the number of public items to less than 45.
            Open

            class Node
            {
                /**
                 * Any of the available DTMF digits in a classic telephone.
                 * @var string
            Severity: Minor
            Found in src/PAGI/Node/Node.php by phpmd

            ExcessivePublicCount

            Since: 0.1

            A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.

            Example

            public class Foo {
                public $value;
                public $something;
                public $var;
                // [... more more public attributes ...]
            
                public function doWork() {}
                public function doMoreWork() {}
                public function doWorkAgain() {}
                // [... more more public methods ...]
            }

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

            Method processNodeResult has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function processNodeResult(Node $node)
                {
                    $ret = false;
                    $name = $node->getName();
                    if (isset($this->nodeResults[$name])) {
            Severity: Minor
            Found in src/PAGI/Node/NodeController.php - About 1 hr to fix

              Method sayInterruptable has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function sayInterruptable($what, array $arguments)
                  {
                      $client = $this->getClient();
                      $logger = $client->getLogger();
              
              
              Severity: Minor
              Found in src/PAGI/Node/MockedNode.php - About 1 hr to fix

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

                    protected function callClientMethods($methods, $stopWhen = null)
                    {
                        $result = null;
                        foreach ($methods as $callInfo) {
                            foreach ($callInfo as $name => $arguments) {
                Severity: Minor
                Found in src/PAGI/Node/Node.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 buildConfirmTransferToCard has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function buildConfirmTransferToCard(
                        NodeController $nodeController, \Closure $onInit
                    ) {
                        $this->buildGenericNode('confirmTransferToCard', $nodeController)
                            ->cancelWith(Node::DTMF_STAR)
                Severity: Minor
                Found in doc/examples/nodecontroller/example.php - About 1 hr to fix

                  Each class must be in a namespace of at least one level (a top-level vendor name)
                  Open

                  class MyPAGIApplication extends PAGIApplication

                  Each class must be in a namespace of at least one level (a top-level vendor name)
                  Open

                  class MyPagiApplication extends PAGIApplication

                  Each class must be in a namespace of at least one level (a top-level vendor name)
                  Open

                  class MyPagiApplication extends PAGIApplication

                  Each class must be in a namespace of at least one level (a top-level vendor name)
                  Open

                  class Card
                  Severity
                  Category
                  Status
                  Source
                  Language