RebelCode/rcmod-wp-bookings-ui

View on GitHub

Showing 41 of 41 total issues

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

    protected function _enqueueAssets(ContainerInterface $assetsUrlMap, ContainerInterface $c)
    {
        if (!$this->_isOnAppPage()) {
            return;
        }
Severity: Minor
Found in src/WpBookingsUiModule.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 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

        $statuses,
        $screenOptionsKey,
        $screenOptionsFields,
        $screenOptionsEndpoint,
        $screenOptionsCache,
Severity: Major
Found in src/Handlers/BookingsStateStatusesHandler.php - About 50 mins to fix

    Method __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            $key,
            $dependencies,
            $configFactory,
            $containerFactory,
            $compContainerFactory,
    Severity: Major
    Found in src/WpBookingsUiModule.php - About 50 mins to fix

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

          protected function _getBookingsAppState($c)
      Severity: Minor
      Found in src/WpBookingsUiModule.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 $c. Configured minimum length is 3.
      Open

          protected function _enqueueAssets(ContainerInterface $assetsUrlMap, ContainerInterface $c)
      Severity: Minor
      Found in src/WpBookingsUiModule.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 $id. Configured minimum length is 3.
      Open

          public function has($id)
      Severity: Minor
      Found in src/SettingsContainer.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 $c. Configured minimum length is 3.
      Open

          protected function _renderAboutPage($c)
      Severity: Minor
      Found in src/WpBookingsUiModule.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 $id. Configured minimum length is 3.
      Open

          public function get($id)
      Severity: Minor
      Found in src/SettingsContainer.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 $c. Configured minimum length is 3.
      Open

          protected function _getStaffMembersAppState($c)
      Severity: Minor
      Found in src/WpBookingsUiModule.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 $c. Configured minimum length is 3.
      Open

          protected function _adminMenu($c)
      Severity: Minor
      Found in src/WpBookingsUiModule.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 $c. Configured minimum length is 3.
      Open

          public function run(ContainerInterface $c = null)
      Severity: Minor
      Found in src/WpBookingsUiModule.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 $c. Configured minimum length is 3.
      Open

          protected function _getServicesListAppState($c)
      Severity: Minor
      Found in src/WpBookingsUiModule.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

      Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function __construct($settingsContainer, $fieldsOptions, $fields, $updateEndpoint, $defaultWizardLabels)
      Severity: Minor
      Found in src/Handlers/SettingsStateHandler.php - About 35 mins to fix

        Method _getUiConfig has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            protected function _getUiConfig($currencyConfig, $formatsConfig, $linksConfig, $uiActionsConfig, $validatorsConfig)
        Severity: Minor
        Found in src/Handlers/GeneralUiStateHandler.php - About 35 mins to fix

          Function _iteratorToArrayRecursive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function _iteratorToArrayRecursive($iterator, $transformer = null)
              {
                  $iterator = $this->_normalizeIterable($iterator);
                  $array    = [];
                  foreach ($iterator as $key => $value) {
          Severity: Minor
          Found in src/IteratorToArrayRecursiveCapableTrait.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

          Function _getWebsiteTimezone has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function _getWebsiteTimezone()
              {
                  $currentOffset = get_option('gmt_offset');
                  $tzstring      = get_option('timezone_string');
          
          
          Severity: Minor
          Found in src/Handlers/GeneralUiStateHandler.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

          Function _prepareEndpoints has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function _prepareEndpoints($endpointsConfig)
              {
                  $resultingConfig = [];
          
                  foreach ($endpointsConfig as $namespace => $endpoints) {
          Severity: Minor
          Found in src/WpBookingsUiModule.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

          The method _getWebsiteTimezone uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                      } else {
                          $tzstring = 'UTC+' . $currentOffset;
                      }

          ElseExpression

          Since: 1.4.0

          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($flag) {
                      // one branch
                  } else {
                      // another branch
                  }
              }
          }

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

          Avoid assigning values to variables in if clauses and the like (line '161', column '14').
          Open

              public function __invoke()
              {
                  /* @var $event EventInterface */
                  $event = func_get_arg(0);
          
          

          IfStatementAssignment

          Since: 2.7.0

          Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($foo = 'bar') { // possible typo
                      // ...
                  }
                  if ($baz = 0) { // always false
                      // ...
                  }
              }
          }

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

          The method __construct has 11 parameters. Consider reducing the number of parameters to less than 10.
          Open

              public function __construct(
                  $settingsContainer,
                  $statuses,
                  $statusesLabels,
                  $currencyConfig,
          Severity
          Category
          Status
          Source
          Language