daemonraco/toobasic-workflows

View on GitHub
includes/Workflow.php

Summary

Maintainability
C
1 day
Test Coverage

Function runFor has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    public function runFor(ItemFlowRepresentation $flow, Item $item) {
        //
        // Default values.
        $continue = true;
        $logParams = array(
Severity: Minor
Found in includes/Workflow.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 runFor has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function runFor(ItemFlowRepresentation $flow, Item $item) {
        //
        // Default values.
        $continue = true;
        $logParams = array(
Severity: Major
Found in includes/Workflow.php - About 3 hrs to fix

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

        protected function load() {
            //
            // Avoiding multipe loads of configurations.
            if($this->_config === false) {
                //
    Severity: Minor
    Found in includes/Workflow.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

    The method runFor() has an NPath complexity of 1184. The configured NPath complexity threshold is 200.
    Open

        public function runFor(ItemFlowRepresentation $flow, Item $item) {
            //
            // Default values.
            $continue = true;
            $logParams = array(
    Severity: Minor
    Found in includes/Workflow.php by phpmd

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

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

    The method runFor() has 139 lines of code. Current threshold is set to 100. Avoid really long methods.
    Open

        public function runFor(ItemFlowRepresentation $flow, Item $item) {
            //
            // Default values.
            $continue = true;
            $logParams = array(
    Severity: Minor
    Found in includes/Workflow.php by phpmd

    Avoid using undefined variables such as '$info' which will lead to PHP notices.
    Open

                    if(!$Defaults[GC_DEFAULTS_INSTALLED] && !self::GetValidator()->validate($jsonString, $info)) {
    Severity: Minor
    Found in includes/Workflow.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$info' which will lead to PHP notices.
    Open

                        $this->_log->log(LGGR_LOG_LEVEL_ERROR, "Workflow '{$this->name()}' specification is not well formed. {$info[JV_FIELD_ERROR][JV_FIELD_MESSAGE]}");
    Severity: Minor
    Found in includes/Workflow.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid unused local variables such as '$Directories'.
    Open

                global $Directories;
    Severity: Minor
    Found in includes/Workflow.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    There are no issues that match your filters.

    Category
    Status