SergiX44/XBackBone

View on GitHub
app/Controllers/MediaController.php

Summary

Maintainability
C
1 day
Test Coverage

File MediaController.php has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App\Controllers;

use App\Database\Repositories\UserRepository;
Severity: Minor
Found in app/Controllers/MediaController.php - About 4 hrs to fix

    Method show has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function show(
            Request $request,
            Response $response,
            string $userCode,
            string $mediaCode,
    Severity: Major
    Found in app/Controllers/MediaController.php - About 2 hrs to fix

      Function show has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function show(
              Request $request,
              Response $response,
              string $userCode,
              string $mediaCode,
      Severity: Minor
      Found in app/Controllers/MediaController.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 streamMedia has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function streamMedia(
              Request $request,
              Response $response,
              Filesystem $storage,
              $media,
      Severity: Minor
      Found in app/Controllers/MediaController.php - About 1 hr to fix

        Method handlePartialRequest has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function handlePartialRequest(
                Response $response,
                Stream $stream,
                string $range,
                string $disposition,
        Severity: Minor
        Found in app/Controllers/MediaController.php - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                  if (
                      UA::isBot($userAgent) &&
                      !(
                          // embed if enabled
                          (UA::embedsLinks($userAgent) &&
          Severity: Major
          Found in app/Controllers/MediaController.php - About 1 hr to fix

            Function deleteByToken has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function deleteByToken(
                    Request $request,
                    Response $response,
                    string $userCode,
                    string $mediaCode,
            Severity: Minor
            Found in app/Controllers/MediaController.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

            Function streamMedia has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function streamMedia(
                    Request $request,
                    Response $response,
                    Filesystem $storage,
                    $media,
            Severity: Minor
            Found in app/Controllers/MediaController.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