nabbar/SwaggerValidator-PHP

View on GitHub

Showing 604 of 604 total issues

Function getModel has a Cognitive Complexity of 22 (exceeds 5 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 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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            if ($key === \SwaggerValidator\Common\FactorySwagger::KEY_REFERENCE) {
                $ref       = $this->getCanonical($context, $value);
                $refList[] = $ref;

                $context->logReference('replace', $ref[0], $value, __METHOD__, __LINE__);
Severity: Major
Found in src/Common/ReferenceFile.php and 1 other location - About 2 hrs to fix
src/Common/ReferenceFile.php on lines 215..231

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 139.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            if ($key === \SwaggerValidator\Common\FactorySwagger::KEY_REFERENCE) {
                $ref       = $this->getCanonical($context, $value);
                $refList[] = $ref;

                $context->logReference('replace', $ref[0], $value, __METHOD__, __LINE__);
Severity: Major
Found in src/Common/ReferenceFile.php and 1 other location - About 2 hrs to fix
src/Common/ReferenceFile.php on lines 244..260

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 139.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function buildBodyXml has a Cognitive Complexity of 20 (exceeds 5 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 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 jsonUnSerialize has a Cognitive Complexity of 19 (exceeds 5 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 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 validate has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate(\SwaggerValidator\Common\Context $context, $valueParams = null)
    {
        $result    = true;
        $lastKey   = null;
        $keySchema = \SwaggerValidator\Common\FactorySwagger::KEY_SCHEMA;
Severity: Minor
Found in src/DataType/TypeArrayItems.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 setValidationError has 64 lines of code (exceeds 25 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: Major
Found in src/Common/Context.php - About 2 hrs to fix

    Collection has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Collection implements \Countable, \IteratorAggregate, \ArrayAccess, \Serializable, \JsonSerializable
    {
    
        /**
         *
    Severity: Minor
    Found in src/Common/Collection.php - About 2 hrs to fix

      CollectionReference has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class CollectionReference extends \SwaggerValidator\Common\Collection
      {
      
          const ID_PREFIX = 'id:';
      
      
      Severity: Minor
      Found in src/Common/CollectionReference.php - About 2 hrs to fix

        File TypeCommon.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

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

          Function validate has a Cognitive Complexity of 17 (exceeds 5 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 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 validateTooMany has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function validateTooMany(\SwaggerValidator\Common\Context $context)
              {
                  $sandBox = $context->getSandBoxKeys();
          
                  foreach ($context->getRequestDataKeys() as $location => $list) {
          Severity: Minor
          Found in src/Object/Swagger.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 validate has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function validate(\SwaggerValidator\Common\Context $context)
              {
                  foreach ($this->keys() as $key) {
                      if (is_object($this->$key) && ($this->$key instanceof \SwaggerValidator\Object\PathItem)) {
                          continue;
          Severity: Major
          Found in src/Object/Paths.php - About 2 hrs to fix

            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 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

                      Severity
                      Category
                      Status
                      Source
                      Language