andersundsehr/aus_driver_amazon_s3

View on GitHub

Showing 25 of 25 total issues

File AmazonS3Driver.php has 945 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/***
 *
 * This file is part of an extension for TYPO3 CMS.
Severity: Major
Found in Classes/Driver/AmazonS3Driver.php - About 2 days to fix

    AmazonS3Driver has 74 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class AmazonS3Driver extends AbstractHierarchicalFilesystemDriver
    {
        const DRIVER_TYPE = 'AusDriverAmazonS3';
    
        const EXTENSION_KEY = 'aus_driver_amazon_s3';
    Severity: Major
    Found in Classes/Driver/AmazonS3Driver.php - About 1 day to fix

      Function getFoldersInFolder has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getFoldersInFolder($folderIdentifier, $start = 0, $numberOfItems = 0, $recursive = false, array $folderNameFilterCallbacks = [], $sort = '', $sortRev = false)
          {
              $this->normalizeIdentifier($folderIdentifier);
              $folders = [];
      
      
      Severity: Minor
      Found in Classes/Driver/AmazonS3Driver.php - About 5 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 getObjectPermissions has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getObjectPermissions($identifier)
          {
              $this->normalizeIdentifier($identifier);
              if ($identifier === '') {
                  $identifier = self::ROOT_FOLDER_IDENTIFIER;
      Severity: Minor
      Found in Classes/Driver/AmazonS3Driver.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

      Function getFilesInFolder has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getFilesInFolder($folderIdentifier, $start = 0, $numberOfItems = 0, $recursive = false, array $filenameFilterCallbacks = [], $sort = '', $sortRev = false)
          {
              $this->normalizeIdentifier($folderIdentifier);
              $files = [];
              if ($folderIdentifier === self::ROOT_FOLDER_IDENTIFIER) {
      Severity: Minor
      Found in Classes/Driver/AmazonS3Driver.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 getListObjects has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getListObjects($identifier, $overrideArgs = [])
          {
              $args = [
                  'Bucket' => $this->configuration['bucket'],
                  'Prefix' => $identifier,
      Severity: Minor
      Found in Classes/Driver/AmazonS3Driver.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 deleteFolder has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function deleteFolder($folderIdentifier, $deleteRecursively = false)
          {
              if ($deleteRecursively) {
                  $items = $this->getListObjects($folderIdentifier);
                  foreach ($items['Contents'] as $object) {
      Severity: Minor
      Found in Classes/Driver/AmazonS3Driver.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 initializeSettings has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function initializeSettings()
          {
              if (self::$settings === null) {
                  if (version_compare(VersionNumberUtility::getNumericTypo3Version(), '9.0.0') === -1) {
                      // Backwards compatibility: for TYPO3 versions lower than 9.0
      Severity: Minor
      Found in Classes/Driver/AmazonS3Driver.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 getObjectPermissions has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getObjectPermissions($identifier)
          {
              $this->normalizeIdentifier($identifier);
              if ($identifier === '') {
                  $identifier = self::ROOT_FOLDER_IDENTIFIER;
      Severity: Minor
      Found in Classes/Driver/AmazonS3Driver.php - About 1 hr to fix

        Method getFoldersInFolder has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getFoldersInFolder($folderIdentifier, $start = 0, $numberOfItems = 0, $recursive = false, array $folderNameFilterCallbacks = [], $sort = '', $sortRev = false)
            {
                $this->normalizeIdentifier($folderIdentifier);
                $folders = [];
        
        
        Severity: Minor
        Found in Classes/Driver/AmazonS3Driver.php - About 1 hr to fix

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

              public function getFilesInFolder($folderIdentifier, $start = 0, $numberOfItems = 0, $recursive = false, array $filenameFilterCallbacks = [], $sort = '', $sortRev = false)
              {
                  $this->normalizeIdentifier($folderIdentifier);
                  $files = [];
                  if ($folderIdentifier === self::ROOT_FOLDER_IDENTIFIER) {
          Severity: Minor
          Found in Classes/Driver/AmazonS3Driver.php - About 1 hr to fix

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

                protected function getListObjects($identifier, $overrideArgs = [])
                {
                    $args = [
                        'Bucket' => $this->configuration['bucket'],
                        'Prefix' => $identifier,
            Severity: Minor
            Found in Classes/Driver/AmazonS3Driver.php - About 1 hr to fix

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

                  public function addFile($localFilePath, $targetFolderIdentifier, $newFileName = '', $removeOriginal = true)
                  {
                      $newFileName = $this->sanitizeFileName($newFileName !== '' ? $newFileName : PathUtility::basename($localFilePath));
                      $targetIdentifier = $targetFolderIdentifier . $newFileName;
                      $localIdentifier = $localFilePath;
              Severity: Minor
              Found in Classes/Driver/AmazonS3Driver.php - About 1 hr to fix

                Method initializeClient has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function initializeClient()
                    {
                        $configuration = [
                            'version' => '2006-03-01',
                            'region' => (string)$this->configuration['region'],
                Severity: Minor
                Found in Classes/Driver/AmazonS3Driver.php - About 1 hr to fix

                  Function addFile has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function addFile($localFilePath, $targetFolderIdentifier, $newFileName = '', $removeOriginal = true)
                      {
                          $newFileName = $this->sanitizeFileName($newFileName !== '' ? $newFileName : PathUtility::basename($localFilePath));
                          $targetIdentifier = $targetFolderIdentifier . $newFileName;
                          $localIdentifier = $localFilePath;
                  Severity: Minor
                  Found in Classes/Driver/AmazonS3Driver.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 upload has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function upload(string $localFilePath, string $targetFilePath, string $bucket, string $cacheControl)
                      {
                          $fileInfo = finfo_open(FILEINFO_MIME_TYPE);
                          $contentType = finfo_file($fileInfo, $localFilePath);
                          finfo_close($fileInfo);
                  Severity: Minor
                  Found in Classes/S3Adapter/MultipartUploaderAdapter.php - About 1 hr to fix

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

                        protected function initializeClient()
                        {
                            $configuration = [
                                'version' => '2006-03-01',
                                'region' => (string)$this->configuration['region'],
                    Severity: Minor
                    Found in Classes/Driver/AmazonS3Driver.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

                    Method getFilesInFolder has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public function getFilesInFolder($folderIdentifier, $start = 0, $numberOfItems = 0, $recursive = false, array $filenameFilterCallbacks = [], $sort = '', $sortRev = false)
                    Severity: Major
                    Found in Classes/Driver/AmazonS3Driver.php - About 50 mins to fix

                      Method getFoldersInFolder has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public function getFoldersInFolder($folderIdentifier, $start = 0, $numberOfItems = 0, $recursive = false, array $folderNameFilterCallbacks = [], $sort = '', $sortRev = false)
                      Severity: Major
                      Found in Classes/Driver/AmazonS3Driver.php - About 50 mins to fix

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

                                    if (is_array($moreResults['Contents'])) {
                                        if (!is_array($result['Contents'])) {
                                            $result['Contents'] = $moreResults['Contents'];
                                        } else {
                                            $result['Contents'] = array_merge($result['Contents'], $moreResults['Contents']);
                        Severity: Minor
                        Found in Classes/Driver/AmazonS3Driver.php and 1 other location - About 35 mins to fix
                        Classes/Driver/AmazonS3Driver.php on lines 1527..1533

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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language