gdbots/ncr-php

View on GitHub

Showing 72 of 92 total issues

Method getItems has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getItems(): array
    {
        $allItems = [];

        while ($this->queue) {
Severity: Minor
Found in src/Repository/DynamoDb/BatchGetItemRequest.php - About 1 hr to fix

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

        public static function getSubscribedEvents(): array
        {
            return [
                'gdbots:ncr:event:node-created'           => 'onNodeCreated',
                'gdbots:ncr:event:node-deleted'           => 'onNodeDeleted',
    Severity: Minor
    Found in src/NcrProjector.php - About 1 hr to fix

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

          protected function ensureSlugIsAvailable(PbjxEvent $pbjxEvent, NodeRef $nodeRef, string $slug): void
          {
              $pbjx = $pbjxEvent::getPbjx();
              $command = $pbjxEvent->getMessage();
      
      
      Severity: Minor
      Found in src/UniqueNodeValidator.php - About 1 hr to fix

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

            public function getNodes(array $nodeRefs, bool $consistent = false, array $context = []): array
            {
                $context = $this->enrichContext(__FUNCTION__, $context);
        
                if (empty($nodeRefs)) {
        Severity: Minor
        Found in src/Repository/DynamoDb/DynamoDbNcr.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 putNode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function putNode(Message $node, ?string $expectedEtag = null, array $context = []): void
            {
                $node->freeze();
                $nodeRef = $node->generateNodeRef();
        
        
        Severity: Minor
        Found in src/Repository/DynamoDb/DynamoDbNcr.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 prepareCommands has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            private function prepareCommands(): array
            {
                $batches = array_chunk($this->queue, $this->batchSize);
                $this->queue = [];
        
        
        Severity: Minor
        Found in src/Repository/DynamoDb/BatchGetItemRequest.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 addEmbeddedNodeRefs has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function addEmbeddedNodeRefs(array $messages, array $paths): void
            {
                $nodeRefs = [];
        
                if (array_is_list($paths)) {
        Severity: Minor
        Found in src/NcrLazyLoader.php - About 1 hr to fix

          Method addEmbeddedNodeRefs has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function addEmbeddedNodeRefs(array $messages, array $paths, string $namespace = self::DEFAULT_NAMESPACE): void
              {
                  $nodeRefs = [];
          
                  if (array_is_list($paths)) {
          Severity: Minor
          Found in src/NcrPreloader.php - About 1 hr to fix

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

                protected function getNode(PbjxEvent $pbjxEvent): Message
                {
                    $command = $pbjxEvent->getMessage();
                    Assertion::true($command->has('node_ref'), 'Field "node_ref" is required.', 'node_ref');
            
            
            Severity: Minor
            Found in src/NodeCommandBinder.php - About 1 hr to fix

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

                  public function deleteNode(NodeRef $nodeRef, array $context = []): void
                  {
                      $context = $this->enrichContext(__FUNCTION__, $context);
                      $tableName = $this->tableManager->getNodeTableName($nodeRef->getQName(), $context);
              
              
              Severity: Minor
              Found in src/Repository/DynamoDb/DynamoDbNcr.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 hasNode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function hasNode(NodeRef $nodeRef, bool $consistent = false, array $context = []): bool
                  {
                      $context = $this->enrichContext(__FUNCTION__, $context);
                      $tableName = $this->tableManager->getNodeTableName($nodeRef->getQName(), $context);
              
              
              Severity: Minor
              Found in src/Repository/DynamoDb/DynamoDbNcr.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 hasNode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  final public function hasNode(NodeRef $nodeRef, bool $consistent = false, array $context = []): bool
                  {
                      if (!$consistent) {
                          $cacheKey = $this->getCacheKey($nodeRef, $context);
                          $cacheItem = $this->cache->getItem($cacheKey);
              Severity: Minor
              Found in src/Repository/Psr6Ncr.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 lockNode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function lockNode(Message $command): void
                  {
                      if (!$this->node::schema()->hasMixin('gdbots:ncr:mixin:lockable')) {
                          throw new InvalidArgumentException(
                              "Node [{$this->nodeRef}] must have [gdbots:ncr:mixin:lockable]."
              Severity: Minor
              Found in src/Aggregate.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

              Method __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      SchemaQName $qname,
                      string $alias,
                      string $value,
                      int $count = 25,
                      ?string $cursor = null,
              Severity: Major
              Found in src/IndexQuery.php - About 50 mins to fix

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

                    public function getNode(NodeRef $nodeRef): Message
                    {
                        if (!$this->hasNode($nodeRef)) {
                            if ($this->lazyLoader->hasNodeRef($nodeRef)) {
                                $this->disablePruning = true;
                Severity: Minor
                Found in src/NcrCache.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 getClient has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getClient(string $cluster = 'default'): Client
                    {
                        if (isset($this->clients[$cluster])) {
                            return $this->clients[$cluster];
                        }
                Severity: Minor
                Found in src/Search/Elastica/ClientManager.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

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

                    public function searchNodes(Message $request, ParsedQuery $parsedQuery, Message $response, array $qnames = [], array $context = []): void;
                Severity: Minor
                Found in src/NcrSearch.php - About 35 mins to fix

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

                          DynamoDbClient $client,
                          EventDispatcher $dispatcher,
                          TableManager $tableManager,
                          array $config = [],
                          ?LoggerInterface $logger = null
                  Severity: Minor
                  Found in src/Repository/DynamoDb/DynamoDbNcr.php - About 35 mins to fix

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

                            ClientManager    $clientManager,
                            EventDispatcher  $dispatcher,
                            IndexManager     $indexManager,
                            ?LoggerInterface $logger = null,
                            ?string          $timeout = null
                    Severity: Minor
                    Found in src/Search/Elastica/ElasticaNcrSearch.php - About 35 mins to fix

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

                          public function searchNodes(Message $request, ParsedQuery $parsedQuery, Message $response, array $qnames = [], array $context = []): void
                      Severity: Minor
                      Found in src/Search/Elastica/ElasticaNcrSearch.php - About 35 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language