phonetworks/pho-lib-graph

View on GitHub

Showing 12 of 12 total issues

Function on has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    function on(string $eventName, /*mixed*/ $callBack, int $priority = 100) 
    {
        if(!is_callable($callBack)) {
            error_log("callback is not callable");
        }
Severity: Minor
Found in src/Pho/Lib/Graph/Event/EmitterTrait.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

Method on has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function on(string $eventName, /*mixed*/ $callBack, int $priority = 100) 
    {
        if(!is_callable($callBack)) {
            error_log("callback is not callable");
        }
Severity: Minor
Found in src/Pho/Lib/Graph/Event/EmitterTrait.php - About 1 hr to fix

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

        public function add(NodeInterface $node, bool $skip_signals = false, $active_exceptions = false): NodeInterface
        {
            if($this->contains($node->id())) {
                if($active_exceptions)
                    throw new Exceptions\NodeAlreadyMemberException($node, $this);
    Severity: Minor
    Found in src/Pho/Lib/Graph/GraphTrait.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 resolvePredicate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function resolvePredicate(?PredicateInterface $predicate, string $fallback): PredicateInterface
        {
            $is_a_predicate = function(string $class_name): bool
            {
                if(!class_exists($class_name))
    Severity: Minor
    Found in src/Pho/Lib/Graph/Edge.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 add has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function add(NodeInterface $node, bool $skip_signals = false, $active_exceptions = false): NodeInterface
        {
            if($this->contains($node->id())) {
                if($active_exceptions)
                    throw new Exceptions\NodeAlreadyMemberException($node, $this);
    Severity: Minor
    Found in src/Pho/Lib/Graph/GraphTrait.php - About 1 hr to fix

      Method __construct has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __construct(NodeInterface $tail, ?NodeInterface $head = null, ?PredicateInterface $predicate = null) 
          {
              $this->predicate = $this->resolvePredicate($predicate, Predicate::class);
      
              if( !$this->predicate->multiplicable() 
      Severity: Minor
      Found in src/Pho/Lib/Graph/Edge.php - About 1 hr to fix

        Avoid too many return statements within this method.
        Open

                        return new $fallback;
        Severity: Major
        Found in src/Pho/Lib/Graph/Edge.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return new \ArrayIterator(
                          array_map($hydrate, $this->$key[(string) $node_id])
                      );
          Severity: Major
          Found in src/Pho/Lib/Graph/EdgeList.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return new Predicate();
            Severity: Major
            Found in src/Pho/Lib/Graph/Edge.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return new \ArrayIterator(
                          array_map($hydrate, array_filter($this->$key[(string) $node_id], $filter_classes))
                      );
              Severity: Major
              Found in src/Pho/Lib/Graph/EdgeList.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return new \ArrayIterator(
                            array_map($hydrate, 
                                array_filter($this->$d, $filter_classes)
                            )
                        );
                Severity: Major
                Found in src/Pho/Lib/Graph/EdgeList.php - About 30 mins to fix

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

                      public function remove(ID $node_id): void
                      {
                          if($this->contains($node_id)) {
                              unset($this->nodes[(string) $node_id]);
                              unset($this->node_ids[array_search((string)$node_id, $this->node_ids)]);
                  Severity: Minor
                  Found in src/Pho/Lib/Graph/GraphTrait.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

                  Severity
                  Category
                  Status
                  Source
                  Language