Leuchtfeuer/typo3-secure-downloads

View on GitHub

Showing 20 of 20 total issues

Function process has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        if (!$this->isEnableGroupCheck) {
            $currentUser = $this->context->getAspect('frontend.user');
            $currentUserId = (int)$currentUser->get('id');
Severity: Minor
Found in Classes/Middleware/TokenRefreshMiddleware.php - About 3 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 CheckConfiguration.php has 268 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

/*
Severity: Minor
Found in Classes/UserFunctions/CheckConfiguration.php - About 2 hrs to fix

    ExtensionConfiguration has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ExtensionConfiguration implements SingletonInterface
    {
        public const FILE_TYPES_WILDCARD = '*';
    
        public const OUTPUT_STREAM = 'stream';
    Severity: Minor
    Found in Classes/Domain/Transfer/ExtensionConfiguration.php - About 2 hrs to fix

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

          public function onResourceStorageEmitPreGeneratePublicUrlSignal(GeneratePublicUrlForResourceEvent $event): void
          {
              $driver = $event->getDriver();
              $resource = $event->getResource();
      
      
      Severity: Minor
      Found in Classes/EventListener/SecureDownloadsEventListener.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

      Function onIconFactoryEmitBuildIconForResourceSignal has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function onIconFactoryEmitBuildIconForResourceSignal(ModifyIconForResourcePropertiesEvent $event): void
          {
              $resource = $event->getResource();
              $driverType = $resource->getStorage()->getDriverType();
      
      
      Severity: Minor
      Found in Classes/EventListener/SecureDownloadsEventListener.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 listAction has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function listAction(?Filter $filter = null): ResponseInterface
          {
              if ($this->request->hasArgument('reset') && (bool)$this->request->getArgument('reset')) {
                  $filter = new Filter();
              } elseif (!$filter instanceof Filter) {
      Severity: Minor
      Found in Classes/Controller/LogController.php - About 1 hr to fix

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

            public function deliver(string $jsonWebToken, ServerRequestInterface $request): ResponseInterface
            {
                if (!$this->retrieveDataFromJsonWebToken($jsonWebToken)) {
                    return $this->getAccessDeniedResponse($request, 'Could not parse token.');
                }
        Severity: Minor
        Found in Classes/Resource/FileDelivery.php - About 1 hr to fix

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

              public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
              {
                  if (!$this->isEnableGroupCheck) {
                      $currentUser = $this->context->getAspect('frontend.user');
                      $currentUserId = (int)$currentUser->get('id');
          Severity: Minor
          Found in Classes/Middleware/TokenRefreshMiddleware.php - About 1 hr to fix

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

                private static function getTokenFromClassName(string $className): AbstractToken
                {
                    if (!class_exists($className)) {
                        throw new ClassNotFoundException(
                            sprintf('Class "%s" not found.', $className),
            Severity: Major
            Found in Classes/Registry/TokenRegistry.php and 1 other location - About 1 hr to fix
            Classes/Registry/CheckRegistry.php on lines 70..89

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

            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 static function getCheckFromClassName(string $className): AbstractCheck
                {
                    if (!class_exists($className)) {
                        throw new ClassNotFoundException(
                            sprintf('Class "%s" not found.', $className),
            Severity: Major
            Found in Classes/Registry/CheckRegistry.php and 1 other location - About 1 hr to fix
            Classes/Registry/TokenRegistry.php on lines 75..94

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

            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

            Function getSuitableDirectories has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function getSuitableDirectories(Finder $directories, string $publicDirectory): void
                {
                    foreach ($directories as $directory) {
                        $directoryPath = sprintf('%s/%s', $publicDirectory, $directory->getRelativePathname());
                        if ($this->isDirectoryMatching($directoryPath)) {
            Severity: Minor
            Found in Classes/UserFunctions/CheckConfiguration.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 checkDirectories has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function checkDirectories(): void
                {
                    $lastSecuredDirectory = null;
            
                    foreach ($this->directories as $directory) {
            Severity: Minor
            Found in Classes/UserFunctions/CheckConfiguration.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 createLocalStorage has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function createLocalStorage($name, $basePath, $pathType, $description = '', $default = false): int
            Severity: Minor
            Found in Classes/Domain/Repository/StorageRepository.php - About 35 mins to fix

              Method dispatchBeforeFileDeliverEvent has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      string &$outputFunction,
                      array &$header,
                      string $fileName,
                      string $mimeType,
                      bool $forceDownload
              Severity: Minor
              Found in Classes/Resource/FileDelivery.php - About 35 mins to fix

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

                    public function determineSecureDownloadsDriverBaseUrl(): void
                    {
                        if ($this->baseUri === null) {
                            if (!empty($this->configuration['baseUri'])) {
                                $this->baseUri = rtrim((string)$this->configuration['baseUri'], '/') . '/';
                Severity: Minor
                Found in Classes/Resource/Driver/SecureDownloadsDriver.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 checkFilesAccessibility has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function checkFilesAccessibility(string $realDirectoryPath, string $directoryPath): void
                    {
                        $fileFinder = (new Finder())->name($this->fileTypePattern)->in($realDirectoryPath)->depth(0);
                        foreach ($fileFinder->files() as $file) {
                            $publicUrl = sprintf('%s/%s/%s', $this->domain, $directoryPath, $file->getRelativePathname());
                Severity: Minor
                Found in Classes/UserFunctions/CheckConfiguration.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 deliver has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function deliver(string $jsonWebToken, ServerRequestInterface $request): ResponseInterface
                    {
                        if (!$this->retrieveDataFromJsonWebToken($jsonWebToken)) {
                            return $this->getAccessDeniedResponse($request, 'Could not parse token.');
                        }
                Severity: Minor
                Found in Classes/Resource/FileDelivery.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 $this->getFileNotFoundResponse($request, 'File does not exist!');
                Severity: Major
                Found in Classes/Resource/FileDelivery.php - About 30 mins to fix

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

                      protected function hasAccess(): bool
                      {
                          foreach (CheckRegistry::getChecks() as $check) {
                              $checkClass = $check['class'];
                              if ($checkClass instanceof AbstractCheck) {
                  Severity: Minor
                  Found in Classes/Resource/FileDelivery.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 renderCheckAccess has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function renderCheckAccess(): string
                      {
                          if ($this->extensionConfiguration->isSkipCheckConfiguration()) {
                              return 'Check skipped as the option "backend.skipCheckConfiguration" is active';
                          }
                  Severity: Minor
                  Found in Classes/UserFunctions/CheckConfiguration.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

                  Severity
                  Category
                  Status
                  Source
                  Language