wol-soft/php-workflow

View on GitHub

Showing 116 of 116 total issues

Function run has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function run(WorkflowControl $control, WorkflowContainer $container): void
    {
        $iteration = 0;

        WorkflowState::getRunningWorkflow()->setInLoop(true);
Severity: Minor
Found in src/Step/Loop.php - About 3 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 renderWorkflowGraph has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function renderWorkflowGraph(string $workflowName, array $steps): string
    {
        $dotScript = sprintf("  %s [label=\"$workflowName\"]\n", self::$stepIndex++);
        foreach ($steps as $stage => $stageSteps) {
            $dotScript .= sprintf(
Severity: Major
Found in src/State/ExecutionLog/OutputFormat/GraphViz.php - About 2 hrs to fix

    Method run has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function run(WorkflowControl $control, WorkflowContainer $container): void
        {
            $iteration = 0;
    
            WorkflowState::getRunningWorkflow()->setInLoop(true);
    Severity: Minor
    Found in src/Step/Loop.php - About 1 hr to fix

      Avoid excessively long variable names like $workflowReportWarning. Keep variable name length under 20.
      Open

          public function addWarning(string $message, bool $workflowReportWarning = false): void

      LongVariable

      Since: 0.2

      Detects when a field, formal or local variable is declared with a long name.

      Example

      class Something {
          protected $reallyLongIntName = -3; // VIOLATION - Field
          public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
              $otherReallyLongName = -5; // VIOLATION - Local
              for ($interestingIntIndex = 0; // VIOLATION - For
                   $interestingIntIndex < 10;
                   $interestingIntIndex++ ) {
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#longvariable

      Avoid excessively long class names like WorkflowStepDependencyNotFulfilledException. Keep class name length under 40.
      Open

      class WorkflowStepDependencyNotFulfilledException extends Exception
      {
      }

      LongClassName

      Since: 2.9

      Detects when classes or interfaces are declared with excessively long names.

      Example

      class ATooLongClassNameThatHintsAtADesignProblem {
      
      }
      
      interface ATooLongInterfaceNameThatHintsAtADesignProblem {
      
      }

      Source https://phpmd.org/rules/naming.html#longclassname

      Function wrapStepExecution has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function wrapStepExecution(WorkflowStep $step, WorkflowState $workflowState): void {
              try {
                  ($this->resolveMiddleware($step, $workflowState))();
              } catch (SkipStepException | FailStepException $exception) {
                  $workflowState->addExecutionLog(
      Severity: Minor
      Found in src/Step/StepExecutionTrait.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 executeWorkflow has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function executeWorkflow(
              WorkflowContainer $workflowContainer = null,
              bool $throwOnFailure = true
          ): WorkflowResult {
              if (!$workflowContainer) {
      Severity: Minor
      Found in src/Stage/Next/AllowNextExecuteWorkflow.php - About 1 hr to fix

        Method wrapStepExecution has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function wrapStepExecution(WorkflowStep $step, WorkflowState $workflowState): void {
                try {
                    ($this->resolveMiddleware($step, $workflowState))();
                } catch (SkipStepException | FailStepException $exception) {
                    $workflowState->addExecutionLog(
        Severity: Minor
        Found in src/Step/StepExecutionTrait.php - About 1 hr to fix

          Function renderWorkflowGraph has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private function renderWorkflowGraph(string $workflowName, array $steps): string
              {
                  $dotScript = sprintf("  %s [label=\"$workflowName\"]\n", self::$stepIndex++);
                  foreach ($steps as $stage => $stageSteps) {
                      $dotScript .= sprintf(
          Severity: Minor
          Found in src/State/ExecutionLog/OutputFormat/GraphViz.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 runStage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function runStage(WorkflowState $workflowState): ?Stage
              {
                  $workflowState->setStage(WorkflowState::STAGE_VALIDATE);
          
                  // make sure hard validators are executed first
          Severity: Minor
          Found in src/Stage/Validate.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 runStage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function runStage(WorkflowState $workflowState): ?Stage
              {
                  $workflowState->setStage(WorkflowState::STAGE_VALIDATE);
          
                  // make sure hard validators are executed first
          Severity: Minor
          Found in src/Stage/Validate.php - About 1 hr to fix

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

                public function check(WorkflowContainer $container): void
                {
                    if (!$container->has($this->key)) {
                        throw new WorkflowStepDependencyNotFulfilledException("Missing '$this->key' in container");
                    }
            Severity: Minor
            Found in src/Step/Dependency/Requires.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

            The class Loop has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
            Open

            class Loop implements WorkflowStep
            {
                use StepExecutionTrait;
            
                protected array $steps = [];
            Severity: Minor
            Found in src/Step/Loop.php by phpmd

            CouplingBetweenObjects

            Since: 1.1.0

            A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

            Example

            class Foo {
                /**
                 * @var \foo\bar\X
                 */
                private $x = null;
            
                /**
                 * @var \foo\bar\Y
                 */
                private $y = null;
            
                /**
                 * @var \foo\bar\Z
                 */
                private $z = null;
            
                public function setFoo(\Foo $foo) {}
                public function setBar(\Bar $bar) {}
                public function setBaz(\Baz $baz) {}
            
                /**
                 * @return \SplObjectStorage
                 * @throws \OutOfRangeException
                 * @throws \InvalidArgumentException
                 * @throws \ErrorException
                 */
                public function process(\Iterator $it) {}
            
                // ...
            }

            Source https://phpmd.org/rules/design.html#couplingbetweenobjects

            Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function __construct(Describable $step, string $state, ?string $reason, array $stepInfo, int $warnings)
            Severity: Minor
            Found in src/State/ExecutionLog/Step.php - About 35 mins to fix

              The CASE body must start on the line following the statement
              Open

                          case WorkflowState::STAGE_SUMMARY: return 'Summary';

              The CASE body must start on the line following the statement
              Open

                          case WorkflowState::STAGE_AFTER: return 'After';

              The CASE body must start on the line following the statement
              Open

                          case WorkflowState::STAGE_ON_SUCCESS: return 'On Success';

              Space found before closing bracket of FOREACH loop
              Open

                          foreach ($containerParameter->getAttributes(

              Terminating statement must be on a line by itself
              Open

                          case WorkflowState::STAGE_PROCESS: return 'Process';

              The DEFAULT body must start on the line following the statement
              Open

                          default: return "{$this->indentation}    - " . $info->getInfo();
              Severity
              Category
              Status
              Source
              Language