gdbots/ncr-php

View on GitHub

Showing 92 of 92 total issues

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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  try {
                      $response = $client->addDocuments($documents);
                      if (!$response->isOk()) {
                          throw new \Exception($response->getStatus() . '::' . $response->getError());
                      }
          Severity: Major
          Found in src/Search/Elastica/ElasticaNcrSearch.php and 1 other location - About 1 hr to fix
          src/Search/Elastica/ElasticaNcrSearch.php on lines 199..214

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 101.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  try {
                      $response = $client->deleteDocuments($documents);
                      if (!$response->isOk()) {
                          throw new \Exception($response->getStatus() . '::' . $response->getError());
                      }
          Severity: Major
          Found in src/Search/Elastica/ElasticaNcrSearch.php and 1 other location - About 1 hr to fix
          src/Search/Elastica/ElasticaNcrSearch.php on lines 139..154

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 101.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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