Dopamedia/StateMachine

View on GitHub

Showing 69 of 69 total issues

Method install has 151 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;
        $installer->startSetup();

Severity: Major
Found in Setup/InstallSchema.php - About 6 hrs to fix

    The class Drawer has an overall complexity of 54 which is very high. The configured complexity threshold is 50.
    Open

    class Drawer implements DrawerInterface
    {
        const ATTRIBUTE_FONT_SIZE = 'fontsize';
    
        const EDGE_UPPER_HALF = 'upper half';
    Severity: Minor
    Found in Model/Graph/Drawer.php by phpmd

    The class State has an overall complexity of 50 which is very high. The configured complexity threshold is 50.
    Open

    class State implements ProcessStateInterface
    {
        /**
         * @var string
         */
    Severity: Minor
    Found in Model/Process/State.php by phpmd

    State has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class State implements ProcessStateInterface
    {
        /**
         * @var string
         */
    Severity: Minor
    Found in Model/Process/State.php - About 2 hrs to fix

      File Drawer.php has 272 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * Created by PhpStorm.
       * User: pandi
       * Date: 25.07.16
      Severity: Minor
      Found in Model/Graph/Drawer.php - About 2 hrs to fix

        Process has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Process implements ProcessProcessInterface
        {
            /**
             * @var string
             */
        Severity: Minor
        Found in Model/Process/Process.php - About 2 hrs to fix

          Function gatherEvents has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function gatherEvents(\DOMElement $parentNode)
              {
                  $events = [];
                  foreach ($this->getChildrenByName($parentNode, 'events') as $eventsNode) {
                      foreach ($this->getAllChildElements($eventsNode) as $eventNode) {
          Severity: Minor
          Found in Model/Configuration/Converter.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

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

                  $manuallyExecutableEventList = [];
          Severity: Minor
          Found in Model/Process/Process.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

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

                  $hasOnlySelfReferences = true;
          Severity: Minor
          Found in Model/Graph/Drawer.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

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

                  if ($transitionsConfiguration = $this->configuration->getTransitions($processName)) {
          Severity: Minor
          Found in Model/StateMachine/Builder.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 addEdgeEventText has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function addEdgeEventText(ProcessTransitionInterface $transition, array $label)
              {
                  if ($transition->hasEvent()) {
                      $event = $transition->getEvent();
          
          
          Severity: Minor
          Found in Model/Graph/Drawer.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

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

                  return $processes;
          Severity: Minor
          Found in Model/Process/Process.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 '$processes' which will lead to PHP notices.
          Open

                  $processes[] = $this;
          Severity: Minor
          Found in Model/Process/Process.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

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                  $table = $installer->getConnection()->newTable(
                      $installer->getTable('state_machine_item_state')
                  )->addColumn(
                      'item_state_id',
                      \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
          Severity: Major
          Found in Setup/InstallSchema.php and 2 other locations - About 55 mins to fix
          Setup/InstallSchema.php on lines 114..134
          Setup/InstallSchema.php on lines 161..181

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

          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 3 locations. Consider refactoring.
          Open

                  $table = $installer->getConnection()->newTable(
                      $installer->getTable('state_machine_item_state_history')
                  )->addColumn(
                      'item_state_history_id',
                      \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
          Severity: Major
          Found in Setup/InstallSchema.php and 2 other locations - About 55 mins to fix
          Setup/InstallSchema.php on lines 71..91
          Setup/InstallSchema.php on lines 161..181

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

          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 3 locations. Consider refactoring.
          Open

                  $table = $installer->getConnection()->newTable(
                      $installer->getTable('state_machine_transition_log')
                  )->addColumn(
                      'transition_log_id',
                      \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
          Severity: Major
          Found in Setup/InstallSchema.php and 2 other locations - About 55 mins to fix
          Setup/InstallSchema.php on lines 71..91
          Setup/InstallSchema.php on lines 114..134

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

          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

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

              protected function addEdgeAttributes(ProcessTransitionInterface $transition, array $attributes, $label, $type = self::EDGE_FULL)
              {
                  $attributes = array_merge($this->attributesTransition, $attributes);
                  $attributes['label'] = '  ' . $label;
          
          
          Severity: Minor
          Found in Model/Graph/Drawer.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 drawTransitionsEvents has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public function drawTransitionsEvents(ProcessStateInterface $state)
              {
                  $events = $state->getEvents();
                  foreach ($events as $event) {
                      $transitions = $state->getOutgoingTransitionsByEvent($event);
          Severity: Minor
          Found in Model/Graph/Drawer.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 gatherTransitions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function gatherTransitions(\DOMElement $parentNode)
              {
                  $transitions = [];
                  foreach ($this->getChildrenByName($parentNode, 'transitions') as $transitionsNode) {
                      foreach ($this->getAllChildElements($transitionsNode) as $transitionNode) {
          Severity: Minor
          Found in Model/Configuration/Converter.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 $id. Configured minimum length is 3.
          Open

              public function hasEvent($id)
          Severity: Minor
          Found in Model/Process/State.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

          Severity
          Category
          Status
          Source
          Language