swaggest/php-json-schema

View on GitHub

Showing 89 of 92 total issues

Method getSchemaPointers has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getSchemaPointers($path, $isURIFragmentId = false)
    {
        $items = explode('->', $path);
        unset($items[0]);
        $result = array();
Severity: Minor
Found in src/Path/PointerUtil.php - About 1 hr to fix

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

        public function getFailedSubSchema(Schema $schema)
        {
            $schemaPointer = $this->getSchemaPointer();
            if ($schema instanceof ObjectItemContract) {
                $refs = $schema->getFromRefs();
    Severity: Minor
    Found in src/InvalidValue.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 isValid has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function isValid(array $data)
        {
            $index = array();
            foreach ($data as $value) {
                if (is_array($value) || $value instanceof \stdClass) {
    Severity: Minor
    Found in src/Constraint/UniqueItems.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 preProcessReferences has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function preProcessReferences($data, Context $options, $nestingLevel = 0)
        {
            if ($nestingLevel > 200) {
                throw new Exception('Too deep nesting level', Exception::DEEP_NESTING);
            }
    Severity: Minor
    Found in src/RefResolver.php - About 1 hr to fix

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

          private function processString($data, $path)
          {
              if ($this->minLength !== null) {
                  if (mb_strlen($data, 'UTF-8') < $this->minLength) {
                      $this->fail((new StringException('String is too short', StringException::TOO_SHORT))
      Severity: Minor
      Found in src/Schema.php - About 1 hr to fix

        Function getFromRefPath has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function getFromRefPath()
            {
                if ($this->__refPath === null) {
                    $this->__refPath = '';
                    if ($this->__fromRef) {
        Severity: Minor
        Found in src/Structure/ObjectItemTrait.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 resolveURI has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function resolveURI($parent, $current)
            {
                if ($current === '') {
                    return $parent;
                }
        Severity: Minor
        Found in src/Helper.php - About 1 hr to fix

          Method processAnyOf has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function processAnyOf($data, Context $options, $path)
              {
                  $successes = 0;
                  $failures = '';
                  $subErrors = [];
          Severity: Minor
          Found in src/Schema.php - About 1 hr to fix

            Method processEnum has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function processEnum($data, $path = '#')
                {
                    $enumOk = false;
                    foreach ($this->enum as $item) {
                        if ($item === $data ||
            Severity: Minor
            Found in src/Schema.php - About 1 hr to fix

              Function dateTimeError has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function dateTimeError($data)
                  {
                      if (!preg_match('/^' . self::$dateRegexPart . 'T' . self::$timeRegexPart . '$/i', $data)) {
                          return 'Invalid date-time format: ' . $data;
                      }
              Severity: Minor
              Found in src/Constraint/Format.php - About 55 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 unicodeNextChar has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  private static function unicodeNextChar($string, &$pointer)
                  {
                      if (!isset($string[$pointer])) return false;
                      $char = ord($string[$pointer]);
                      if ($char < 128) {
              Severity: Minor
              Found in src/Constraint/Format/Iri.php - About 55 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 deeply nested control flow statements.
              Open

                                              if (isset($test->schemas)) {
                                                  foreach ($test->schemas as $i => $schema) {
                                                      $testCases[$name . '_' . $i] = array(
                                                          'schema' => $schema,
                                                          'data' => $case->data,
              Severity: Major
              Found in benchmarks/Draft7Bench.php - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                                if ($result->__validateOnSet) {
                                                    $result->__validateOnSet = false;
                                                    /** @noinspection PhpUnusedLocalVariableInspection */
                                                    /* todo check performance impact
                                                    $validateOnSetHandler = new ScopeExit(function () use ($result) {
                Severity: Major
                Found in src/Schema.php - About 45 mins to fix

                  Function in has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function in($data, Context $options = null)
                      {
                          if (null !== $this->__booleanSchema) {
                              if ($this->__booleanSchema) {
                                  return $data;
                  Severity: Minor
                  Found in src/Schema.php - About 45 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 deeply nested control flow statements.
                  Open

                                                  if (isset($test->schemas)) {
                                                      foreach ($test->schemas as $i => $schema) {
                                                          $testCases[$name . '_' . $i] = array(
                                                              'schema' => $schema,
                                                              'data' => $case->data,
                  Severity: Major
                  Found in benchmarks/AjvSchemasBench.php - About 45 mins to fix

                    Function import has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function import($data, Context $options = null)
                        {
                            if (null === $options) {
                                $options = new Context();
                            }
                    Severity: Minor
                    Found in src/Schema.php - About 45 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 processAnyOf has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function processAnyOf($data, Context $options, $path)
                        {
                            $successes = 0;
                            $failures = '';
                            $subErrors = [];
                    Severity: Minor
                    Found in src/Schema.php - About 45 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

                    Consider simplifying this complex logical expression.
                    Open

                            if ($this->const !== $data &&
                                !( // Int and float equality.
                                    (is_int($this->const) || is_float($this->const)) &&
                                    (is_int($data) || is_float($data)) &&
                                    $this->const == $data
                    Severity: Major
                    Found in src/Schema.php - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                                  if ($item === $data ||
                                      ( // Int and float equality check.
                                          (is_int($item) || is_float($item)) &&
                                          (is_int($data) || is_float($data)) &&
                                          $item == $data
                      Severity: Major
                      Found in src/Schema.php - About 40 mins to fix

                        Method process has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            public static function process(Context $options, $encoding, $mediaType, $data, $import = true)
                        Severity: Minor
                        Found in src/Constraint/Content.php - About 35 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language