gboudreau/Greyhole

View on GitHub

Showing 334 of 371 total issues

Avoid deeply nested control flow statements.
Open

                                if (empty($file_path)) {
                                    $expected_md5 = DB::getFirstValue($q, ['share' => $share, 'full_path' => $filename]);
                                }
Severity: Major
Found in includes/Tasks/FsckTask.php - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                                if (isset($this->metafiles[$full_filename])) {
                                    continue;
                                }
    Severity: Major
    Found in includes/Metastores.php - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if ($file=='.' || $file=='..') {
                                  continue;
                              }
      Severity: Major
      Found in includes/Metastores.php - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if (file_exists($path_to_delete)) {
                                $rm_command = "rm -rf " . escapeshellarg($path_to_delete);
                                error_log($rm_command);
                                exec($rm_command);
        
        
        Severity: Major
        Found in web-app/init.inc.php - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      } else if (empty($metafile->is_linked) && $metafile->path == $share_file_link_to) {
                                          if (!$quiet) {
                                              Log::debug('  Changing is_linked to TRUE for ' . $metafile->path);
                                          }
                                          $metafile->is_linked = TRUE;
          Severity: Major
          Found in includes/Metastores.php - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            if ($return_var) {
                                $output = implode(" ", $output);
                                echo json_encode(['result' => 'error', 'message' => "Error: UNIX user doesn't not exist, and failed to create ($output).\nYou can only create Samba users for existing UNIX users."]);
                            }
            Severity: Major
            Found in web-app/init.inc.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                              if (!$quiet) {
                                                  Log::debug('  Changing is_linked to FALSE for ' . $metafile->path);
                                              }
              Severity: Major
              Found in includes/Metastores.php - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if (!is_dir($v)) {
                                        echo json_encode(['result' => 'error', 'message' => "Specified dir not found: " . $v]);
                                        exit();
                                    }
                Severity: Major
                Found in web-app/init.inc.php - About 45 mins to fix

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

                      public function close_task($act, $share, $fd, $fullpath, &$tasks) {
                  Severity: Minor
                  Found in includes/DBSpool.php - About 35 mins to fix

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

                        public static function get_file_copies_inodes($share, $file_path, $filename, &$file_metafiles, $one_is_enough = FALSE) {
                    Severity: Minor
                    Found in includes/StoragePool.php - About 35 mins to fix

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

                          public static function create_file_copies_from_metafiles($metafiles, $share, $full_path, $source_file, $missing_only = FALSE) {
                      Severity: Minor
                      Found in includes/StorageFile.php - About 35 mins to fix

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

                            public function __construct($share, $path, $load_nok_metafiles=FALSE, $quiet=FALSE, $check_symlink=TRUE) {
                        Severity: Minor
                        Found in includes/Metastores.php - About 35 mins to fix

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

                          function gh_error_handler($errno, $errstr, $errfile, $errline, $errcontext = NULL) {
                          Severity: Minor
                          Found in includes/common.php - About 35 mins to fix

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

                                public function insert($action, $share, $full_path, $additional_info, $fd) {
                            Severity: Minor
                            Found in includes/DBSpool.php - About 35 mins to fix

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

                                  private function update_symlink($target, $symlink, $share, $file_path, $filename) {
                              Severity: Minor
                              Found in includes/Tasks/FsckTask.php - About 35 mins to fix

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

                                    public static function create_metafiles($share, $full_path, $num_copies_required, $filesize, $metafiles=[]) {
                                Severity: Minor
                                Found in includes/Metastores.php - About 35 mins to fix

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

                                      protected static function _queue($action, $share, $full_path, $additional_info, $complete) {
                                  Severity: Minor
                                  Found in includes/Tasks/AbstractTask.php - About 35 mins to fix

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

                                        function __construct($longOpt, $opt, $paramName, $cliRunnerClass, $help) {
                                    Severity: Minor
                                    Found in includes/CLI/CliCommandDefinition.php - About 35 mins to fix

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

                                      function bytes_to_human(bytes) {
                                          let units = 'B';
                                          if (Math.abs(bytes) > 1024) {
                                              bytes /= 1024;
                                              units = 'KiB';
                                      Severity: Minor
                                      Found in web-app/scripts.js - 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 migrate_18_full_path_utf8mb4 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          private static function migrate_18_full_path_utf8mb4() {
                                              $q = "ALTER TABLE `checksums` CHANGE `full_path` `full_path` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL";
                                              DB::execute($q);
                                      
                                              $query = "DESCRIBE tasks";
                                      Severity: Minor
                                      Found in includes/DB.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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language