nabbar/SwaggerValidator-PHP

View on GitHub
src/Common/Context.php

Summary

Maintainability
F
5 days
Test Coverage

cleanParams accesses the super-global variable $_GET.
Open

    public function cleanParams()
    {
        $_GET    = array();
        $_POST   = array();
        $_FILES  = array();
Severity: Minor
Found in src/Common/Context.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

loadRequestFormData accesses the super-global variable $_FILES.
Open

    public function loadRequestFormData($paramName)
    {
        if (array_key_exists($paramName, $_POST)) {
            $this->contextDataExists = true;
            $this->contextDataValue  = $_POST[$paramName];
Severity: Minor
Found in src/Common/Context.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

loadRequestFormData accesses the super-global variable $_FILES.
Open

    public function loadRequestFormData($paramName)
    {
        if (array_key_exists($paramName, $_POST)) {
            $this->contextDataExists = true;
            $this->contextDataValue  = $_POST[$paramName];
Severity: Minor
Found in src/Common/Context.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

getRequestFormDataKey accesses the super-global variable $_POST.
Open

    public function getRequestFormDataKey()
    {
        $post = array_keys($_POST);
        $file = array_keys($_FILES);

Severity: Minor
Found in src/Common/Context.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

cleanParams accesses the super-global variable $_COOKIE.
Open

    public function cleanParams()
    {
        $_GET    = array();
        $_POST   = array();
        $_FILES  = array();
Severity: Minor
Found in src/Common/Context.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

loadRequestFormData accesses the super-global variable $_POST.
Open

    public function loadRequestFormData($paramName)
    {
        if (array_key_exists($paramName, $_POST)) {
            $this->contextDataExists = true;
            $this->contextDataValue  = $_POST[$paramName];
Severity: Minor
Found in src/Common/Context.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

cleanParams accesses the super-global variable $_POST.
Open

    public function cleanParams()
    {
        $_GET    = array();
        $_POST   = array();
        $_FILES  = array();
Severity: Minor
Found in src/Common/Context.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

cleanParams accesses the super-global variable $_FILES.
Open

    public function cleanParams()
    {
        $_GET    = array();
        $_POST   = array();
        $_FILES  = array();
Severity: Minor
Found in src/Common/Context.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

getRequestFormDataKey accesses the super-global variable $_FILES.
Open

    public function getRequestFormDataKey()
    {
        $post = array_keys($_POST);
        $file = array_keys($_FILES);

Severity: Minor
Found in src/Common/Context.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

loadRequestFormData accesses the super-global variable $_POST.
Open

    public function loadRequestFormData($paramName)
    {
        if (array_key_exists($paramName, $_POST)) {
            $this->contextDataExists = true;
            $this->contextDataValue  = $_POST[$paramName];
Severity: Minor
Found in src/Common/Context.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

cleanParams accesses the super-global variable $_SERVER.
Open

    public function cleanParams()
    {
        $_GET    = array();
        $_POST   = array();
        $_FILES  = array();
Severity: Minor
Found in src/Common/Context.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

cleanParams accesses the super-global variable $_SERVER.
Open

    public function cleanParams()
    {
        $_GET    = array();
        $_POST   = array();
        $_FILES  = array();
Severity: Minor
Found in src/Common/Context.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

File Context.php has 642 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/*
 * Copyright 2016 Nicolas JUHEL <swaggervalidator@nabbar.com>.
 *
Severity: Major
Found in src/Common/Context.php - About 1 day to fix

    Context has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Context extends ContextBase implements \SwaggerValidator\Interfaces\ContextLog, \SwaggerValidator\Interfaces\ContextDataLoader, \SwaggerValidator\Interfaces\ContextDataParser
    {
        /*
         * Mode Constants
         */
    Severity: Minor
    Found in src/Common/Context.php - About 5 hrs to fix

      The class Context has an overall complexity of 152 which is very high. The configured complexity threshold is 50.
      Open

      class Context extends ContextBase implements \SwaggerValidator\Interfaces\ContextLog, \SwaggerValidator\Interfaces\ContextDataLoader, \SwaggerValidator\Interfaces\ContextDataParser
      {
          /*
           * Mode Constants
           */
      Severity: Minor
      Found in src/Common/Context.php by phpmd

      The class Context has 29 non-getter- and setter-methods. Consider refactoring Context to keep number of methods under 25.
      Open

      class Context extends ContextBase implements \SwaggerValidator\Interfaces\ContextLog, \SwaggerValidator\Interfaces\ContextDataLoader, \SwaggerValidator\Interfaces\ContextDataParser
      {
          /*
           * Mode Constants
           */
      Severity: Minor
      Found in src/Common/Context.php by phpmd

      TooManyMethods

      Since: 0.1

      A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      The default was changed from 10 to 25 in PHPMD 2.3.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanymethods

      The class Context has 25 public methods. Consider refactoring Context to keep number of public methods under 10.
      Open

      class Context extends ContextBase implements \SwaggerValidator\Interfaces\ContextLog, \SwaggerValidator\Interfaces\ContextDataLoader, \SwaggerValidator\Interfaces\ContextDataParser
      {
          /*
           * Mode Constants
           */
      Severity: Minor
      Found in src/Common/Context.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      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

      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

        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

        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

        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 dataLoad has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function dataLoad()
                {
                    $paramName = $this->__get('DataPath');
                    $paramName = array_pop($paramName);
            
            
            Severity: Minor
            Found in src/Common/Context.php - About 1 hr to fix

              Function dataLoad has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function dataLoad()
                  {
                      $paramName = $this->__get('DataPath');
                      $paramName = array_pop($paramName);
              
              
              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 parseQueryAsMulti has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function parseQueryAsMulti($queryString)
                  {
                      $params = explode('&', $queryString);
                      $result = array();
              
              
              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

              Method loadBodyByContent has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function loadBodyByContent($headers, $rawBody)
                  {
                      $contentType   = null;
                      $contentLength = null;
              
              
              Severity: Minor
              Found in src/Common/Context.php - About 1 hr to fix

                Method loadRequestPath has 27 lines of code (exceeds 25 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

                  Method logReference has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public function logReference($type, $ref, $oldRef = null, $method = null, $line = null)
                  Severity: Minor
                  Found in src/Common/Context.php - About 35 mins to fix

                    Function logReference has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function logReference($type, $ref, $oldRef = null, $method = null, $line = null)
                        {
                            if (self::getConfig('log', 'reference') || self::getConfig('log', $type . 'Ref')) {
                                switch ($type) {
                                    case 'replace':
                    Severity: Minor
                    Found in src/Common/Context.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 setSandBox has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function setSandBox()
                        {
                            if ($this->getType() !== self::TYPE_REQUEST) {
                                return $this;
                            }
                    Severity: Minor
                    Found in src/Common/Context.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 loadBodyByContent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function loadBodyByContent($headers, $rawBody)
                        {
                            $contentType   = null;
                            $contentLength = null;
                    
                    
                    Severity: Minor
                    Found in src/Common/Context.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

                    Avoid too many return statements within this method.
                    Open

                                return $this->loadRequestPath($paramName);
                    Severity: Major
                    Found in src/Common/Context.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return $this->loadRequestQuery($paramName);
                      Severity: Major
                      Found in src/Common/Context.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return $this->checkDataIsEmpty();
                        Severity: Major
                        Found in src/Common/Context.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return $this->loadRequestFormData($paramName);
                          Severity: Major
                          Found in src/Common/Context.php - About 30 mins to fix

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

                                public function checkDataIsEmpty()
                                {
                                    if ($this->isDataExists() === false) {
                                        $this->contextDataEmpty = true;
                                    }
                            Severity: Minor
                            Found in src/Common/Context.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

                            The class Context has 1012 lines of code. Current threshold is 1000. Avoid really long classes.
                            Open

                            class Context extends ContextBase implements \SwaggerValidator\Interfaces\ContextLog, \SwaggerValidator\Interfaces\ContextDataLoader, \SwaggerValidator\Interfaces\ContextDataParser
                            {
                                /*
                                 * Mode Constants
                                 */
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            The method setValidationError() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
                            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 by phpmd

                            CyclomaticComplexity

                            Since: 0.1

                            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                            Example

                            // Cyclomatic Complexity = 11
                            class Foo {
                            1   public function example() {
                            2       if ($a == $b) {
                            3           if ($a1 == $b1) {
                                            fiddle();
                            4           } elseif ($a2 == $b2) {
                                            fiddle();
                                        } else {
                                            fiddle();
                                        }
                            5       } elseif ($c == $d) {
                            6           while ($c == $d) {
                                            fiddle();
                                        }
                            7        } elseif ($e == $f) {
                            8           for ($n = 0; $n < $h; $n++) {
                                            fiddle();
                                        }
                                    } else {
                                        switch ($z) {
                            9               case 1:
                                                fiddle();
                                                break;
                            10              case 2:
                                                fiddle();
                                                break;
                            11              case 3:
                                                fiddle();
                                                break;
                                            default:
                                                fiddle();
                                                break;
                                        }
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                            The method dataLoad() has a Cyclomatic Complexity of 21. The configured cyclomatic complexity threshold is 10.
                            Open

                                public function dataLoad()
                                {
                                    $paramName = $this->__get('DataPath');
                                    $paramName = array_pop($paramName);
                            
                            
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            CyclomaticComplexity

                            Since: 0.1

                            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                            Example

                            // Cyclomatic Complexity = 11
                            class Foo {
                            1   public function example() {
                            2       if ($a == $b) {
                            3           if ($a1 == $b1) {
                                            fiddle();
                            4           } elseif ($a2 == $b2) {
                                            fiddle();
                                        } else {
                                            fiddle();
                                        }
                            5       } elseif ($c == $d) {
                            6           while ($c == $d) {
                                            fiddle();
                                        }
                            7        } elseif ($e == $f) {
                            8           for ($n = 0; $n < $h; $n++) {
                                            fiddle();
                                        }
                                    } else {
                                        switch ($z) {
                            9               case 1:
                                                fiddle();
                                                break;
                            10              case 2:
                                                fiddle();
                                                break;
                            11              case 3:
                                                fiddle();
                                                break;
                                            default:
                                                fiddle();
                                                break;
                                        }
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                            Missing class import via use statement (line '1028', column '26').
                            Open

                                            $e = new \SwaggerValidator\Exception($messageException);
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            MissingImport

                            Since: 2.7.0

                            Importing all external classes in a file through use statements makes them clearly visible.

                            Example

                            function make() {
                                return new \stdClass();
                            }

                            Source http://phpmd.org/rules/cleancode.html#MissingImport

                            Missing class import via use statement (line '935', column '18').
                            Open

                                    $e = new \SwaggerValidator\Exception($message);
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            MissingImport

                            Since: 2.7.0

                            Importing all external classes in a file through use statements makes them clearly visible.

                            Example

                            function make() {
                                return new \stdClass();
                            }

                            Source http://phpmd.org/rules/cleancode.html#MissingImport

                            Avoid using static access to class '\SwaggerValidator\Common\Collection' in method 'buildBodyXml'.
                            Open

                                        $this->contextDataValue = \SwaggerValidator\Common\Collection::jsonEncode($this->getDataValue());
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            StaticAccess

                            Since: 1.4.0

                            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                            Example

                            class Foo
                            {
                                public function bar()
                                {
                                    Bar::baz();
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#staticaccess

                            Avoid using static access to class '\SwaggerValidator\Common\Collection' in method 'setValidationError'.
                            Open

                                            $messageException = 'Swagger Validation Error : Route ! Value Find : ' . \SwaggerValidator\Common\Collection::jsonEncode($this->getDataValue());
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            StaticAccess

                            Since: 1.4.0

                            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                            Example

                            class Foo
                            {
                                public function bar()
                                {
                                    Bar::baz();
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#staticaccess

                            The method loadResponseBody uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                            Open

                                    else {
                                        $this->loadBodyByContent($this->getResponseHeader(), file_get_contents("php://output"));
                                    }
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ElseExpression

                            Since: 1.4.0

                            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                            Example

                            class Foo
                            {
                                public function bar($flag)
                                {
                                    if ($flag) {
                                        // one branch
                                    } else {
                                        // another branch
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#elseexpression

                            The method loadRequestBody uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                            Open

                                    else {
                                        $this->loadBodyByContent($this->getRequestHeader(), file_get_contents("php://input"));
                                    }
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ElseExpression

                            Since: 1.4.0

                            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                            Example

                            class Foo
                            {
                                public function bar($flag)
                                {
                                    if ($flag) {
                                        // one branch
                                    } else {
                                        // another branch
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#elseexpression

                            The method buildBodyXml uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                            Open

                                            else {
                                                $this->contextDecodeError[] = array('code' => json_last_error(), 'message' => null);
                                            }
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ElseExpression

                            Since: 1.4.0

                            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                            Example

                            class Foo
                            {
                                public function bar($flag)
                                {
                                    if ($flag) {
                                        // one branch
                                    } else {
                                        // another branch
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#elseexpression

                            The method buildBodyXml uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                            Open

                                        else {
                                            $this->contextDataValue = json_decode($this->getDataValue(), false);
                            
                                            if (json_last_error() !== JSON_ERROR_NONE) {
                                                $this->contextDataEmpty = true;
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ElseExpression

                            Since: 1.4.0

                            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                            Example

                            class Foo
                            {
                                public function bar($flag)
                                {
                                    if ($flag) {
                                        // one branch
                                    } else {
                                        // another branch
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#elseexpression

                            Avoid using static access to class '\SwaggerValidator\Common\Collection' in method 'setValidationError'.
                            Open

                                            $messageException = 'Swagger Validation Error : Method ! Value Find : ' . \SwaggerValidator\Common\Collection::jsonEncode($this->getDataValue());
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            StaticAccess

                            Since: 1.4.0

                            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                            Example

                            class Foo
                            {
                                public function bar()
                                {
                                    Bar::baz();
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#staticaccess

                            The method checkDataIsEmpty uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                            Open

                                    else {
                                        $this->contextDataEmpty = (bool) $this->checkIsEmpty($this->getDataValue());
                                    }
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ElseExpression

                            Since: 1.4.0

                            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                            Example

                            class Foo
                            {
                                public function bar($flag)
                                {
                                    if ($flag) {
                                        // one branch
                                    } else {
                                        // another branch
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#elseexpression

                            The method getRequestDataKeys uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                            Open

                                    else {
                                        $data = file_get_contents("php://input");
                                    }
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ElseExpression

                            Since: 1.4.0

                            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                            Example

                            class Foo
                            {
                                public function bar($flag)
                                {
                                    if ($flag) {
                                        // one branch
                                    } else {
                                        // another branch
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#elseexpression

                            The method buildBodyXml uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                            Open

                                                else {
                                                    $this->contextDecodeError[] = array('code' => json_last_error(), 'message' => null);
                                                }
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ElseExpression

                            Since: 1.4.0

                            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                            Example

                            class Foo
                            {
                                public function bar($flag)
                                {
                                    if ($flag) {
                                        // one branch
                                    } else {
                                        // another branch
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#elseexpression

                            The method buildBodyXml uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                            Open

                                            else {
                                                $this->checkDataIsEmpty();
                                            }
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ElseExpression

                            Since: 1.4.0

                            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                            Example

                            class Foo
                            {
                                public function bar($flag)
                                {
                                    if ($flag) {
                                        // one branch
                                    } else {
                                        // another branch
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#elseexpression

                            Avoid using static access to class '\SwaggerValidator\Common\Collection' in method 'setValidationError'.
                            Open

                                            $messageException = 'Swagger Validation Error : HostName ! Value Find : ' . \SwaggerValidator\Common\Collection::jsonEncode($this->getDataValue());
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            StaticAccess

                            Since: 1.4.0

                            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                            Example

                            class Foo
                            {
                                public function bar()
                                {
                                    Bar::baz();
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#staticaccess

                            The method buildBodyJson uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                            Open

                                    else {
                                        $this->checkDataIsEmpty();
                                    }
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ElseExpression

                            Since: 1.4.0

                            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                            Example

                            class Foo
                            {
                                public function bar($flag)
                                {
                                    if ($flag) {
                                        // one branch
                                    } else {
                                        // another branch
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#elseexpression

                            Avoid using static access to class '\SwaggerValidator\Common\Collection' in method 'logMessage'.
                            Open

                                        $message = \SwaggerValidator\Common\Collection::jsonEncode($message);
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            StaticAccess

                            Since: 1.4.0

                            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                            Example

                            class Foo
                            {
                                public function bar()
                                {
                                    Bar::baz();
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#staticaccess

                            The method parseQueryAsMulti uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                            Open

                                        else {
                                            $result[$key] = $qrs[$key];
                                        }
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ElseExpression

                            Since: 1.4.0

                            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                            Example

                            class Foo
                            {
                                public function bar($flag)
                                {
                                    if ($flag) {
                                        // one branch
                                    } else {
                                        // another branch
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#elseexpression

                            Avoid using static access to class '\SwaggerValidator\Common\Collection' in method 'setValidationError'.
                            Open

                                            $messageException = 'Swagger Validation Error : BasePath ! Value Find : ' . \SwaggerValidator\Common\Collection::jsonEncode($this->getDataValue());
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            StaticAccess

                            Since: 1.4.0

                            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                            Example

                            class Foo
                            {
                                public function bar()
                                {
                                    Bar::baz();
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#staticaccess

                            The method __storeData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                            Open

                                    else {
                                        parent::__storeData($key, $value);
                                    }
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ElseExpression

                            Since: 1.4.0

                            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                            Example

                            class Foo
                            {
                                public function bar($flag)
                                {
                                    if ($flag) {
                                        // one branch
                                    } else {
                                        // another branch
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#elseexpression

                            The method buildBodyJson uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                            Open

                                        else {
                                            $this->contextDecodeError = array(array('code' => json_last_error(), 'message' => null));
                                        }
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ElseExpression

                            Since: 1.4.0

                            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                            Example

                            class Foo
                            {
                                public function bar($flag)
                                {
                                    if ($flag) {
                                        // one branch
                                    } else {
                                        // another branch
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#elseexpression

                            The method buildBodyXml uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                            Open

                                    else {
                                        $this->contextDataValue = \SwaggerValidator\Common\Collection::jsonEncode($this->getDataValue());
                            
                                        if (json_last_error() !== JSON_ERROR_NONE) {
                                            $this->contextDataEmpty = true;
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ElseExpression

                            Since: 1.4.0

                            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                            Example

                            class Foo
                            {
                                public function bar($flag)
                                {
                                    if ($flag) {
                                        // one branch
                                    } else {
                                        // another branch
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/cleancode.html#elseexpression

                            Avoid unused local variables such as '$code'.
                            Open

                                            $this->contextDecodeError[] = array('code' => $error->$code, 'message' => $error->message);
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            UnusedLocalVariable

                            Since: 0.2

                            Detects when a local variable is declared and/or assigned, but not used.

                            Example

                            class Foo {
                                public function doSomething()
                                {
                                    $i = 5; // Unused
                                }
                            }

                            Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

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

                                        if (json_last_error() !== JSON_ERROR_NONE) {
                                            $this->contextDataEmpty = true;
                                            $this->contextDataValue = null;
                                            if (function_exists('json_last_error_msg')) {
                                                $this->contextDecodeError[] = array('code' => json_last_error(), 'message' => json_last_error_msg());
                            Severity: Minor
                            Found in src/Common/Context.php and 1 other location - About 55 mins to fix
                            src/Common/Context.php on lines 615..627

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

                            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 (json_last_error() !== JSON_ERROR_NONE) {
                                                $this->contextDataEmpty = true;
                                                $this->contextDataValue = null;
                                                if (function_exists('json_last_error_msg')) {
                                                    $this->contextDecodeError[] = array('code' => json_last_error(), 'message' => json_last_error_msg());
                            Severity: Minor
                            Found in src/Common/Context.php and 1 other location - About 55 mins to fix
                            src/Common/Context.php on lines 602..628

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

                            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

                            Avoid variables with short names like $e. Configured minimum length is 3.
                            Open

                                            $e = new \SwaggerValidator\Exception($messageException);
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ShortVariable

                            Since: 0.2

                            Detects when a field, local, or parameter has a very short name.

                            Example

                            class Something {
                                private $q = 15; // VIOLATION - Field
                                public static function main( array $as ) { // VIOLATION - Formal
                                    $r = 20 + $this->q; // VIOLATION - Local
                                    for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                        $r += $this->q;
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/naming.html#shortvariable

                            Avoid variables with short names like $e. Configured minimum length is 3.
                            Open

                                    $e = new \SwaggerValidator\Exception($message);
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            ShortVariable

                            Since: 0.2

                            Detects when a field, local, or parameter has a very short name.

                            Example

                            class Something {
                                private $q = 15; // VIOLATION - Field
                                public static function main( array $as ) { // VIOLATION - Formal
                                    $r = 20 + $this->q; // VIOLATION - Local
                                    for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                        $r += $this->q;
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/naming.html#shortvariable

                            The method __storeData is not named in camelCase.
                            Open

                                protected function __storeData($key, $value = null)
                                {
                                    if (property_exists($this, $key)) {
                                        $this->$key = $value;
                                    }
                            Severity: Minor
                            Found in src/Common/Context.php by phpmd

                            CamelCaseMethodName

                            Since: 0.2

                            It is considered best practice to use the camelCase notation to name methods.

                            Example

                            class ClassName {
                                public function get_name() {
                                }
                            }

                            Source

                            There are no issues that match your filters.

                            Category
                            Status