gdbots/ncr-php

View on GitHub

Showing 92 of 92 total issues

Method getNodes has 44 lines of code (exceeds 25 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

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

        public function getNodes(array $nodeRefs, bool $consistent = false, array $context = []): array
        {
            if (empty($nodeRefs)) {
                return [];
            }
    Severity: Minor
    Found in src/Repository/MemoizingNcr.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 getClient has 42 lines of code (exceeds 25 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 1 hr to fix

      Function handleRequest has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function handleRequest(Message $request, Pbjx $pbjx): Message
          {
              $consistent = $request->get('consistent_read');
              $response = $this->createGetNodeResponse($request, $pbjx);
              $context = ['causator' => $request];
      Severity: Minor
      Found in src/GetNodeRequestHandler.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 createQuery has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          final public function createQuery(IndexQuery $query): array
          {
              $filterables = $this->getFilterableAttributes();
              $params = [
                  'IndexName'                 => $this->getName(),
      Severity: Minor
      Found in src/Repository/DynamoDb/AbstractIndex.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 getItems has a Cognitive Complexity of 13 (exceeds 5 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

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

          public function publishNode(Message $command, ?\DateTimeZone $localTimeZone = null): void
          {
              if (!$this->node::schema()->hasMixin('gdbots:ncr:mixin:publishable')) {
                  throw new InvalidArgumentException(
                      "Node [{$this->nodeRef}] must have [gdbots:ncr:mixin:publishable]."
      Severity: Minor
      Found in src/Aggregate.php - About 1 hr to fix

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

            public function handleRequest(Message $request, Pbjx $pbjx): Message
            {
                $consistent = $request->get('consistent_read');
                $response = $this->createGetNodeResponse($request, $pbjx);
                $context = ['causator' => $request];
        Severity: Minor
        Found in src/GetNodeRequestHandler.php - About 1 hr to fix

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

              protected function applyDateFilters(Message $request, ParsedQuery $parsedQuery): void
              {
                  $required = BoolOperator::REQUIRED;
          
                  $dateFilters = [
          Severity: Minor
          Found in src/Search/Elastica/QueryFactory.php - About 1 hr to fix

            Method hasNode has 36 lines of code (exceeds 25 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 1 hr to fix

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

                  final public function getNode(NodeRef $nodeRef, bool $consistent = false, array $context = []): Message
                  {
                      $cacheKey = $this->getCacheKey($nodeRef, $context);
                      $cacheItem = null;
              
              
              Severity: Minor
              Found in src/Repository/Psr6Ncr.php - About 1 hr to fix

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

                    public function getNode(NodeRef $nodeRef, bool $consistent = false, array $context = []): Message
                    {
                        $context = $this->enrichContext(__FUNCTION__, $context);
                        $tableName = $this->tableManager->getNodeTableName($nodeRef->getQName(), $context);
                
                
                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 updateNode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function updateNode(Message $command): void
                    {
                        /** @var NodeRef $nodeRef */
                        $nodeRef = $command->get('node_ref');
                        $this->assertNodeRefMatches($nodeRef);
                Severity: Minor
                Found in src/Aggregate.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

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

                    public function pipeNodes(SchemaQName $qname, array $context = []): \Generator
                    {
                        $context = $this->enrichContext(__FUNCTION__, $context);
                        $context['node_refs_only'] = false;
                        $generator = $this->doPipeNodes($qname, $context);
                Severity: Major
                Found in src/Repository/DynamoDb/DynamoDbNcr.php and 1 other location - About 1 hr to fix
                src/Repository/DynamoDb/DynamoDbNcr.php on lines 455..470

                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 107.

                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

                    public function pipeNodeRefs(SchemaQName $qname, array $context = []): \Generator
                    {
                        $context = $this->enrichContext(__FUNCTION__, $context);
                        $context['node_refs_only'] = true;
                        $generator = $this->doPipeNodes($qname, $context);
                Severity: Major
                Found in src/Repository/DynamoDb/DynamoDbNcr.php and 1 other location - About 1 hr to fix
                src/Repository/DynamoDb/DynamoDbNcr.php on lines 438..453

                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 107.

                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

                Method deleteNode has 32 lines of code (exceeds 25 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 1 hr to fix

                  Function publishNode has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function publishNode(Message $command, ?\DateTimeZone $localTimeZone = null): void
                      {
                          if (!$this->node::schema()->hasMixin('gdbots:ncr:mixin:publishable')) {
                              throw new InvalidArgumentException(
                                  "Node [{$this->nodeRef}] must have [gdbots:ncr:mixin:publishable]."
                  Severity: Minor
                  Found in src/Aggregate.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 createIndex has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      final public function createIndex(Client $client, SchemaQName $qname, array $context = []): Index
                      {
                          static $created = [];
                  
                          $indexName = $this->getIndexName($qname, $context);
                  Severity: Minor
                  Found in src/Search/Elastica/IndexManager.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 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
                      Severity
                      Category
                      Status
                      Source
                      Language