wol-soft/php-workflow

View on GitHub

Showing 17 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

      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

            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

              Avoid too many return statements within this method.
              Open

                          case WorkflowState::STAGE_AFTER: return 'After';
              Severity: Major
              Found in src/State/ExecutionLog/ExecutionLog.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            case WorkflowState::STAGE_ON_SUCCESS: return 'On Success';
                Severity: Major
                Found in src/State/ExecutionLog/ExecutionLog.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              default: return "{$this->indentation}    - " . $info->getInfo();
                  Severity: Major
                  Found in src/State/ExecutionLog/OutputFormat/StringLog.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                case WorkflowState::STAGE_ON_ERROR: return 'On Error';
                    Severity: Major
                    Found in src/State/ExecutionLog/ExecutionLog.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  case WorkflowState::STAGE_SUMMARY: return 'Summary';
                      Severity: Major
                      Found in src/State/ExecutionLog/ExecutionLog.php - About 30 mins to fix

                        Function executeWorkflow has a Cognitive Complexity of 6 (exceeds 5 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 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