fab2s/NodalFlow

View on GitHub

Showing 11 of 11 total issues

Function recurse has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    protected function recurse($param = null, int $nodeIdx = 0)
    {
        while ($nodeIdx <= $this->lastIdx) {
            $node          = $this->nodes[$nodeIdx];
            $this->nodeIdx = $nodeIdx;
Severity: Minor
Found in src/NodalFlow.php - About 5 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 getStats has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function getStats(): array
    {
        $this->resetTotals();
        foreach ($this->flow->getNodes() as $node) {
            $nodeMap = $this->nodeMap[$node->getId()];
Severity: Minor
Found in src/Flows/FlowMap.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 recurse has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function recurse($param = null, int $nodeIdx = 0)
    {
        while ($nodeIdx <= $this->lastIdx) {
            $node          = $this->nodes[$nodeIdx];
            $this->nodeIdx = $nodeIdx;
Severity: Minor
Found in src/NodalFlow.php - About 1 hr to fix

    Function getTraversable has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getTraversable($param = null): iterable
        {
            $value = null;
            /** @var $nodes TraversableNodeInterface[] */
            $nodes = $this->payload->getNodes();
    Severity: Minor
    Found in src/Nodes/AggregateNode.php - About 55 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

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

        public function registerFlow(FlowInterface $flow): FlowRegistryInterface
        {
            $flowId = $flow->getId();
            if (isset(static::$flows[$flowId])) {
                throw new NodalFlowException('Duplicate Flow instances are not allowed', 1, null, [
    Severity: Minor
    Found in src/Flows/FlowRegistry.php and 1 other location - About 45 mins to fix
    src/Flows/FlowRegistry.php on lines 99..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 95.

    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

        public function registerNode(NodeInterface $node): FlowRegistryInterface
        {
            $nodeId = $node->getId();
            if (isset(static::$nodes[$nodeId])) {
                throw new NodalFlowException('Duplicate Node instances are not allowed', 1, null, [
    Severity: Minor
    Found in src/Flows/FlowRegistry.php and 1 other location - About 45 mins to fix
    src/Flows/FlowRegistry.php on lines 77..90

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

    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

    Function enforceIsATraversable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function enforceIsATraversable(): self
        {
            if ($this->isFlow()) {
                if ($this->isATraversable) {
                    throw new NodalFlowException('Cannot Traverse a Branch');
    Severity: Minor
    Found in src/Nodes/NodeAbstract.php - About 35 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

    Function listActiveEvent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function listActiveEvent(bool $reload = false): self
        {
            if (!isset($this->dispatcher) || (isset($this->activeEvents) && !$reload)) {
                return $this;
            }
    Severity: Minor
    Found in src/Flows/FlowEventAbstract.php - About 35 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

    Function setFlowIncrement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function setFlowIncrement(array $flowIncrements): self
        {
            foreach ($flowIncrements as $incrementKey => $target) {
                if (is_string($target)) {
                    if (!isset($this->flowStats[$target])) {
    Severity: Minor
    Found in src/Flows/FlowMap.php - About 35 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

    Function setNodeIncrement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function setNodeIncrement(NodeInterface $node): self
        {
            $nodeId = $node->getId();
            foreach ($node->getNodeIncrements() as $incrementKey => $target) {
                if (is_string($target)) {
    Severity: Minor
    Found in src/Flows/FlowMap.php - About 35 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

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

        public function resetNodeStats(): FlowMapInterface
        {
            foreach ($this->nodeMap as &$nodeStat) {
                foreach ($this->nodeIncrements as $key => $value) {
                    if (isset($nodeStat[$key])) {
    Severity: Minor
    Found in src/Flows/FlowMap.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