components-web-app/api-components-bundle

View on GitHub
src/EventListener/Api/PublishableEventListener.php

Summary

Maintainability
B
4 hrs
Test Coverage

Method onPostRespond has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function onPostRespond(ResponseEvent $event): void
    {
        $request = $event->getRequest();

        $attributes = $this->getAttributes($request);
Severity: Minor
Found in src/EventListener/Api/PublishableEventListener.php - About 1 hr to fix

    Method checkMergeDraftIntoPublished has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function checkMergeDraftIntoPublished(Request $request, object $data, bool $flushDatabase = false): object
        {
            if (!$this->publishableStatusChecker->isActivePublishedAt($data)) {
                return $data;
            }
    Severity: Minor
    Found in src/EventListener/Api/PublishableEventListener.php - About 1 hr to fix

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

          public function onPostRespond(ResponseEvent $event): void
          {
              $request = $event->getRequest();
      
              $attributes = $this->getAttributes($request);
      Severity: Minor
      Found in src/EventListener/Api/PublishableEventListener.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 mergeDraftIntoPublished has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private function mergeDraftIntoPublished(string $identifierFieldName, object $draftResource, object $publishedResource, bool $flushDatabase): void
          {
              $draftReflection = new \ReflectionClass($draftResource);
              $publishedReflection = new \ReflectionClass($publishedResource);
              $properties = $publishedReflection->getProperties();
      Severity: Minor
      Found in src/EventListener/Api/PublishableEventListener.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 checkMergeDraftIntoPublished has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          private function checkMergeDraftIntoPublished(Request $request, object $data, bool $flushDatabase = false): object
          {
              if (!$this->publishableStatusChecker->isActivePublishedAt($data)) {
                  return $data;
              }
      Severity: Minor
      Found in src/EventListener/Api/PublishableEventListener.php - About 25 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

      There are no issues that match your filters.

      Category
      Status