gdbots/pbjx-bundle-php

View on GitHub

Showing 49 of 61 total issues

File PbjxBatchCommand.php has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare(strict_types=1);

namespace Gdbots\Bundle\PbjxBundle\Command;

Severity: Minor
Found in src/Command/PbjxBatchCommand.php - About 2 hrs to fix

    Method load has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function load(array $configs, ContainerBuilder $container): void
        {
            $processor = new Processor();
            $configuration = new Configuration();
            $configs = $processor->processConfiguration($configuration, $configs);
    Severity: Minor
    Found in src/DependencyInjection/GdbotsPbjxExtension.php - About 1 hr to fix

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

          protected function execute(InputInterface $input, OutputInterface $output): int
          {
              $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
      
              $curie = SchemaCurie::fromString($input->getArgument('curie'));
      Severity: Minor
      Found in src/Command/PbjxCommand.php - About 1 hr to fix

        Function execute has a Cognitive Complexity of 14 (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/ExportEventsCommand.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 configure has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function configure(): void
            {
                $this
                    ->setDescription('Handles pbjx messages (command, event, request) and returns an envelope with the result')
                    ->setHelp(<<<EOF
        Severity: Minor
        Found in src/Command/PbjxCommand.php - About 1 hr to fix

          Method execute has 43 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/ExportEventsCommand.php - About 1 hr to fix

            Method isPbjxTokenOk has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function isPbjxTokenOk(Message $envelope, Request $request, string $content): bool
                {
                    if ($request->attributes->getBoolean('pbjx_console')) {
                        // no tokens used on the console
                        return true;
            Severity: Minor
            Found in src/Controller/PbjxController.php - About 1 hr to fix

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

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

                    public function receiveAction(Request $request): JsonResponse
                    {
                        if (!$this->enabled) {
                            throw new AccessDeniedHttpException(
                                'The receive endpoint is not enabled.',
                Severity: Minor
                Found in src/Controller/PbjxReceiveController.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 isPbjxTokenOk has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function isPbjxTokenOk(Message $envelope, Request $request, string $content): bool
                    {
                        if ($request->attributes->getBoolean('pbjx_console')) {
                            // no tokens used on the console
                            return true;
                Severity: Minor
                Found in src/Controller/PbjxController.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 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

                        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

                            Severity
                            Category
                            Status
                            Source
                            Language