robotdance/php-json-schema

View on GitHub

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

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

    class UndefinedConstraint extends Constraint
    {
        /**
         * {@inheritDoc}
         */

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

        public function parse($uri)
        {
            preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
    
            $components = array();
    Severity: Major
    Found in src/JsonSchema/Uri/UriResolver.php and 1 other location - About 3 hrs to fix
    src/JsonSchema/Uri/UriRetriever.php on lines 205..227

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

    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

        public function parse($uri)
        {
            preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
    
            $components = array();
    Severity: Major
    Found in src/JsonSchema/Uri/UriRetriever.php and 1 other location - About 3 hrs to fix
    src/JsonSchema/Uri/UriResolver.php on lines 28..48

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

    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

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

            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

              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

              Severity
              Category
              Status
              Source
              Language