gdbots/pbjx-bundle-php

View on GitHub

Showing 61 of 61 total issues

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

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $dryRun = $input->getOption('dry-run');
        $skipErrors = $input->getOption('skip-errors');
        $batchSize = NumberUtil::bound((int)$input->getOption('batch-size'), 1, 1000);
Severity: Minor
Found in src/Command/ReplayEventsCommand.php - About 2 hrs 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 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

        $this
Severity: Major
Found in src/Command/ReplayEventsCommand.php - About 2 hrs to fix

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

        private function handleCommand(Message $envelope, Request $request, Message $command): Message
        {
            try {
                $this->pbjx->send($command);
            } catch (\Throwable $e) {
    Severity: Major
    Found in src/Controller/PbjxController.php and 1 other location - About 2 hrs to fix
    src/Controller/PbjxController.php on lines 196..214

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

    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

        private function handleEvent(Message $envelope, Request $request, Message $event): Message
        {
            try {
                $this->pbjx->publish($event);
            } catch (\Throwable $e) {
    Severity: Major
    Found in src/Controller/PbjxController.php and 1 other location - About 2 hrs to fix
    src/Controller/PbjxController.php on lines 176..194

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

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

        protected function configure(): void
        {
            $storeProvider = $this->container->getParameter('gdbots_pbjx.event_store.provider');
            $searchProvider = $this->container->getParameter('gdbots_pbjx.event_search.provider');
    
    
    Severity: Major
    Found in src/Command/ReindexEventsCommand.php - About 2 hrs to fix

      Method receiveAction has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function receiveAction(Request $request): JsonResponse
          {
              if (!$this->enabled) {
                  throw new AccessDeniedHttpException(
                      'The receive endpoint is not enabled.',
      Severity: Major
      Found in src/Controller/PbjxReceiveController.php - About 2 hrs to fix

        File Configuration.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        declare(strict_types=1);
        
        namespace Gdbots\Bundle\PbjxBundle\DependencyInjection;
        
        
        Severity: Minor
        Found in src/DependencyInjection/Configuration.php - About 2 hrs to fix

          Function handleAction has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public function handleAction(Request $request): Message
              {
                  $request->attributes->set('pbjx_redact_error_message', false);
                  $envelope = EnvelopeV1::create();
                  if (!$this->isRequestMethodOk($envelope, $request) || !$this->isContentTypeOk($envelope, $request)) {
          Severity: Minor
          Found in src/Controller/PbjxController.php - About 2 hrs 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 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function configure(): void
              {
                  $provider = $this->container->getParameter('gdbots_pbjx.event_store.provider');
          
                  $this
          Severity: Major
          Found in src/Command/ExportEventsCommand.php - About 2 hrs to fix

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

                protected function execute(InputInterface $input, OutputInterface $output): int
                {
                    $dryRun = $input->getOption('dry-run');
                    $skipErrors = $input->getOption('skip-errors');
                    $batchSize = NumberUtil::bound((int)$input->getOption('batch-size'), 1, 1000);
            Severity: Minor
            Found in src/Command/ReindexEventsCommand.php - About 2 hrs 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

            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

                          Severity
                          Category
                          Status
                          Source
                          Language