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 makeObjectItem has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function makeObjectItem(Context $options = null)
    {
        if (null === $this->objectItemClass) {
            return new ObjectItem();
        } else {
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 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

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

    public static function padLines($with, $text, $skipFirst = true)
    {
        $lines = explode("\n", $text);
        foreach ($lines as $index => $line) {
            if ($skipFirst && !$index) {
Severity: Minor
Found in src/Helper.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 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 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 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 '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 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 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 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 Uri::validationError($data, Uri::IS_URI_TEMPLATE);
                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 'Invalid fragment: unescaped backslash';
                    Severity: Major
                    Found in src/Constraint/Format/Uri.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return self::regexError($data);
                      Severity: Major
                      Found in src/Constraint/Format.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

                          Avoid too many return statements within this method.
                          Open

                                          return 'Invalid path: unescaped backslash';
                          Severity: Major
                          Found in src/Constraint/Format/Uri.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 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 'Invalid hostname (too long)';
                                Severity: Major
                                Found in src/Constraint/Format.php - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language