shrink0r/workflux

View on GitHub

Showing 32 of 32 total issues

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

    private function realizeConfig(array $config): array
    {
        $states = [];
        $transitions = [];
        foreach ($config as $name => $state_config) {
Severity: Major
Found in src/Builder/YamlStateMachineBuilder.php and 1 other location - About 2 hrs to fix
src/Builder/ArrayStateMachineBuilder.php on lines 59..76

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

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

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

    private function realizeConfig(array $config): array
    {
        $states = [];
        $transitions = [];
        foreach ($config as $name => $state_config) {
Severity: Major
Found in src/Builder/ArrayStateMachineBuilder.php and 1 other location - About 2 hrs to fix
src/Builder/YamlStateMachineBuilder.php on lines 69..86

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

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

<?php

namespace Workflux\Error;

use DomainException;
Severity: Major
Found in src/Error/InvalidOutput.php and 1 other location - About 2 hrs to fix
src/Error/InvalidInput.php on lines 1..44

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

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

<?php

namespace Workflux\Error;

use DomainException;
Severity: Major
Found in src/Error/InvalidInput.php and 1 other location - About 2 hrs to fix
src/Error/InvalidOutput.php on lines 1..44

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

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

Method getStateSchema has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getStateSchema(): array
    {
        return [
            "type" => "assoc" ,
            "required" => false,
Severity: Major
Found in src/Builder/StateMachineSchema.php - About 2 hrs to fix

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

        private static $default_validation_schema = [ ':any_name:' => [ 'type' => 'any' ] ];
    Severity: Minor
    Found in src/Builder/Factory.php by phpmd

    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

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

        public function splat(): array
        {
            $initial_state = null;
            $all_states = new StateMap;
            $final_states = new StateMap;
    Severity: Minor
    Found in src/State/StateSet.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 __construct has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __construct(StateMap $states, TransitionSet $transitions)
        {
            $this->internal_map = new Map;
            foreach ($transitions as $transition) {
                $from_state = $transition->getFrom();
    Severity: Minor
    Found in src/Transition/StateTransitions.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 __construct has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __construct(StateMap $states, TransitionSet $transitions)
        {
            $this->internal_map = new Map;
            foreach ($transitions as $transition) {
                $from_state = $transition->getFrom();
    Severity: Minor
    Found in src/Transition/StateTransitions.php - About 1 hr to fix

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

          private function realizeConfig(array $config): array
          {
              $states = [];
              $transitions = [];
              foreach ($config as $name => $state_config) {
      Severity: Minor
      Found in src/Builder/ArrayStateMachineBuilder.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

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

          private function realizeConfig(array $config): array
          {
              $states = [];
              $transitions = [];
              foreach ($config as $name => $state_config) {
      Severity: Minor
      Found in src/Builder/YamlStateMachineBuilder.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

      Avoid variables with short names like $to. Configured minimum length is 3.
      Open

          public function createTransition(string $from, string $to, array $config = null): TransitionInterface
      Severity: Minor
      Found in src/Builder/Factory.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

      Avoid variables with short names like $to. Configured minimum length is 3.
      Open

              string $to,
      Severity: Minor
      Found in src/Transition/Transition.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

      Avoid variables with short names like $to. Configured minimum length is 3.
      Open

          public function createTransition(string $from, string $to, array $config = null): TransitionInterface;
      Severity: Minor
      Found in src/Builder/FactoryInterface.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

      Avoid variables with short names like $to. Configured minimum length is 3.
      Open

          private $to;
      Severity: Minor
      Found in src/Transition/Transition.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

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

      final class Factory implements FactoryInterface
      {
          const SUFFIX_IN = '-input_schema';
      
          const SUFFIX_OUT = '-output_schema';
      Severity: Minor
      Found in src/Builder/Factory.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

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

          private function activateTransition(InputInterface $input, OutputInterface $output)
          {
              $next_state = null;
              foreach ($this->state_transitions->get($output->getCurrentState()) as $transition) {
                  if ($transition->isActivatedBy($input, $output)) {
      Severity: Minor
      Found in src/StateMachine.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 withParam has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function withParam(string $param_name, $param_value, bool $treat_name_as_path = true): ParamHolderInterface
          {
              $param_holder = clone $this;
              if ($treat_name_as_path) {
                  $name_parts = array_reverse(explode('.', $param_name));
      Severity: Minor
      Found in src/Param/ParamHolderTrait.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

      The method withParam has a boolean flag argument $treat_name_as_path, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public function withParam(string $param_name, $param_value, bool $treat_name_as_path = true): self;
      Severity: Minor
      Found in src/Param/ParamHolderInterface.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

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

      The method withParam has a boolean flag argument $treat_name_as_path, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public function withParam(string $param_name, $param_value, bool $treat_name_as_path = true): ParamHolderInterface
      Severity: Minor
      Found in src/Param/ParamHolderTrait.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

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

      Severity
      Category
      Status
      Source
      Language