luyadev/luya-module-admin

View on GitHub
src/ngrest/Config.php

Summary

Maintainability
D
2 days
Test Coverage
A
94%

Config has 45 functions (exceeds 20 allowed). Consider refactoring.
Open

class Config extends BaseObject implements ConfigInterface
{
    private $_model;

    /**
Severity: Minor
Found in src/ngrest/Config.php - About 6 hrs to fix

    File Config.php has 363 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace luya\admin\ngrest;
    
    use luya\admin\Module;
    Severity: Minor
    Found in src/ngrest/Config.php - About 4 hrs to fix

      Function getExtraFields has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getExtraFields()
          {
              if ($this->_extraFields === null) {
                  $extraFields = [];
                  foreach ($this->getConfig() as $pointer => $fields) {
      Severity: Minor
      Found in src/ngrest/Config.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

      Function getPlugins has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getPlugins()
          {
              if ($this->_plugins === null) {
                  $plugins = [];
                  foreach ($this->getConfig() as $pointer => $fields) {
      Severity: Minor
      Found in src/ngrest/Config.php - About 2 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

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

          public function appendFieldOption($fieldName, $optionKey, $optionValue)
          {
              foreach ($this->getConfig() as $pointer => $fields) {
                  if (is_array($fields)) {
                      foreach ($fields as $field) {
      Severity: Minor
      Found in src/ngrest/Config.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 onFinish has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function onFinish()
          {
              foreach ($this->getPrimaryKey() as $pk) {
                  if (!$this->hasField('list', $pk)) {
                      $alias = $pk;
      Severity: Minor
      Found in src/ngrest/Config.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 getRelations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getRelations()
          {
              if ($this->_relations === null) {
                  // ensure relations are made not on composite table.
                  if ($this->model->ngRestRelations() && (is_countable($this->getPrimaryKey()) ? count($this->getPrimaryKey()) : 0) > 1) {
      Severity: Minor
      Found in src/ngrest/Config.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

      There are no issues that match your filters.

      Category
      Status