gdbots/pbjx-php

View on GitHub

Showing 107 of 107 total issues

Method createStorage has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    final public function createStorage(array $context = []): void
    {
        $context = $this->enrichContext(__FUNCTION__, $context);

        if (isset($context['cluster'])) {
Severity: Minor
Found in src/EventSearch/Elastica/ElasticaEventSearch.php - About 1 hr to fix

    Method httpToVendor has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function httpToVendor(HttpCode $httpCode = HttpCode::HTTP_OK): Code
        {
            if ($httpCode->value < 400) {
                return Code::OK;
            }
    Severity: Minor
    Found in src/Util/StatusCodeUtil.php - About 1 hr to fix

      Method vendorToHttp has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function vendorToHttp(Code $code = Code::OK): HttpCode
          {
              if (Code::OK === $code) {
                  return HttpCode::HTTP_OK;
              }
      Severity: Minor
      Found in src/Util/StatusCodeUtil.php - About 1 hr to fix

        Method deleteEvent has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            final public function deleteEvent(Identifier $eventId, array $context = []): void
            {
                $context = $this->enrichContext(__FUNCTION__, $context);
                $tableName = $this->getTableNameForWrite($context);
                $key = $this->getItemKeyByEventId($eventId, $context);
        Severity: Minor
        Found in src/EventStore/DynamoDb/DynamoDbEventStore.php - About 1 hr to fix

          Method describeStorage has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              final public function describeStorage(array $context = []): string
              {
                  $context = $this->enrichContext(__FUNCTION__, $context);
          
                  if (isset($context['cluster'])) {
          Severity: Minor
          Found in src/EventSearch/Elastica/ElasticaEventSearch.php - About 1 hr to fix

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

                public function create(DynamoDbClient $client, string $tableName): void
                {
                    try {
                        $client->describeTable(['TableName' => $tableName]);
                        return;
            Severity: Minor
            Found in src/Scheduler/DynamoDb/SchedulerTable.php - About 1 hr to fix

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

                  final public function describeStorage(array $context = []): string
                  {
                      $context = $this->enrichContext(__FUNCTION__, $context);
              
                      if (isset($context['cluster'])) {
              Severity: Minor
              Found in src/EventSearch/Elastica/ElasticaEventSearch.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 createStorage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  final public function createStorage(array $context = []): void
                  {
                      $context = $this->enrichContext(__FUNCTION__, $context);
              
                      if (isset($context['cluster'])) {
              Severity: Minor
              Found in src/EventSearch/Elastica/ElasticaEventSearch.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 getStreamSlice has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getStreamSlice(StreamId $streamId, ?Microtime $since = null, int $count = 25, bool $forward = true, bool $consistent = false, array $context = []): StreamSlice
                  {
                      $key = $streamId->toString();
                      if (!isset($this->streams[$key])) {
                          return new StreamSlice([], $streamId, $forward, $consistent, false);
              Severity: Minor
              Found in src/EventStore/InMemoryEventStore.php - About 1 hr to fix

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

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

                      public function copyContext(Message $from, Message $to): static
                      {
                          if ($to->isFrozen()) {
                              return $this;
                          }
                  Severity: Minor
                  Found in src/SimplePbjx.php - About 1 hr to fix

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

                        protected function getItemKeyByEventId(Identifier $eventId, array $context = []): ?array
                        {
                            $tableName = $this->getTableNameForRead($context);
                            $params = [
                                'TableName'                 => $tableName,
                    Severity: Minor
                    Found in src/EventStore/DynamoDb/DynamoDbEventStore.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 deleteEvent has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        final public function deleteEvent(Identifier $eventId, array $context = []): void
                        {
                            $context = $this->enrichContext(__FUNCTION__, $context);
                            $tableName = $this->getTableNameForWrite($context);
                            $key = $this->getItemKeyByEventId($eventId, $context);
                    Severity: Minor
                    Found in src/EventStore/DynamoDb/DynamoDbEventStore.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 getNestedMessages has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function getNestedMessages(Message $message, Schema $schema): array
                        {
                            $messages = [];
                    
                            foreach ($schema->getFields() as $field) {
                    Severity: Minor
                    Found in src/SimplePbjx.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 applyDateFilters has 27 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/EventSearch/Elastica/QueryFactory.php - About 1 hr to fix

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

                          public static function create(string $content, string $aud, string $kid, string $secret, array $options = []): self
                          {
                              $header = [
                                  'alg' => self::ALGO,
                                  'typ' => 'JWT',
                      Severity: Minor
                      Found in src/PbjxToken.php - About 1 hr to fix

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

                            public function __construct(Pbjx $pbjx, array $streams = [])
                            {
                                $this->pbjx = $pbjx;
                        
                                foreach ($streams as $streamId => $events) {
                        Severity: Minor
                        Found in src/EventStore/InMemoryEventStore.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 dispatch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function dispatch(Message $event, string $eventName): void
                            {
                                foreach ($this->dispatcher->getListeners($eventName) as $listener) {
                                    try {
                                        call_user_func($listener, $event, $this->pbjx);
                        Severity: Minor
                        Found in src/SimpleEventBus.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 copyContext has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function copyContext(Message $from, Message $to): static
                            {
                                if ($to->isFrozen()) {
                                    return $this;
                                }
                        Severity: Minor
                        Found in src/SimplePbjx.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

                        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 240..246

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language