nabbar/SwaggerValidator-PHP

View on GitHub

Showing 188 of 604 total issues

File Swagger.php has 254 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/*
 * Copyright 2016 Nicolas JUHEL <swaggervalidator@nabbar.com>.
 *
Severity: Minor
Found in src/Object/Swagger.php - About 2 hrs to fix

    Function setValidationError has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public function setValidationError($valitionType, $messageException = null, $method = null, $line = null)
        {
            $this->logValidationError($valitionType, $messageException, $method, $line);
    
            if ($this->__get('IsCombined')) {
    Severity: Minor
    Found in src/Common/Context.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

    Method getExampleType has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function getExampleType(\SwaggerValidator\Common\Context $context)
        {
            $keyItems = \SwaggerValidator\Common\FactorySwagger::KEY_ITEMS;
    
            if (is_object($this->$keyItems) && method_exists($this->$keyItems, 'getModel')) {
    Severity: Major
    Found in src/DataType/TypeArray.php - About 2 hrs to fix

      Method validate has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function validate(\SwaggerValidator\Common\Context $context)
          {
              $keyRequired   = \SwaggerValidator\Common\FactorySwagger::KEY_REQUIRED;
              $keyAdditional = \SwaggerValidator\Common\FactorySwagger::KEY_ADDPROPERTIES;
      
      Severity: Minor
      Found in src/DataType/TypeObject.php - About 2 hrs to fix

        Method getModel has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getModel(\SwaggerValidator\Common\Context $context)
            {
                $result   = new \stdClass();
                $keyAnyOf = \SwaggerValidator\Common\FactorySwagger::KEY_ANYOF;
                $keyAllOf = \SwaggerValidator\Common\FactorySwagger::KEY_ALLOF;
        Severity: Minor
        Found in src/DataType/TypeCombined.php - About 2 hrs to fix

          Method validate has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function validate(\SwaggerValidator\Common\Context $context)
              {
                  $keyType        = \SwaggerValidator\Common\FactorySwagger::KEY_TYPE;
                  $keyItems       = \SwaggerValidator\Common\FactorySwagger::KEY_ITEMS;
                  $keyAdditional  = \SwaggerValidator\Common\FactorySwagger::KEY_ADDITEMS;
          Severity: Minor
          Found in src/DataType/TypeArray.php - About 1 hr to fix

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

                public function validate(\SwaggerValidator\Common\Context $context)
                {
                    if (!isset($this->type)) {
                        return $context->setValidationError(\SwaggerValidator\Common\Context::VALIDATION_TYPE_SWAGGER_ERROR, null, __METHOD__, __LINE__);
                    }
            Severity: Minor
            Found in src/DataType/TypeInteger.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 getExampleType has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function getExampleType(\SwaggerValidator\Common\Context $context)
                {
                    $keySchema = \SwaggerValidator\Common\FactorySwagger::KEY_SCHEMA;
                    $result    = array();
            
            
            Severity: Minor
            Found in src/DataType/TypeArrayItems.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 loadRequestPath has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                public function loadRequestPath($paramName)
                {
                    // parse from the end to the top
                    $path = array_reverse(explode('/', $this->contextRequestPath));
            
            
            Severity: Minor
            Found in src/Common/Context.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 getExampleType has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function getExampleType(\SwaggerValidator\Common\Context $context)
                {
                    $keyItems = \SwaggerValidator\Common\FactorySwagger::KEY_ITEMS;
            
                    if (is_object($this->$keyItems) && method_exists($this->$keyItems, 'getModel')) {
            Severity: Minor
            Found in src/DataType/TypeArray.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 jsonUnSerialize has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function jsonUnSerialize(\SwaggerValidator\Common\Context $context, $jsonData)
                {
                    $this->checkJsonObject($context, $jsonData);
            
                    if (property_exists($jsonData, \SwaggerValidator\Common\FactorySwagger::KEY_REFERENCE) && count(get_object_vars($jsonData)) > 1) {
            Severity: Minor
            Found in src/DataType/TypeObject.php - About 1 hr to fix

              Function validate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function validate(\SwaggerValidator\Common\Context $context)
                  {
                      if (!isset($this->type)) {
                          return $context->setValidationError(\SwaggerValidator\Common\Context::VALIDATION_TYPE_SWAGGER_ERROR, null, __METHOD__, __LINE__);
                      }
              Severity: Minor
              Found in src/DataType/TypeNumber.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 validate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function validate(\SwaggerValidator\Common\Context $context, $valueParams = null)
                  {
                      $keyAnyOf = \SwaggerValidator\Common\FactorySwagger::KEY_ANYOF;
                      $keyAllOf = \SwaggerValidator\Common\FactorySwagger::KEY_ALLOF;
                      $keyOneOf = \SwaggerValidator\Common\FactorySwagger::KEY_ONEOF;
              Severity: Minor
              Found in src/DataType/TypeCombined.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 __construct has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function __construct(\SwaggerValidator\Common\Context $context, $filepath)
                  {
                      $this->fileUri = $filepath;
              
                      $urlPart = parse_url($filepath);
              Severity: Minor
              Found in src/Common/ReferenceFile.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 getExampleType has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function getExampleType(\SwaggerValidator\Common\Context $context)
                  {
                      $keySchema = \SwaggerValidator\Common\FactorySwagger::KEY_SCHEMA;
                      $result    = array();
              
              
              Severity: Minor
              Found in src/DataType/TypeArrayItems.php - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                        if ($paramName === \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY && $this->getType() === self::TYPE_REQUEST) {
                            return $this->loadRequestBody();
                        }
                        elseif ($paramName === \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY && $this->getType() === self::TYPE_RESPONSE) {
                            return $this->loadResponseBody();
                Severity: Critical
                Found in src/Common/Context.php - About 1 hr to fix

                  Method buildBodyXml has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function buildBodyXml($contents)
                      {
                          $this->contextDataType   = self::CONTENT_TYPE_XML;
                          $this->contextDataExists = (bool) (strlen($contents) > 0);
                          $this->contextDataValue  = simplexml_load_string($contents);
                  Severity: Minor
                  Found in src/Common/Context.php - About 1 hr to fix

                    Method buildObjectFromOriginObject has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function buildObjectFromOriginObject(\SwaggerValidator\Common\Context $context, $originType, $originKey, &$jsonData)
                        {
                            $keyIn   = self::KEY_IN;
                            $keyName = self::KEY_NAME;
                            $object  = null;
                    Severity: Minor
                    Found in src/Common/FactorySwagger.php - About 1 hr to fix

                      Function buildObjectFromOriginKey has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function buildObjectFromOriginKey(\SwaggerValidator\Common\Context $context, $originType, $originKey, &$jsonData)
                          {
                              $object = null;
                      
                              if (!empty(self::$keyToObject[$originKey])) {
                      Severity: Minor
                      Found in src/Common/FactorySwagger.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 jsonUnSerialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function jsonUnSerialize(\SwaggerValidator\Common\Context $context, $originType, $originKey, &$jsonData)
                          {
                              $keyType   = self::KEY_TYPE;
                              $keyCustom = self::KEY_CUSTOM_PATTERN;
                              $notCustom = array(
                      Severity: Minor
                      Found in src/Common/FactorySwagger.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

                      Severity
                      Category
                      Status
                      Source
                      Language