swaggest/php-json-schema

View on GitHub

Showing 89 of 92 total issues

Function processEnum has a Cognitive Complexity of 19 (exceeds 5 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 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 resolveReference has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function resolveReference($referencePath)
    {
        if ($this->resolutionScope) {
            $referencePath = Helper::resolveURI($this->resolutionScope, $referencePath);
        }
Severity: Major
Found in src/RefResolver.php - About 2 hrs to fix

    Method processNumeric has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function processNumeric($data, $path)
        {
            if ($this->multipleOf !== null) {
                $div = $data / $this->multipleOf;
                if ($div != (int)$div && ($div = $data * (1 / $this->multipleOf)) && ($div != (int)$div)) {
    Severity: Major
    Found in src/Schema.php - About 2 hrs to fix

      Wrapper has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Wrapper implements SchemaContract, MetaHolder, SchemaExporter, \JsonSerializable
      {
          /** @var Schema */
          private $schema;
      
      
      Severity: Minor
      Found in src/Wrapper.php - About 2 hrs to fix

        Function isValid has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function isValid($types, $data, $version)
            {
                if (!is_array($types)) {
                    $types = array($types);
                }
        Severity: Minor
        Found in src/Constraint/Type.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 processString has a Cognitive Complexity of 16 (exceeds 5 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 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 validationError has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function validationError($data, $options = 0)
            {
                if ($options === Uri::IS_URI_TEMPLATE) {
                    $opened = false;
                    for ($i = 0; $i < strlen($data); ++$i) {
        Severity: Minor
        Found in src/Constraint/Format/Uri.php - About 2 hrs to fix

          Function preProcessReferences has a Cognitive Complexity of 15 (exceeds 5 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

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

              public static function readString($types, &$data)
              {
                  if (!is_array($types)) {
                      $types = array($types);
                  }
          Severity: Minor
          Found in src/Constraint/Type.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 processOneOf has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              private function processOneOf($data, Context $options, $path)
              {
                  $successes = 0;
                  $failures = '';
                  $subErrors = [];
          Severity: Minor
          Found in src/Schema.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 process has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function process(Context $options, $encoding, $mediaType, $data, $import = true)
              {
                  if ($import) {
                      if ($encoding !== null) {
                          switch ($encoding) {
          Severity: Minor
          Found in src/Constraint/Content.php - About 1 hr to fix

            Method processOneOf has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

              Function processConst has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function processConst($data, $path)
                  {
                      if ($this->const !== $data &&
                          !( // Int and float equality.
                              (is_int($this->const) || is_float($this->const)) &&
              Severity: Minor
              Found in src/Schema.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 validationError has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function validationError($format, $data)
                  {
                      switch ($format) {
                          case self::DATE_TIME:
                              return self::dateTimeError($data);
              Severity: Minor
              Found in src/Constraint/Format.php - About 1 hr to fix

                Function resolveURI has a Cognitive Complexity of 13 (exceeds 5 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

                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 jsonSerialize has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    #[\ReturnTypeWillChange]
                    public function jsonSerialize()
                    {
                        $result = new \stdClass();
                        $schema = static::schema();
                Severity: Minor
                Found in src/Structure/ClassStructureTrait.php - About 1 hr to fix

                  Method provider has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private static function provider($path)
                      {
                          $testCases = array();
                  
                          if ($handle = opendir($path)) {
                  Severity: Minor
                  Found in benchmarks/Draft7Bench.php - About 1 hr to fix

                    Method provider has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private static function provider($path)
                        {
                            $testCases = array();
                    
                            if ($handle = opendir($path)) {
                    Severity: Minor
                    Found in benchmarks/AjvSchemasBench.php - About 1 hr to fix

                      Method isValid has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function isValid($types, $data, $version)
                          {
                              if (!is_array($types)) {
                                  $types = array($types);
                              }
                      Severity: Minor
                      Found in src/Constraint/Type.php - About 1 hr to fix

                        Method readString has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function readString($types, &$data)
                            {
                                if (!is_array($types)) {
                                    $types = array($types);
                                }
                        Severity: Minor
                        Found in src/Constraint/Type.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language