owncloud/core

View on GitHub
apps/files_external/lib/Lib/Storage/SMB.php

Summary

Maintainability
F
4 days
Test Coverage

File SMB.php has 600 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
 * @author Jesús Macias <jmacias@solidgear.es>
 * @author Jörn Friedrich Dreyer <jfd@butonic.de>
Severity: Major
Found in apps/files_external/lib/Lib/Storage/SMB.php - About 1 day to fix

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

        protected function getFileInfo($path) {
            $this->log('enter: '.__FUNCTION__."($path)");
            $path = $this->buildPath($path);
            if (!isset($this->statCache[$path])) {
                try {
    Severity: Minor
    Found in apps/files_external/lib/Lib/Storage/SMB.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

    SMB has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SMB extends StorageAdapter {
        /** @var bool */
        protected $logActive;
    
        /**
    Severity: Minor
    Found in apps/files_external/lib/Lib/Storage/SMB.php - About 3 hrs to fix

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

          public function rename($source, $target) {
              $this->log("enter: rename('$source', '$target')", Util::DEBUG);
      
              if ($this->isRootDir($source) || $this->isRootDir($target)) {
                  $this->log("refusing to rename \"$source\" to \"$target\"");
      Severity: Minor
      Found in apps/files_external/lib/Lib/Storage/SMB.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

      Method getFileInfo has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getFileInfo($path) {
              $this->log('enter: '.__FUNCTION__."($path)");
              $path = $this->buildPath($path);
              if (!isset($this->statCache[$path])) {
                  try {
      Severity: Major
      Found in apps/files_external/lib/Lib/Storage/SMB.php - About 3 hrs to fix

        Method fopen has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function fopen($path, $mode) {
                $this->log('enter: '.__FUNCTION__."($path, $mode)");
                $fullPath = $this->buildPath($path);
                $result = false;
                try {
        Severity: Major
        Found in apps/files_external/lib/Lib/Storage/SMB.php - About 2 hrs to fix

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

              public function fopen($path, $mode) {
                  $this->log('enter: '.__FUNCTION__."($path, $mode)");
                  $fullPath = $this->buildPath($path);
                  $result = false;
                  try {
          Severity: Minor
          Found in apps/files_external/lib/Lib/Storage/SMB.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 rename has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function rename($source, $target) {
                  $this->log("enter: rename('$source', '$target')", Util::DEBUG);
          
                  if ($this->isRootDir($source) || $this->isRootDir($target)) {
                      $this->log("refusing to rename \"$source\" to \"$target\"");
          Severity: Minor
          Found in apps/files_external/lib/Lib/Storage/SMB.php - About 1 hr to fix

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

                protected function getFolderContents($path) {
                    $this->log('enter: '.__FUNCTION__."($path)");
                    try {
                        $path = $this->buildPath($path);
                        $result = [];
            Severity: Minor
            Found in apps/files_external/lib/Lib/Storage/SMB.php - About 1 hr to fix

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

                  protected function getFolderContents($path) {
                      $this->log('enter: '.__FUNCTION__."($path)");
                      try {
                          $path = $this->buildPath($path);
                          $result = [];
              Severity: Minor
              Found in apps/files_external/lib/Lib/Storage/SMB.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 __construct has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function __construct($params) {
                      // log switch might be set already (from a subclass), so don't change it.
                      if (!isset($this->logActive)) {
                          $this->logActive = \OC::$server->getConfig()->getSystemValue('smb.logging.enable', false) === true;
                      }
              Severity: Minor
              Found in apps/files_external/lib/Lib/Storage/SMB.php - About 1 hr to fix

                Method rmdir has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function rmdir($path) {
                        $this->log('enter: '.__FUNCTION__."($path)");
                
                        if ($this->isRootDir($path)) {
                            $this->log("refusing to delete \"$path\"");
                Severity: Minor
                Found in apps/files_external/lib/Lib/Storage/SMB.php - About 1 hr to fix

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

                      public function __construct($params) {
                          // log switch might be set already (from a subclass), so don't change it.
                          if (!isset($this->logActive)) {
                              $this->logActive = \OC::$server->getConfig()->getSystemValue('smb.logging.enable', false) === true;
                          }
                  Severity: Minor
                  Found in apps/files_external/lib/Lib/Storage/SMB.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 leave has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function leave($function, $result) {
                          if (!$this->logActive) {
                              //don't bother building log strings
                              return $result;
                          } elseif ($result === true) {
                  Severity: Minor
                  Found in apps/files_external/lib/Lib/Storage/SMB.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 rmdir has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function rmdir($path) {
                          $this->log('enter: '.__FUNCTION__."($path)");
                  
                          if ($this->isRootDir($path)) {
                              $this->log("refusing to delete \"$path\"");
                  Severity: Minor
                  Found in apps/files_external/lib/Lib/Storage/SMB.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

                  There are no issues that match your filters.

                  Category
                  Status