robotdance/php-json-schema

View on GitHub

Showing 38 of 177 total issues

Function validateCommonProperties has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    protected function validateCommonProperties($value, $schema = null, $path = null, $i = "")
    {
        // if it extends another schema, it must pass that schema as well
        if (isset($schema->extends)) {
            if (is_string($schema->extends)) {
Severity: Minor
Found in src/JsonSchema/Constraints/UndefinedConstraint.php - About 5 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 validateItems has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    protected function validateItems($value, $schema = null, $path = null, $i = null)
    {
        if (is_object($schema->items)) {
            // just one type definition for the whole array
            foreach ($value as $k => $v) {
Severity: Minor
Found in src/JsonSchema/Constraints/CollectionConstraint.php - About 5 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 check has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    public function check($element, $schema = null, $path = null, $i = null)
    {
        // Verify minimum
        if (isset($schema->exclusiveMinimum)) {
            if (isset($schema->minimum)) {
Severity: Minor
Found in src/JsonSchema/Constraints/NumberConstraint.php - About 5 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 validateDependencies has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    protected function validateDependencies($value, $dependencies, $path, $i = "")
    {
        foreach ($dependencies as $key => $dependency) {
            if (property_exists($value, $key)) {
                if (is_string($dependency)) {
Severity: Minor
Found in src/JsonSchema/Constraints/UndefinedConstraint.php - About 4 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 check has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public function check($element, $schema = null, $path = null, $i = null)
    {
        if (!isset($schema->format)) {
            return;
        }
Severity: Minor
Found in src/JsonSchema/Constraints/FormatConstraint.php - About 4 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 validateOfProperties has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    protected function validateOfProperties($value, $schema, $path, $i = "")
    {
        // Verify type
        if ($value instanceof UndefinedConstraint) {
            return;
Severity: Minor
Found in src/JsonSchema/Constraints/UndefinedConstraint.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

Method check has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function check($element, $schema = null, $path = null, $i = null)
    {
        if (!isset($schema->format)) {
            return;
        }
Severity: Major
Found in src/JsonSchema/Constraints/FormatConstraint.php - About 3 hrs to fix

    Method validateOfProperties has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function validateOfProperties($value, $schema, $path, $i = "")
        {
            // Verify type
            if ($value instanceof UndefinedConstraint) {
                return;
    Severity: Major
    Found in src/JsonSchema/Constraints/UndefinedConstraint.php - About 2 hrs to fix

      Function check has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public function check($element, $schema = null, $path = null, $i = null)
          {
              // Only validate enum if the attribute exists
              if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {
                  return;
      Severity: Minor
      Found in src/JsonSchema/Constraints/EnumConstraint.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 validateElement has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function validateElement($element, $matches, $objectDefinition = null, $path = null, $additionalProp = null)
          {
              $this->validateMinMaxConstraint($element, $objectDefinition, $path);
              foreach ($element as $i => $value) {
                  $definition = $this->getProperty($objectDefinition, $i);
      Severity: Minor
      Found in src/JsonSchema/Constraints/ObjectConstraint.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 validateCommonProperties has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function validateCommonProperties($value, $schema = null, $path = null, $i = "")
          {
              // if it extends another schema, it must pass that schema as well
              if (isset($schema->extends)) {
                  if (is_string($schema->extends)) {
      Severity: Major
      Found in src/JsonSchema/Constraints/UndefinedConstraint.php - About 2 hrs to fix

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

            public function validatePatternProperties($element, $path, $patternProperties)
            {
                $try = array('/','#','+','~','%');
                $matches = array();
                foreach ($patternProperties as $pregex => $schema) {
        Severity: Minor
        Found in src/JsonSchema/Constraints/ObjectConstraint.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 check has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function check($value = null, $schema = null, $path = null, $i = null)
            {
                $type = isset($schema->type) ? $schema->type : null;
                $isValid = true;
        
        
        Severity: Minor
        Found in src/JsonSchema/Constraints/TypeConstraint.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 check has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function check($element, $schema = null, $path = null, $i = null)
            {
                // Verify minimum
                if (isset($schema->exclusiveMinimum)) {
                    if (isset($schema->minimum)) {
        Severity: Minor
        Found in src/JsonSchema/Constraints/NumberConstraint.php - About 1 hr to fix

          Method validateItems has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function validateItems($value, $schema = null, $path = null, $i = null)
              {
                  if (is_object($schema->items)) {
                      // just one type definition for the whole array
                      foreach ($value as $k => $v) {
          Severity: Minor
          Found in src/JsonSchema/Constraints/CollectionConstraint.php - About 1 hr to fix

            Method check has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function check($value = null, $schema = null, $path = null, $i = null)
                {
                    $type = isset($schema->type) ? $schema->type : null;
                    $isValid = true;
            
            
            Severity: Minor
            Found in src/JsonSchema/Constraints/TypeConstraint.php - About 1 hr to fix

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

                  public function resolvePointer($jsonSchema, $uri)
                  {
                      $resolver = new UriResolver();
                      $parsed = $resolver->parse($uri);
                      if (empty($parsed['fragment'])) {
              Severity: Minor
              Found in src/JsonSchema/Uri/UriRetriever.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 validateType has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function validateType($value, $type)
                  {
                      //mostly the case for inline schema
                      if (!$type) {
                          return true;
              Severity: Minor
              Found in src/JsonSchema/Constraints/TypeConstraint.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 validateType has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function validateType($value, $type)
                  {
                      //mostly the case for inline schema
                      if (!$type) {
                          return true;
              Severity: Minor
              Found in src/JsonSchema/Constraints/TypeConstraint.php - About 1 hr to fix

                Method resolvePointer has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function resolvePointer($jsonSchema, $uri)
                    {
                        $resolver = new UriResolver();
                        $parsed = $resolver->parse($uri);
                        if (empty($parsed['fragment'])) {
                Severity: Minor
                Found in src/JsonSchema/Uri/UriRetriever.php - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language