swaggest/php-json-schema

View on GitHub

Showing 87 of 92 total issues

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

    private function processIf($data, Context $options, $path)
    {
        $valid = true;
        try {
            self::unboolSchema($this->if)->process($data, $options, $path . '->if');
Severity: Minor
Found in src/Schema.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 jsonSerialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    #[\ReturnTypeWillChange]
    public function jsonSerialize()
    {
        if ($this->__nestedObjects) {
            $result = $this->__arrayOfData;
Severity: Minor
Found in src/Structure/ObjectItemTrait.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 toArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function &toArray()
    {
        if (!isset($this->__propertyToData[Schema::DEFAULT_MAPPING])) {
            return $this->__arrayOfData;
        }
Severity: Minor
Found in src/Constraint/Properties.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 getDataKeyMap has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDataKeyMap($mapping = Schema::DEFAULT_MAPPING)
    {
        if (!isset($this->__dataKeyMaps[$mapping])) {
            $map = array();
            foreach ($this->__arrayOfData as $propertyName => $property) {
Severity: Minor
Found in src/Constraint/Properties.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 Iri::validationError($data);
Severity: Major
Found in src/Constraint/Format.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                    return Iri::validationError($data, Uri::IS_URI_REFERENCE);
    Severity: Major
    Found in src/Constraint/Format.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return count(explode('@', $data, 3)) === 2 ? null : 'Invalid email';
      Severity: Major
      Found in src/Constraint/Format.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return filter_var($data, FILTER_VALIDATE_EMAIL) ? null : 'Invalid email';
        Severity: Major
        Found in src/Constraint/Format.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return preg_match(Uri::HOSTNAME_REGEX, $data) ? null : 'Invalid hostname';
          Severity: Major
          Found in src/Constraint/Format.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return null;
            Severity: Major
            Found in src/Constraint/Format.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return self::jsonPointerError($data, true);
              Severity: Major
              Found in src/Constraint/Format.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return 'Missing scheme in URI';
                Severity: Major
                Found in src/Constraint/Format/Uri.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return filter_var($data, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? null : 'Invalid ipv4';
                  Severity: Major
                  Found in src/Constraint/Format.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return Uri::validationError($data, Uri::IS_URI_REFERENCE);
                    Severity: Major
                    Found in src/Constraint/Format.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return self::jsonPointerError($data);
                      Severity: Major
                      Found in src/Constraint/Format.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return 'Invalid hostname (too long)';
                        Severity: Major
                        Found in src/Constraint/Format.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return IdnHostname::validationError($data);
                          Severity: Major
                          Found in src/Constraint/Format.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return filter_var($data, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ? null : 'Invalid ipv6';
                            Severity: Major
                            Found in src/Constraint/Format.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                      return null;
                              Severity: Major
                              Found in src/Constraint/Format/Uri.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                    return 'Malformed host in URI: ' . $host;
                                Severity: Major
                                Found in src/Constraint/Format/Uri.php - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language