gboudreau/Greyhole

View on GitHub

Showing 334 of 371 total issues

Method execute has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function execute() {
        $share = $this->share;
        $full_path = $this->full_path;

        $landing_zone = get_share_landing_zone($share);
Severity: Minor
Found in includes/Tasks/RmdirTask.php - About 1 hr to fix

    Method taskCompleted has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function taskCompleted($task_id, $send_email) {
            $fsck_work_log = static::getFromDisk();
            foreach ($fsck_work_log->tasks as $task) {
                if ($task->id == $task_id) {
                    $task->status = static::STATUS_COMPLETE;
    Severity: Minor
    Found in includes/common.php - About 1 hr to fix

      Function success has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              success: function(data, textStatus, jqXHR) {
                  if (data.result === 'success') {
                      $table.find('tr:not(.loading):not(.header)').detach();
                      for (let row of data.rows) {
                          let $tr = $('<tr/>');
      Severity: Minor
      Found in web-app/scripts.js - About 1 hr to fix

        Function loadActionsTrashContent has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function loadActionsTrashContent() {
            var $table = $('#trash-content');
            var $loading_row = $table.find('.loading');
            $loading_row.show();
            $.ajax({
        Severity: Minor
        Found in web-app/scripts.js - About 1 hr to fix

          Method get_debug_bt has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function get_debug_bt() {
              $bt = '';
              foreach (debug_backtrace() as $d) {
                  if ($d['function'] == 'gh_error_handler' || $d['function'] == 'get_debug_bt') { continue; }
                  if ($bt != '') {
          Severity: Minor
          Found in includes/common.php - About 1 hr to fix

            Function ajaxCallFromButton has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function ajaxCallFromButton(button, ajax_action, data, onbusy_btn_text, onsuccess_btn_text, final_btn_text, onsuccess, onsuccess_delay) {
            Severity: Major
            Found in web-app/scripts.js - About 1 hr to fix

              Method gh_write_process_metafiles has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private function gh_write_process_metafiles($num_copies_required, $existing_metafiles, $share, $full_path, $source_file, $filesize, $task_id, $keys_to_remove=NULL) {
              Severity: Major
              Found in includes/Tasks/WriteTask.php - About 1 hr to fix

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

                    private static function migrate_6_md5_worker_indexes() {
                        $query = "SHOW INDEX FROM tasks WHERE Key_name = 'md5_worker'";
                        $row = DB::getFirst($query);
                        if ($row === FALSE) {
                            // migrate
                Severity: Minor
                Found in includes/DB.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 restore has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function restore() {
                        $latest_backup_time = 0;
                        foreach (Config::storagePoolDrives() as $sp_drive) {
                            $settings_backup_file = "$sp_drive/.gh_settings.bak";
                            if (file_exists($settings_backup_file)) {
                Severity: Minor
                Found in includes/Settings.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 run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function run() {
                        $pid = (int) exec('ps ax -o pid,stat,comm,args | grep "greyhole --daemon\|greyhole -D" | grep -v grep | grep -v bash | awk \'{print $1}\'');
                        if ($pid) {
                            if ($this instanceof ResumeCliRunner) {
                                exec('kill -CONT ' . $pid);
                Severity: Minor
                Found in includes/CLI/PauseCliRunner.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 create_mem_spool has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function create_mem_spool() {
                        $mounted_already = exec('mount | grep /var/spool/greyhole/mem | wc -l');
                        if (!$mounted_already && file_exists('/var/spool/greyhole/mem')) {
                            // In Docker, mount doesn't list mounts... need to check using df instead:
                            exec("cat /proc/1/sched | grep supervisord", $output, $result);
                Severity: Minor
                Found in includes/SambaSpool.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 drawTreeMapDiskUsage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                function drawTreeMapDiskUsage(ctx, du_stats) {
                    let dataset = [];
                    let paths = [];
                    let max = 0, min = null;
                
                
                Severity: Minor
                Found in web-app/scripts.js - 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 string_starts_with has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                function string_starts_with($haystack, $needle) {
                    if (!is_string($haystack) || empty($haystack)) {
                        return FALSE;
                    }
                    if (is_array($needle)) {
                Severity: Minor
                Found in includes/common.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 string_ends_with has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                function string_ends_with($haystack, $needle) {
                    if (!is_string($haystack) || empty($haystack)) {
                        return FALSE;
                    }
                    if (is_array($needle)) {
                Severity: Minor
                Found in includes/common.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 execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function execute($q, $args = array(), $attempt_repair=TRUE) {
                        $stmt = self::$handle->prepare($q);
                        foreach ($args as $key => $value) {
                            $stmt->bindValue(":$key", $value);
                        }
                Severity: Minor
                Found in includes/DB.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 getHumanReadableReport has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function getHumanReadableReport() {
                        $fsck_work_log = static::getFromDisk();
                
                        if (count($fsck_work_log->tasks) == 1) {
                            $task = first($fsck_work_log->tasks);
                Severity: Minor
                Found in includes/common.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 get_forced_groups_config has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                function get_forced_groups_config() {
                    if ($('[name="drive_selection_algorithm_forced"]:checked').val() === 'no') {
                        $('.forced_toggleable').closest('.form-group').hide();
                        return $('[name="drive_selection_algorithm"]:checked').val();
                    }
                Severity: Minor
                Found in web-app/scripts.js - 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 balance_drive has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function balance_drive($share, $share_options, $source_drive, &$pool_drives_avail_space, $balance_direction_asc, $min_file_size) {
                        $current_avail_space = $pool_drives_avail_space[$source_drive];
                        $target_avail_space = array_sum($pool_drives_avail_space) / count($pool_drives_avail_space);
                        $delta_needed = $target_avail_space - $current_avail_space;
                        if ($delta_needed <= 10*1024 || $delta_needed < $min_file_size*1024) {
                Severity: Minor
                Found in includes/Tasks/BalanceTask.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 balance_file has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    private function balance_file($file, $share, $share_options, $source_drive, &$pool_drives_avail_space, $balance_direction_asc, &$file_too_large_warnings) {
                Severity: Major
                Found in includes/Tasks/BalanceTask.php - About 50 mins to fix

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

                      public function gh_fsck_file($path, $filename, $file_type, $source, $share, $storage_path = FALSE, $num_retries = 1) {
                  Severity: Major
                  Found in includes/Tasks/FsckTask.php - About 50 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language