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);
- Read upRead up
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(
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);
Avoid excessively long variable names like $workflowReportWarning. Keep variable name length under 20. Open
public function addWarning(string $message, bool $workflowReportWarning = false): void
- Read upRead up
- Exclude checks
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
{
}
- Read upRead up
- Exclude checks
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(
- Read upRead up
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) {
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(
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(
- Read upRead up
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
- Read upRead up
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
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");
}
- Read upRead up
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 = [];
- Read upRead up
- Exclude checks
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)
The CASE body must start on the line following the statement Open
case WorkflowState::STAGE_SUMMARY: return 'Summary';
- Exclude checks
The CASE body must start on the line following the statement Open
case WorkflowState::STAGE_AFTER: return 'After';
- Exclude checks
The CASE body must start on the line following the statement Open
case WorkflowState::STAGE_ON_SUCCESS: return 'On Success';
- Exclude checks
Space found before closing bracket of FOREACH loop Open
foreach ($containerParameter->getAttributes(
- Exclude checks
Terminating statement must be on a line by itself Open
case WorkflowState::STAGE_PROCESS: return 'Process';
- Exclude checks
The DEFAULT body must start on the line following the statement Open
default: return "{$this->indentation} - " . $info->getInfo();
- Exclude checks