gdbots/pbj-php

View on GitHub

Showing 68 of 77 total issues

Function create has a Cognitive Complexity of 272 (exceeds 5 allowed). Consider refactoring.
Open

    public static function create(string $string, bool $allowSlashes = false): string
    {
        $slug = '';
        $string = html_entity_decode($string, ENT_QUOTES);

Severity: Minor
Found in src/Util/SlugUtil.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

File AbstractMessage.php has 447 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare(strict_types=1);

namespace Gdbots\Pbj;

Severity: Minor
Found in src/AbstractMessage.php - About 6 hrs to fix

    Function doUnmarshal has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        private function doUnmarshal(array $data): Message
        {
            Assertion::keyIsset(
                $data['M'],
                Schema::PBJ_FIELD_NAME,
    Severity: Minor
    Found in src/Marshaler/DynamoDb/ItemMarshaler.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

    AbstractMessage has 45 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class AbstractMessage implements Message, \JsonSerializable
    {
        /** @var Schema[] */
        private static array $schemas = [];
        private static ?PhpArraySerializer $serializer = null;
    Severity: Minor
    Found in src/AbstractMessage.php - About 6 hrs to fix

      File Field.php has 364 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      declare(strict_types=1);
      
      namespace Gdbots\Pbj;
      
      
      Severity: Minor
      Found in src/Field.php - About 4 hrs to fix

        Function xmlEscape has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function xmlEscape(string $str): string
            {
                // array used to figure what number to decrement from character order value
                // according to number of characters used to map unicode to ascii by utf-8
                $decrement = [];
        Severity: Minor
        Found in src/Util/StringUtil.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

        Field has 34 functions (exceeds 20 allowed). Consider refactoring.
        Open

        final class Field implements \JsonSerializable
        {
            /**
             * Regular expression pattern for matching a valid field name.  The pattern allows
             * for camelCase fields name but snake_case is recommend.
        Severity: Minor
        Found in src/Field.php - About 4 hrs to fix

          Function doUnmarshal has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              private function doUnmarshal(array $data): Message
              {
                  $schemaId = SchemaId::fromString((string)$data[Schema::PBJ_FIELD_NAME]);
                  $className = MessageResolver::resolveId($schemaId);
                  $message = new $className();
          Severity: Minor
          Found in src/Marshaler/Elastica/DocumentMarshaler.php - About 3 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 doDeserialize has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              private function doDeserialize(array $data): Message
              {
                  $schemaId = SchemaId::fromString((string)$data[Schema::PBJ_FIELD_NAME]);
                  $className = MessageResolver::resolveId($schemaId);
                  $message = new $className();
          Severity: Minor
          Found in src/Serializer/PhpArraySerializer.php - About 3 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

          File ItemMarshaler.php has 325 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          declare(strict_types=1);
          
          namespace Gdbots\Pbj\Marshaler\DynamoDb;
          
          
          Severity: Minor
          Found in src/Marshaler/DynamoDb/ItemMarshaler.php - About 3 hrs to fix

            File URLUtil.php has 311 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            declare(strict_types=1);
            
            namespace Gdbots\Pbj\Util;
            
            
            Severity: Minor
            Found in src/Util/URLUtil.php - About 3 hrs to fix

              File MappingBuilder.php has 301 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              declare(strict_types=1);
              
              namespace Gdbots\Pbj\Marshaler\Elastica;
              
              
              Severity: Minor
              Found in src/Marshaler/Elastica/MappingBuilder.php - About 3 hrs to fix

                Method create has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function create(string $string, bool $allowSlashes = false): string
                    {
                        $slug = '';
                        $string = html_entity_decode($string, ENT_QUOTES);
                
                
                Severity: Major
                Found in src/Util/SlugUtil.php - About 3 hrs to fix

                  Method doUnmarshal has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function doUnmarshal(array $data): Message
                      {
                          Assertion::keyIsset(
                              $data['M'],
                              Schema::PBJ_FIELD_NAME,
                  Severity: Major
                  Found in src/Marshaler/DynamoDb/ItemMarshaler.php - About 2 hrs to fix

                    Method guard has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function guard(mixed $value, Field $field): void
                        {
                            $fieldName = $field->getName();
                            Assertion::string($value, null, $fieldName);
                    
                    
                    Severity: Major
                    Found in src/Type/AbstractStringType.php - About 2 hrs to fix

                      Method xmlEscape has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function xmlEscape(string $str): string
                          {
                              // array used to figure what number to decrement from character order value
                              // according to number of characters used to map unicode to ascii by utf-8
                              $decrement = [];
                      Severity: Major
                      Found in src/Util/StringUtil.php - About 2 hrs to fix

                        Function buildSchema has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function buildSchema(Schema $schema): array
                            {
                                $properties = [];
                        
                                if ($this->getPathDepth() > static::MAX_PATH_DEPTH) {
                        Severity: Minor
                        Found in src/Marshaler/Elastica/MappingBuilder.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

                        FieldBuilder has 23 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        final class FieldBuilder
                        {
                            private string $name;
                            private Type $type;
                            private ?FieldRule $rule = null;
                        Severity: Minor
                        Found in src/FieldBuilder.php - About 2 hrs to fix

                          Function validate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                          Open

                              final public function validate(bool $strict = false, bool $recursive = false): static
                              {
                                  if (!$strict && $this->isFrozen()) {
                                      return $this;
                                  }
                          Severity: Minor
                          Found in src/AbstractMessage.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 __construct has 18 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  string    $name,
                                  Type      $type,
                                  FieldRule $rule,
                                  bool      $required = false,
                                  ?int      $minLength = null,
                          Severity: Major
                          Found in src/Field.php - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language