luyadev/luya-module-admin

View on GitHub
src/openapi/specs/BaseSpecs.php

Summary

Maintainability
D
1 day
Test Coverage
A
94%

File BaseSpecs.php has 337 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace luya\admin\openapi\specs;

use cebe\openapi\spec\Example;
Severity: Minor
Found in src/openapi/specs/BaseSpecs.php - About 4 hrs to fix

    Method getParameters has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getParameters(): array
        {
            $params = [];
            if ($this->getReflection() instanceof ReflectionMethod) {
                foreach ($this->getReflection()->getParameters() as $arg) {
    Severity: Major
    Found in src/openapi/specs/BaseSpecs.php - About 3 hrs to fix

      Method getResponseContent has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getResponseContent()
          {
              $modelClass = $this->extractModelClassFromObject($this->getActionObject());
      
              if ($modelClass) {
      Severity: Minor
      Found in src/openapi/specs/BaseSpecs.php - About 1 hr to fix

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

            public function getParameters(): array
            {
                $params = [];
                if ($this->getReflection() instanceof ReflectionMethod) {
                    foreach ($this->getReflection()->getParameters() as $arg) {
        Severity: Minor
        Found in src/openapi/specs/BaseSpecs.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

        Method internalGenerateResponseArrayFromModel has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function internalGenerateResponseArrayFromModel($modelClassName, $isArray = false)
            {
                $object = $this->createObjectFromClassName($modelClassName);
        
                $schema = false;
        Severity: Minor
        Found in src/openapi/specs/BaseSpecs.php - About 1 hr to fix

          Function internalGenerateResponseArrayFromModel has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              private function internalGenerateResponseArrayFromModel($modelClassName, $isArray = false)
              {
                  $object = $this->createObjectFromClassName($modelClassName);
          
                  $schema = false;
          Severity: Minor
          Found in src/openapi/specs/BaseSpecs.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 too many return statements within this method.
          Open

                  return [];
          Severity: Major
          Found in src/openapi/specs/BaseSpecs.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return [
                            'application/json' => new MediaType([
                                'schema' => [
                                    'type' => $type->getNoramlizeName(),
                                ],
            Severity: Major
            Found in src/openapi/specs/BaseSpecs.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return [
                              'application/json' => new MediaType([
                                  'schema' => [
                                      'type' => 'object',
                                  ],
              Severity: Major
              Found in src/openapi/specs/BaseSpecs.php - About 30 mins to fix

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

                    protected function getResponseContent()
                    {
                        $modelClass = $this->extractModelClassFromObject($this->getActionObject());
                
                        if ($modelClass) {
                Severity: Minor
                Found in src/openapi/specs/BaseSpecs.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