robotdance/php-json-schema

View on GitHub

Showing 177 of 177 total issues

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

                    $this->checkUndefined($value, $schema ? : new \stdClass(), $path, $i);

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 '105', column '55').
Open

                        $this->checkUndefined($v, new \stdClass(), $path, $k);

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

Remove error control operator '@' on line 59.
Open

    public function validatePatternProperties($element, $path, $patternProperties)
    {
        $try = array('/','#','+','~','%');
        $matches = array();
        foreach ($patternProperties as $pregex => $schema) {

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

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

Missing class import via use statement (line '113', column '51').
Open

                $this->checkUndefined($value, new \stdClass(), $path, $i);

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 too many return statements within this method.
Open

            return is_object($value);
Severity: Major
Found in src/JsonSchema/Constraints/TypeConstraint.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return is_array($value);
    Severity: Major
    Found in src/JsonSchema/Constraints/TypeConstraint.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return is_null($value);
      Severity: Major
      Found in src/JsonSchema/Constraints/TypeConstraint.php - About 30 mins to fix

        Missing class import via use statement (line '53', column '34').
        Open

                        $subSchema = new \stdClass();

        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 '140', column '31').
        Open

                    $typeSchema = new \stdClass();

        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 too many return statements within this method.
        Open

                    return is_string($value);
        Severity: Major
        Found in src/JsonSchema/Constraints/TypeConstraint.php - About 30 mins to fix

          Remove error control operator '@' on line 162.
          Open

              protected function validateRegex($regex)
              {
                  return false !== @preg_match('/' . $regex . '/', '');
              }

          ErrorControlOperator

          Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

          Example

          function foo($filePath) {
              $file = @fopen($filPath); // hides exceptions
              $key = @$array[$notExistingKey]; // assigns null to $key
          }

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

          Missing class import via use statement (line '139', column '30').
          Open

                      $newSchema = new \stdClass();
          Severity: Minor
          Found in src/JsonSchema/RefResolver.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 '45', column '23').
          Open

                      throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');

          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 '26', column '23').
          Open

                      throw new \RuntimeException("cURL not installed");

          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 '46', column '23').
          Open

                      throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(

          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 '31', column '23').
          Open

                      throw new \InvalidArgumentException('Ref value must be a string');
          Severity: Minor
          Found in src/JsonSchema/Entity/JsonPointer.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 '25', column '114').
          Open

                  $dateTime = \DateTime::createFromFormat('Y-m-d\TH:i:s.uP', $dateAndTime . $microseconds . $timeZone, new \DateTimeZone('UTC'));
          Severity: Minor
          Found in src/JsonSchema/Rfc3339.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 '115', column '22').
          Open

                  $stack = new \SplStack();

          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

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

              protected function incrementPath($path, $i)
              {
                  if ($path !== '') {
                      if (is_int($i)) {
                          $path .= '[' . $i . ']';
          Severity: Minor
          Found in src/JsonSchema/Constraints/Constraint.php - About 25 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

              private function getRefSchema(JsonPointer $jsonPointer, $refSchema)
              {
                  foreach ($jsonPointer->getPropertyPaths() as $path) {
                      if (is_object($refSchema) && property_exists($refSchema, $path)) {
                          $refSchema = $refSchema->{$path};
          Severity: Minor
          Found in src/JsonSchema/RefResolver.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

          Severity
          Category
          Status
          Source
          Language