swaggest/php-json-schema

View on GitHub

Showing 87 of 92 total issues

Function processObject has a Cognitive Complexity of 271 (exceeds 5 allowed). Consider refactoring.
Open

    private function processObject($data, Context $options, $path, $result = null)
    {
        $import = $options->import;

        $hasMapping = $this->properties !== null && isset($this->properties->__dataToProperty[$options->mapping]);
Severity: Minor
Found in src/Schema.php - About 5 days 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 unicodeValidationError has 625 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function unicodeValidationError($data, &$sanitized = null)
    {
        static $excluded = array(
            "\xD9\x80" => '\u0640',
            "\xDF\xBA" => '\u07FA',
Severity: Major
Found in src/Constraint/Format/Iri.php - About 3 days to fix

    File Schema.php has 1068 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Swaggest\JsonSchema;
    
    
    
    Severity: Major
    Found in src/Schema.php - About 2 days to fix

      File Iri.php has 664 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace Swaggest\JsonSchema\Constraint\Format;
      
      class Iri
      Severity: Major
      Found in src/Constraint/Format/Iri.php - About 1 day to fix

        Method processObject has 293 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function processObject($data, Context $options, $path, $result = null)
            {
                $import = $options->import;
        
                $hasMapping = $this->properties !== null && isset($this->properties->__dataToProperty[$options->mapping]);
        Severity: Major
        Found in src/Schema.php - About 1 day to fix

          Function process has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
          Open

              public function process($data, Context $options, $path = '#', $result = null)
              {
                  $origData = $data;
                  $import = $options->import;
          
          
          Severity: Minor
          Found in src/Schema.php - About 1 day 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 resolveReference has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
          Open

              public function resolveReference($referencePath)
              {
                  if ($this->resolutionScope) {
                      $referencePath = Helper::resolveURI($this->resolutionScope, $referencePath);
                  }
          Severity: Minor
          Found in src/RefResolver.php - About 7 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 provider has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function provider($path)
              {
                  $testCases = array();
          
                  if ($handle = opendir($path)) {
          Severity: Minor
          Found in benchmarks/AjvSchemasBench.php - About 6 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 provider has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function provider($path)
              {
                  $testCases = array();
          
                  if ($handle = opendir($path)) {
          Severity: Minor
          Found in benchmarks/Draft7Bench.php - About 6 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 validationError has a Cognitive Complexity of 39 (exceeds 5 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 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

          Schema has 42 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Schema extends JsonSchema implements MetaHolder, SchemaContract, HasDefault
          {
              const ENUM_NAMES_PROPERTY = 'x-enum-names';
              const CONST_PROPERTY = 'const';
              const DEFAULT_PROPERTY = 'default';
          Severity: Minor
          Found in src/Schema.php - About 5 hrs to fix

            Function processArray has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
            Open

                private function processArray($data, Context $options, $path, $result)
                {
                    $count = count($data);
                    if (!$options->skipValidation) {
                        if ($this->minItems !== null && $count < $this->minItems) {
            Severity: Minor
            Found in src/Schema.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 process has a Cognitive Complexity of 32 (exceeds 5 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 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 processNumeric has a Cognitive Complexity of 30 (exceeds 5 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: Minor
            Found in src/Schema.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

            Method process has 107 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function process($data, Context $options, $path = '#', $result = null)
                {
                    $origData = $data;
                    $import = $options->import;
            
            
            Severity: Major
            Found in src/Schema.php - About 4 hrs to fix

              Function jsonSerialize has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
              Open

                  #[\ReturnTypeWillChange]
                  public function jsonSerialize()
                  {
                      $result = new \stdClass();
                      $schema = static::schema();
              Severity: Minor
              Found in src/Structure/ClassStructureTrait.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

              Method processArray has 69 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function processArray($data, Context $options, $path, $result)
                  {
                      $count = count($data);
                      if (!$options->skipValidation) {
                          if ($this->minItems !== null && $count < $this->minItems) {
              Severity: Major
              Found in src/Schema.php - About 2 hrs to fix

                Function getSchemaPointers has a Cognitive Complexity of 20 (exceeds 5 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 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 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
                  Severity
                  Category
                  Status
                  Source
                  Language