gboudreau/Greyhole

View on GitHub

Showing 334 of 371 total issues

Method get_email_body has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function get_email_body($include_trash_size) {
        if (empty($this->end)) {
            $this->end = time();
        }

Severity: Major
Found in includes/common.php - About 2 hrs to fix

    Function ajax_value_changed has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    function ajax_value_changed($el, name, value, success) {
        // console.log(name + " = " + value);
        $.ajax({
            type: 'POST',
            url: './?ajax=config',
    Severity: Minor
    Found in web-app/scripts.js - 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 run has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function run() {
            Log::setAction(ACTION_INITIALIZE);
            Metastores::choose_metastores_backups();
            Log::setAction(ACTION_MOVE);
    
    
    Severity: Major
    Found in includes/CLI/MoveCliRunner.php - About 2 hrs to fix

      Method get_metafiles_for_file has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function get_metafiles_for_file($share, $path, $filename=NULL, $load_nok_metafiles=FALSE, $quiet=FALSE, $check_symlink=TRUE) {
              if (!$quiet) {
                  Log::debug("Loading metafiles for " . clean_dir($share . (!empty($path) ? "/$path" : "") . "/$filename") . ' ...');
              }
              $metafiles_data_file = static::get_metafile_data_filename($share, $path, $filename);
      Severity: Major
      Found in includes/Metastores.php - About 2 hrs to fix

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

            public function close_all_tasks($tasks) {
                $q = "SELECT COUNT(*) FROM tasks WHERE complete = 'no'";
                $has_incomplete_tasks = (int) DB::getFirstValue($q);
        
                $q = "SELECT COUNT(*) FROM tasks WHERE complete = 'written'";
        Severity: Minor
        Found in includes/DBSpool.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 xcopy has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

        function xcopy($src,$dest) {
            // recursive copy
            if (!is_dir($dest)) {
                mkdir($dest);
            }
        Severity: Minor
        Found in web-app/views/trash.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 loadStatusBalanceReport has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function loadStatusBalanceReport() {
            let $container = $('#balance_groups');
            $.ajax({
                type: 'POST',
                url: './?ajax=get_status_balance_report',
        Severity: Major
        Found in web-app/scripts.js - About 2 hrs to fix

          Function execute has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              public function execute() {
                  Log::info("Starting available space balancing");
          
                  // Start with shares that have sticky files, so that subsequent shares will be used to try to balance what moving files into stick_into drives could debalance...
                  // Then start with the shares for which we keep the most # copies;
          Severity: Minor
          Found in includes/Tasks/BalanceTask.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 run has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function run() {
                  ConfigHelper::parse();
                  DB::connect();
                  Log::setAction(ACTION_INITIALIZE);
                  Metastores::choose_metastores_backups();
          Severity: Major
          Found in includes/CLI/CopyCliRunner.php - About 2 hrs to fix

            Method gh_mkdir has 62 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function gh_mkdir($directory, $original_directory, $dir_permissions = NULL) {
                $directory = clean_dir($directory);
                $original_directory = clean_dir($original_directory);
                if (is_dir($directory)) {
                    if (empty($dir_permissions)) {
            Severity: Major
            Found in includes/SystemHelper.php - About 2 hrs to fix

              Method json_pretty_print has 62 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function json_pretty_print($json) {
                  if (defined('JSON_PRETTY_PRINT')) {
                      if (is_string($json)) {
                          $json = json_decode($json);
                      }
              Severity: Major
              Found in includes/common.php - About 2 hrs to fix

                Method trash_file has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function trash_file($real_path, $file_was_modified = FALSE) {
                        $is_symlink = FALSE;
                        clearstatcache();
                        if (is_link($real_path)) {
                            $is_symlink = TRUE;
                Severity: Major
                Found in includes/Trash.php - About 2 hrs to fix

                  Function parse_line_pool_drive has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private static function parse_line_pool_drive($name, $value) {
                          if ($name == CONFIG_STORAGE_POOL_DRIVE) {
                              if (preg_match("/(.*) ?, ?min_free ?: ?([0-9]+) ?([gmk])b?/i", $value, $regs)) {
                                  $sp_drive = '/' . trim(trim($regs[1]), '/');
                                  Config::add(CONFIG_STORAGE_POOL_DRIVE, $sp_drive);
                  Severity: Minor
                  Found in includes/ConfigHelper.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 getRunner has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function getRunner() {
                          if (empty($this->actionCmd) && basename(first($GLOBALS['argv'], '')) == 'cpgh') {
                              return new CopyCliRunner($this->options, $this->actionCmd);
                          }
                  
                  
                  Severity: Minor
                  Found in includes/CLI/CommandLineHelper.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 get_debug_bt has a Cognitive Complexity of 18 (exceeds 5 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 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 get_new_share_defaults has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function get_new_share_defaults($all_samba_shares) {
                      // Default path for new share: find the most-used path in existing shares
                      $prefixes = [];
                      $prefix_shares = [];
                      $options = [];
                  Severity: Minor
                  Found in web-app/functions.inc.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 success has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          success: function(data, textStatus, jqXHR) {
                              if (data.result === 'success') {
                                  if (data.show_stop_button) {
                                      $('#cancel_balance_container').show();
                                  } else {
                  Severity: Major
                  Found in web-app/scripts.js - About 2 hrs to fix

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

                        public function execute() {
                            $this->drive = $this->full_path;
                    
                            // Removing this drive here will insure it won't be used for new files while we're moving files away, and that it can later be replaced.
                            StoragePool::remove_drive($this->drive);
                    Severity: Major
                    Found in includes/Tasks/RemoveTask.php - About 2 hrs to fix

                      Method migrate_10_utf8 has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private static function migrate_10_utf8() {
                              $q = "SHOW INDEX FROM du_stats WHERE key_name = 'uniqness' AND column_name = 'full_path'";
                              $index_def = DB::getFirst($q);
                              if ($index_def->Sub_part > 269) {
                                  $q = "ALTER TABLE du_stats DROP INDEX uniqness";
                      Severity: Major
                      Found in includes/DB.php - About 2 hrs to fix

                        Method samba_check_vfs has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function samba_check_vfs() {
                                $vfs_is_ok = FALSE;
                        
                                // Samba version
                                $version = str_replace('.', '', SambaUtils::samba_get_version());
                        Severity: Major
                        Found in includes/SambaUtils.php - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language