gboudreau/Greyhole

View on GitHub

Showing 334 of 371 total issues

Function loadStatusQueue has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

    Method run has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function run() {
            if (file_exists('/sbin/zpool')) {
                if (exec("whoami") != 'root') {
                    $this->log("Warning: If you are using ZFS datasets as Greyhole storage pool drives, you will need to execute this as root.");
                }
    Severity: Minor
    Found in includes/CLI/StatsCliRunner.php - About 1 hr to fix

      Function loadStatusLogs has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function loadStatusLogs() {
          if (!('page' in urlParams) || urlParams.page === 'id_l1_status_tab') {
              loadStatus();
          }
          if (!('page_status' in urlParams) || urlParams.page_status === 'id_l2_status_balance_tab') {
      Severity: Minor
      Found in web-app/scripts.js - About 1 hr to fix

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

            public static function is_pool_drive($sp_drive) {
                global $going_drive;
                if (isset($going_drive) && $sp_drive == $going_drive) {
                    return FALSE;
                }
        Severity: Minor
        Found in includes/StoragePool.php - About 1 hr to fix

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

              protected static function move_file($source, $destination) {
                  echo "[INFO] Moving file: $source > $destination\n";
          
                  $source_parts = explode('/', $source);
                  $source_share = array_shift($source_parts);
          Severity: Minor
          Found in includes/CLI/MoveCliRunner.php - About 1 hr to fix

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

                public static function directory_uuid($dir) {
                    $dev = exec('df ' . escapeshellarg($dir) . ' 2> /dev/null | grep \'/dev\' | awk \'{print $1}\'');
                    if (!is_dir($dir)) {
                        return FALSE;
                    }
            Severity: Minor
            Found in includes/SystemHelper.php - About 1 hr to fix

              Method getRunner has 34 lines of code (exceeds 25 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 1 hr to fix

                Function getTreemapColor has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function getTreemapColor(value, min, max) {
                    value = parseInt(value);
                    min = parseInt(min);
                    max = parseInt(max);
                
                
                Severity: Minor
                Found in web-app/scripts.js - About 1 hr to fix

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

                      public static function isFileLocked($share, $full_path) {
                          $db_spool = static::getInstance();
                          $idx = clean_dir("$share/$full_path");
                          if (isset($db_spool->locked_files[$idx])) {
                              return $db_spool->locked_files[$idx];
                  Severity: Minor
                  Found in includes/DBSpool.php - About 1 hr to fix

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

                        public function run() {
                            $landing_zone = get_share_landing_zone($this->share);
                    
                            $this->log("Will remove '$this->share' share from the Greyhole storage pool, by moving all the data files inside this share to it's landing zone: $landing_zone");
                    
                    
                    Severity: Minor
                    Found in includes/CLI/RemoveShareCliRunner.php - About 1 hr to fix

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

                          private static function create_trash_share_symlink($filepath_in_trash, $trash_path) {
                              $trash_share = SharesConfig::getConfigForShare(CONFIG_TRASH_SHARE);
                              if ($trash_share) {
                                  $filepath_in_trash = clean_dir($filepath_in_trash);
                                  $filepath_in_trash_share = str_replace($trash_path, $trash_share[CONFIG_LANDING_ZONE], $filepath_in_trash);
                      Severity: Minor
                      Found in includes/Trash.php - About 1 hr to fix

                        Function ajax_value_changed has 32 lines of code (exceeds 25 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 1 hr to fix

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

                              public function output() {
                                  $num_lines = 0;
                                  $cols = exec('tput cols');
                          
                                  printf("Watching every %ds:%s%s\n", $this->refresh_interval, str_repeat(' ', $cols - 50), date('r'));
                          Severity: Minor
                          Found in includes/CLI/BalanceStatusCliRunner.php - About 1 hr to fix

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

                                public static function getShareOptionsFromDrive($full_path, $sp_drive) {
                                    $landing_zone = '';
                                    $share = FALSE;
                                    foreach (SharesConfig::getShares() as $share_name => $share_options) {
                                        $lz = $share_options[CONFIG_LANDING_ZONE];
                            Severity: Minor
                            Found in includes/ConfigHelper.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

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

                                static function parse($config_string, $drive_selection_groups) {
                                    $ds = array();
                                    if ($config_string == 'least_used_space' || $config_string == 'most_available_space') {
                                        $ds[] = new PoolDriveSelector(count(Config::storagePoolDrives()), $config_string, Config::storagePoolDrives(), FALSE, 'all', 'all');
                                        return $ds;
                            Severity: Minor
                            Found in includes/PoolDriveSelector.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

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

                            function loadStatusFsckReport() {
                                $('#fsck-report-code').text('Loading...');
                                $.ajax({
                                    type: 'POST',
                                    url: './?ajax=get_status_fsck_report',
                            Severity: Minor
                            Found in web-app/scripts.js - 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

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

                                function init(&$sorted_target_drives, &$last_resort_sorted_target_drives) {
                                    // Sort by used space (asc) for least_used_space, or by available space (desc) for most_available_space
                                    if ($this->selection_algorithm == 'least_used_space') {
                                        $sorted_target_drives = $sorted_target_drives['used_space'];
                                        $last_resort_sorted_target_drives = $last_resort_sorted_target_drives['used_space'];
                            Severity: Minor
                            Found in includes/PoolDriveSelector.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

                            Function toggleSambaShareGreyholeEnabled has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function toggleSambaShareGreyholeEnabled(el) {
                                let $el = $(el);
                                let name = $el.attr('name');
                                let value = $el.val();
                                let share_name = $el.data('sharename')
                            Severity: Minor
                            Found in web-app/scripts.js - About 1 hr to fix

                              Method run has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function run() {
                                      echo "\nIs the specified drive still available? ";
                                      if (is_dir("$this->drive/.gh_metastore/")) {
                                          echo "(It looks like it is.)\n";
                                      } else {
                              Severity: Minor
                              Found in includes/CLI/RemoveCliRunner.php - About 1 hr to fix

                                Method gh_wild_mb_strpos has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function gh_wild_mb_strpos($haystack, $needle) {
                                    /** @noinspection PhpSuspiciousNameCombinationInspection */
                                    $is_wild = string_contains($needle, "*");
                                    if (!$is_wild) {
                                        return mb_strpos($haystack, $needle);
                                Severity: Minor
                                Found in includes/common.php - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language