luyadev/luya-module-admin

View on GitHub
src/ngrest/base/NgRestModel.php

Summary

Maintainability
D
3 days
Test Coverage
B
88%

NgRestModel has 51 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class NgRestModel extends ActiveRecord implements GenericSearchInterface, NgRestModelInterface
{
    /**
     * @var string This event will be trigger after the find population of each row when ngrest loads the data from the server to edit data. (When click on edit icon)
     */
Severity: Major
Found in src/ngrest/base/NgRestModel.php - About 7 hrs to fix

    File NgRestModel.php has 454 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace luya\admin\ngrest\base;
    
    use luya\admin\base\GenericSearchInterface;
    Severity: Minor
    Found in src/ngrest/base/NgRestModel.php - About 6 hrs to fix

      Function ngRestConfigDefine has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function ngRestConfigDefine(ConfigBuilder $config, $assignedType, array $fields)
          {
              $types = $this->ngRestAttributeTypes();
              $extraTypes = $this->ngRestExtraAttributeTypes();
      
      
      Severity: Minor
      Found in src/ngrest/base/NgRestModel.php - About 4 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 ngRestConfigDefine has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function ngRestConfigDefine(ConfigBuilder $config, $assignedType, array $fields)
          {
              $types = $this->ngRestAttributeTypes();
              $extraTypes = $this->ngRestExtraAttributeTypes();
      
      
      Severity: Minor
      Found in src/ngrest/base/NgRestModel.php - About 1 hr to fix

        Function ngRestConfig has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function ngRestConfig($config)
            {
                foreach ($this->ngRestScopes() as $arrayConfig) {
                    if (!isset($arrayConfig[0]) && !isset($arrayConfig[1])) {
                        throw new InvalidConfigException("Invalid ngRestScope definition. Definition must contain an array with two elements: `['create', []]`");
        Severity: Minor
        Found in src/ngrest/base/NgRestModel.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 i18nAttributeFallbackValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function i18nAttributeFallbackValue($attributeName, $preferredLanguage = null)
            {
                $value = $this->{$attributeName};
        
                if (empty($value) && $this->isI18n($attributeName)) {
        Severity: Minor
        Found in src/ngrest/base/NgRestModel.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 ngRestConfigButtonCondition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function ngRestConfigButtonCondition($arrayConfig)
            {
                if (!isset($arrayConfig[2]) || !isset($arrayConfig[2]['buttonCondition'])) {
                    $buttonCondition = '';
                } elseif (is_string($arrayConfig[2]['buttonCondition'])) {
        Severity: Minor
        Found in src/ngrest/base/NgRestModel.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 getNgRestScopeConfigOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getNgRestScopeConfigOptions($config)
            {
                $configOptions = [];
                foreach ($this->ngRestScopes() as $arrayConfig) {
                    $scope = is_string($arrayConfig[0]) ? [$arrayConfig[0]] : $arrayConfig[0];
        Severity: Minor
        Found in src/ngrest/base/NgRestModel.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 generateNgRestRelations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function generateNgRestRelations()
            {
                $relations = [];
                // generate relations
                foreach ($this->ngRestRelations() as $key => $item) {
        Severity: Minor
        Found in src/ngrest/base/NgRestModel.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 afterFind has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function afterFind()
            {
                if ($this->getNgRestCallType()) {
                    if ($this->getNgRestCallType() == 'list') {
                        $this->trigger(self::EVENT_AFTER_NGREST_FIND);
        Severity: Minor
        Found in src/ngrest/base/NgRestModel.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