YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/crons/Magento.php

Summary

Maintainability
B
6 hrs
Test Coverage
F
0%

Function process has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public function process()
    {
        foreach (App\Integrations\Magento\Config::getAllServers() as $serverId => $config) {
            if (0 === (int) $config['status']) {
                continue;
Severity: Minor
Found in modules/Vtiger/crons/Magento.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 process has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process()
    {
        foreach (App\Integrations\Magento\Config::getAllServers() as $serverId => $config) {
            if (0 === (int) $config['status']) {
                continue;
Severity: Minor
Found in modules/Vtiger/crons/Magento.php - About 1 hr to fix

    Avoid too many return statements within this method.
    Open

                    return;
    Severity: Major
    Found in modules/Vtiger/crons/Magento.php - About 30 mins to fix

      The method process() has an NPath complexity of 4097. The configured NPath complexity threshold is 200.
      Open

          public function process()
          {
              foreach (App\Integrations\Magento\Config::getAllServers() as $serverId => $config) {
                  if (0 === (int) $config['status']) {
                      continue;
      Severity: Minor
      Found in modules/Vtiger/crons/Magento.php by phpmd

      NPathComplexity

      Since: 0.1

      The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

      Example

      class Foo {
          function bar() {
              // lots of complicated code
          }
      }

      Source https://phpmd.org/rules/codesize.html#npathcomplexity

      The method process() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
      Open

          public function process()
          {
              foreach (App\Integrations\Magento\Config::getAllServers() as $serverId => $config) {
                  if (0 === (int) $config['status']) {
                      continue;
      Severity: Minor
      Found in modules/Vtiger/crons/Magento.php by phpmd

      CyclomaticComplexity

      Since: 0.1

      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

      Example

      // Cyclomatic Complexity = 11
      class Foo {
      1   public function example() {
      2       if ($a == $b) {
      3           if ($a1 == $b1) {
                      fiddle();
      4           } elseif ($a2 == $b2) {
                      fiddle();
                  } else {
                      fiddle();
                  }
      5       } elseif ($c == $d) {
      6           while ($c == $d) {
                      fiddle();
                  }
      7        } elseif ($e == $f) {
      8           for ($n = 0; $n < $h; $n++) {
                      fiddle();
                  }
              } else {
                  switch ($z) {
      9               case 1:
                          fiddle();
                          break;
      10              case 2:
                          fiddle();
                          break;
      11              case 3:
                          fiddle();
                          break;
                      default:
                          fiddle();
                          break;
                  }
              }
          }
      }

      Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

      Refactor this function to reduce its Cognitive Complexity from 25 to the 15 allowed.
      Open

          public function process()
      Severity: Critical
      Found in modules/Vtiger/crons/Magento.php by sonar-php

      Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

      See

      Reduce the number of returns of this function 5, down to the maximum allowed 3.
      Open

          public function process()
      Severity: Major
      Found in modules/Vtiger/crons/Magento.php by sonar-php

      Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

      Noncompliant Code Example

      With the default threshold of 3:

      function myFunction(){ // Noncompliant as there are 4 return statements
        if (condition1) {
          return true;
        } else {
          if (condition2) {
            return false;
          } else {
            return true;
          }
        }
        return false;
      }
      

      Missing class import via use statement (line '25', column '22').
      Open

                  $connector = (new App\Integrations\Magento\Controller($serverId));
      Severity: Minor
      Found in modules/Vtiger/crons/Magento.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Avoid using static access to class 'App\Integrations\Magento\Config' in method 'process'.
      Open

              foreach (App\Integrations\Magento\Config::getAllServers() as $serverId => $config) {
      Severity: Minor
      Found in modules/Vtiger/crons/Magento.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Each class must be in a namespace of at least one level (a top-level vendor name)
      Open

      class Vtiger_Magento_Cron extends \App\CronHandler

      The class Vtiger_Magento_Cron is not named in CamelCase.
      Open

      class Vtiger_Magento_Cron extends \App\CronHandler
      {
          /** {@inheritdoc} */
          public function process()
          {
      Severity: Minor
      Found in modules/Vtiger/crons/Magento.php by phpmd

      CamelCaseClassName

      Since: 0.2

      It is considered best practice to use the CamelCase notation to name classes.

      Example

      class class_name {
      }

      Source

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      return;

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $connector->synchronizeCurrencies();

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if ($connector->config->get('sync_orders')) {

      Spaces must be used to indent lines; tabs are not allowed
      Open

          /** {@inheritdoc} */

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $this->updateLastActionTime();

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $this->updateLastActionTime();

      Spaces must be used to indent lines; tabs are not allowed
      Open

          public function process()

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if ($this->checkTimeout()) {

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $connector->synchronizeCategories();

      Spaces must be used to indent lines; tabs are not allowed
      Open

              foreach (App\Integrations\Magento\Config::getAllServers() as $serverId => $config) {

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if ($this->checkTimeout()) {

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      continue;

      Spaces must be used to indent lines; tabs are not allowed
      Open

          {

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if ($connector->config->get('sync_currency')) {

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $connector->synchronizeCustomers();

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $this->updateLastActionTime();

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if ($connector->config->get('sync_categories')) {

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if ($connector->config->get('sync_customers')) {

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if (0 === (int) $config['status']) {

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if ($connector->config->get('sync_products')) {

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $connector->synchronizeProducts();

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }

      Spaces must be used to indent lines; tabs are not allowed
      Open

          }

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      return;

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $this->updateLastActionTime();

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $this->updateLastActionTime();

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      return;

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $connector->synchronizeInvoices();

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if ($this->checkTimeout()) {

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      return;

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if ($this->checkTimeout()) {

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $this->updateLastActionTime();

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  $connector = (new App\Integrations\Magento\Controller($serverId));

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if ($connector->config->get('sync_invoices')) {

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      return;

      Spaces must be used to indent lines; tabs are not allowed
      Open

              }

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  }

      Spaces must be used to indent lines; tabs are not allowed
      Open

                      $connector->synchronizeOrders();

      Spaces must be used to indent lines; tabs are not allowed
      Open

                  if ($this->checkTimeout()) {

      Class name "Vtiger_Magento_Cron" is not in camel caps format
      Open

      class Vtiger_Magento_Cron extends \App\CronHandler

      There are no issues that match your filters.

      Category
      Status