gdbots/pbjx-php

View on GitHub

Showing 107 of 107 total issues

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

        foreach (['s16', 's32', 's64', 's128', 's256'] as $shard) {
            if (isset($context[$shard])) {
                $params['ExpressionAttributeNames']["#{$shard}"] = $shard;
                $params['ExpressionAttributeValues'][":v_{$shard}"] = ['N' => (string)((int)$context[$shard])];
                $filterExpressions[] = "#{$shard} = :v_{$shard}";
Severity: Minor
Found in src/EventStore/DynamoDb/DynamoDbEventStore.php and 1 other location - About 50 mins to fix
src/EventStore/DynamoDb/DynamoDbEventStore.php on lines 450..456

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

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 getStreamSlice has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function getStreamSlice(StreamId $streamId, ?Microtime $since = null, int $count = 25, bool $forward = true, bool $consistent = false, array $context = []): StreamSlice;
Severity: Minor
Found in src/EventStore/EventStore.php - About 45 mins to fix

    Method getStreamSlice has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function getStreamSlice(StreamId $streamId, ?Microtime $since = null, int $count = 25, bool $forward = true, bool $consistent = false, array $context = []): StreamSlice
    Severity: Minor
    Found in src/EventStore/TwoPhaseCommitEventStore.php - About 45 mins to fix

      Method getStreamSlice has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          final public function getStreamSlice(StreamId $streamId, ?Microtime $since = null, int $count = 25, bool $forward = true, bool $consistent = false, array $context = []): StreamSlice
      Severity: Minor
      Found in src/EventStore/DynamoDb/DynamoDbEventStore.php - About 45 mins to fix

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

                DynamoDbClient $dynamoDbClient,
                string $tableName,
                SfnClient $sfnClient,
                string $stateMachineArn,
                EventDispatcher $dispatcher,
        Severity: Minor
        Found in src/Scheduler/DynamoDb/DynamoDbScheduler.php - About 45 mins to fix

          Method getStreamSlice has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function getStreamSlice(StreamId $streamId, ?Microtime $since = null, int $count = 25, bool $forward = true, bool $consistent = false, array $context = []): StreamSlice
          Severity: Minor
          Found in src/EventStore/InMemoryEventStore.php - About 45 mins to fix

            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/EventSearch/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

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

                private function checkClaims(): void
                {
                    if (!is_array($this->header)) {
                        throw new InvalidArgumentException('PbjxToken header encoding is invalid.');
                    }
            Severity: Minor
            Found in src/PbjxToken.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 searchEvents has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

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

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

                  public static function create(string $content, string $aud, string $kid, string $secret, array $options = []): self
              Severity: Minor
              Found in src/PbjxToken.php - About 35 mins to fix

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

                        Pbjx $pbjx,
                        DynamoDbClient $client,
                        string $tableName,
                        EventDispatcher $dispatcher,
                        ?LoggerInterface $logger = null
                Severity: Minor
                Found in src/EventStore/DynamoDb/DynamoDbEventStore.php - About 35 mins to fix

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

                      final public function searchEvents(Message $request, ParsedQuery $parsedQuery, Message $response, array $curies = [], array $context = []): void
                  Severity: Minor
                  Found in src/EventSearch/Elastica/ElasticaEventSearch.php - About 35 mins to fix

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

                        public function __construct(array $events = [], ?StreamId $streamId = null, bool $forward = true, bool $consistent = false, bool $hasMore = false)
                    Severity: Minor
                    Found in src/EventStore/StreamSlice.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/EventSearch/Elastica/ElasticaEventSearch.php - About 35 mins to fix

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

                            public function trigger(Message $message, string $suffix, ?PbjxEvent $event = null, bool $recursive = true, bool $throw = true): static;
                        Severity: Minor
                        Found in src/Pbjx.php - About 35 mins to fix

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

                              public function trigger(Message $message, string $suffix, ?PbjxEvent $event = null, bool $recursive = true, bool $throw = true): static
                          Severity: Minor
                          Found in src/SimplePbjx.php - About 35 mins to fix

                            Function indexEvents has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                final public function indexEvents(array $events, array $context = []): void
                                {
                                    if (empty($events)) {
                                        return;
                                    }
                            Severity: Minor
                            Found in src/EventSearch/Elastica/ElasticaEventSearch.php - About 35 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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                final public function run(int $maxRuntime = 300): void
                                {
                                    if ($this->isRunning) {
                                        $this->logger->notice(sprintf('Consumer [%s] is already running.', $this->consumerName));
                                        return;
                            Severity: Minor
                            Found in src/Consumer/AbstractConsumer.php - About 35 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 pipeEvents has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                final public function pipeEvents(StreamId $streamId, ?Microtime $since = null, ?Microtime $until = null, array $context = []): \Generator
                                {
                                    $context['stream_id'] = $streamId;
                                    $context = $this->enrichContext(__FUNCTION__, $context);
                                    $consistent = filter_var($context['consistent'] ?? true, FILTER_VALIDATE_BOOLEAN);
                            Severity: Minor
                            Found in src/EventStore/DynamoDb/DynamoDbEventStore.php - About 35 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 setResponse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function setResponse(Message $response): void
                                {
                                    if ($this->hasResponse()) {
                                        throw new LogicException('Response can only be set one time.');
                                    }
                            Severity: Minor
                            Found in src/Event/GetResponseEvent.php - About 35 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

                            Severity
                            Category
                            Status
                            Source
                            Language