gdbots/pbjx-bundle-php

View on GitHub

Showing 61 of 61 total issues

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

    protected function configure(): void
    {
        $provider = $this->container->getParameter('gdbots_pbjx.event_store.provider');

        $this
Severity: Minor
Found in src/Command/TailEventsCommand.php - About 1 hr to fix

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

        public function process(ContainerBuilder $container): void
        {
            $locator = $container->getDefinition('gdbots_pbjx.service_locator');
    
            foreach ($container->findTaggedServiceIds('pbjx.handler') as $id => $attributes) {
    Severity: Minor
    Found in src/DependencyInjection/Compiler/RegisterHandlersPass.php - About 1 hr to fix

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

          protected function reindex(array $events, array $context, bool $skipErrors): int
          {
              $count = count($events);
              if ($count === 0) {
                  return 0;
      Severity: Minor
      Found in src/Command/ReindexEventsCommand.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 handleException has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function handleException(Message $envelope, Request $request, Message $message, \Throwable $exception): Message
          {
              if ($exception instanceof HttpExceptionInterface) {
                  $httpCode = HttpCode::tryFrom($exception->getStatusCode()) ?: HttpCode::UNKNOWN;
                  $code = StatusCodeUtil::httpToVendor($httpCode);
      Severity: Minor
      Found in src/Controller/PbjxController.php - About 1 hr to fix

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

            protected function execute(InputInterface $input, OutputInterface $output): int
            {
                $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
                $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
                $errOutput->setVerbosity(OutputInterface::VERBOSITY_NORMAL);
        Severity: Minor
        Found in src/Command/TailEventsCommand.php - About 1 hr to fix

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

                  $this
                      ->setDescription('Handles pbjx messages (command, event, request) and returns an envelope with the result')
                      ->setHelp(<<<EOF
          The <info>%command.name%</info> command will create a single pbjx message using the json
          payload provided and return an envelope (also json) with the results.
          Severity: Major
          Found in src/Command/PbjxCommand.php and 1 other location - About 1 hr to fix
          src/Command/PbjxBatchCommand.php on lines 31..71

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

          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

                  $this
                      ->setDescription('Reads messages from a newline-delimited JSON file and processes them')
                      ->setHelp(<<<EOF
          The <info>%command.name%</info> command will read messages (pbj commands or events) from a
          newline-delimited JSON file and run pbjx->send or pbjx->publish.
          Severity: Major
          Found in src/Command/PbjxBatchCommand.php and 1 other location - About 1 hr to fix
          src/Command/PbjxCommand.php on lines 31..70

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

          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

          Consider simplifying this complex logical expression.
          Open

                  if (
                      null === ($class = $container->getDefinition($id)->getClass())
                      || !($r = $container->getReflectionClass($class, false))
                      || !$r->hasMethod($method)
                      || 1 > ($m = $r->getMethod($method))->getNumberOfParameters()
          Severity: Major
          Found in src/DependencyInjection/Compiler/RegisterListenersPass.php - About 1 hr to fix

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

                protected function execute(InputInterface $input, OutputInterface $output): int
                {
                    $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
                    $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
                    $errOutput->setVerbosity(OutputInterface::VERBOSITY_NORMAL);
            Severity: Minor
            Found in src/Command/TailEventsCommand.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 onKernelView has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function onKernelView(ViewEvent $event): void
                {
                    $envelope = $event->getControllerResult();
                    if (!$envelope instanceof EnvelopeV1) {
                        return;
            Severity: Minor
            Found in src/EventListener/EnvelopeListener.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 reindexBatch has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                protected function reindexBatch(SymfonyStyle $io, array $events, array $context, int $batch, bool $dryRun, bool $skipErrors): int
            Severity: Minor
            Found in src/Command/ReindexEventsCommand.php - About 45 mins to fix

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

                  protected function restrictBind(PbjxEvent $pbjxEvent, Message $message, array $restrictedFields, array $input): void
                  {
                      foreach ($restrictedFields as $field) {
                          if (!$message->has($field)) {
                              // this means whatever was in the input never made it to the message.
              Severity: Minor
              Found in src/MessageBinder.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 useInMemoryTransports has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function useInMemoryTransports(InputInterface $input, ?SymfonyStyle $io = null): void
                  {
                      if (!$input->hasOption('in-memory') || $input->getOption('in-memory')) {
                          $locator = $this->getPbjxServiceLocator();
                          if ($locator instanceof ContainerAwareServiceLocator) {
              Severity: Minor
              Found in src/Command/PbjxAwareCommandTrait.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

              Avoid too many return statements within this method.
              Open

                          return $envelope;
              Severity: Major
              Found in src/Controller/PbjxController.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return $this->handleCommand($envelope, $request, $message);
                Severity: Major
                Found in src/Controller/PbjxController.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return $this->handleEvent($envelope, $request, $message);
                  Severity: Major
                  Found in src/Controller/PbjxController.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return false;
                    Severity: Major
                    Found in src/Controller/PbjxController.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return $envelope
                                      ->set('code', Code::OK->value)
                                      ->set('http_code', HttpCode::HTTP_ACCEPTED)
                                      ->set('message_ref', $message->generateMessageRef());
                      Severity: Major
                      Found in src/Controller/PbjxController.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return true;
                        Severity: Major
                        Found in src/Controller/PbjxController.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return $this->handleRequest($envelope, $request, $message);
                          Severity: Major
                          Found in src/Controller/PbjxController.php - About 30 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language