gboudreau/Greyhole

View on GitHub

Showing 334 of 371 total issues

Method getData has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getData() {
        $shares_names = array_keys(SharesConfig::getShares());
        natcasesort($shares_names);

        $queues = array();
Severity: Minor
Found in includes/CLI/ViewQueueCliRunner.php - About 1 hr to fix

    Method check_going_dir has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected static function check_going_dir($path, $share, $going_drive) {
            $handle = @opendir($path);
            if ($handle === FALSE) {
                Log::error("Couldn't open $path to list content. Skipping...", Log::EVENT_CODE_LIST_DIR_FAILED);
                return;
    Severity: Minor
    Found in includes/Tasks/RemoveTask.php - About 1 hr to fix

      Method inject_in_file has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function inject_in_file($file, $level=0) {
          global $require_once_already_included;
      
          $file_content = file_get_contents($file);
          $new_content = '';
      Severity: Minor
      Found in build/inject-includes.php - About 1 hr to fix

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

          Method parse has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function parse() {
                  if (!ini_get('date.timezone')) {
                      // To prevent warnings that would be logged if something gets logged before the timezone setting is parsed and applied.
                      date_default_timezone_set('UTC');
                  }
          Severity: Minor
          Found in includes/ConfigHelper.php - About 1 hr to fix

            Function confirmRemoveDrive has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function confirmRemoveDrive() {
                let drive = $('#inputremove_drive').val();
                if (drive === '0') {
                    alert('meh!');
                    return;
            Severity: Minor
            Found in web-app/scripts.js - About 1 hr to fix

              Function changedTab has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function changedTab(el, first, replace) {
                  if (skip_changed_tab_event) {
                      skip_changed_tab_event = false;
                      return;
                  }
              Severity: Minor
              Found in web-app/scripts.js - About 1 hr to fix

                Function recursive_include_parser has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                function recursive_include_parser($file) {
                    $regex = '/^[ \t]*include[ \t]*=[ \t]*([^#\r\n]+)/im';
                    $ok_to_execute = FALSE;
                
                    if (is_array($file) && count($file) > 1) {
                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 setUniqID has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function setUniqID() {
                        $uniq_id = Settings::get('uniq_id');
                
                        if (!$uniq_id) {
                            // No uid found in DB; look on filesystem
                Severity: Minor
                Found in includes/CLI/GetGUIDCliRunner.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 fix_symlinks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function fix_symlinks($landing_zone, $share, $full_path, $target_full_path) {
                        if (isset($this->fix_symlinks_scanned_dirs[$landing_zone])) {
                            return;
                        }
                        Log::info("  Scanning $landing_zone for broken links... This can take a while!");
                Severity: Minor
                Found in includes/Tasks/RenameTask.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 run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function run() {
                        ConfigHelper::parse();
                        DB::connect();
                        Log::setAction(ACTION_INITIALIZE);
                        Metastores::choose_metastores_backups();
                Severity: Minor
                Found in includes/CLI/CopyCliRunner.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 loadActionsTrashContent has a Cognitive Complexity of 10 (exceeds 5 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

                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 drawPieChartStorage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                function drawPieChartStorage(ctx, stats) {
                    let dataset_used = [];
                    let dataset_trash = [];
                    let dataset_free = [];
                    let drives = [];
                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 ajaxCallFromButton has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                function ajaxCallFromButton(button, ajax_action, data, onbusy_btn_text, onsuccess_btn_text, final_btn_text, onsuccess, onsuccess_delay) {
                    let $button = $(button);
                    let original_btn_text = $button.text();
                    $button.text(onbusy_btn_text).prop('disabled', true);
                    $.ajax({
                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 run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function run() {
                        $devices_drives = array();
                        foreach (Config::storagePoolDrives() as $sp_drive) {
                            $device = exec("df " . escapeshellarg($sp_drive) . " 2>/dev/null | awk '{print \$1}'");
                            $device = preg_replace('@/dev/(sd[a-z])[0-9]?@', '\1', $device);
                Severity: Minor
                Found in includes/CLI/IoStatsCliRunner.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 execute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function execute() {
                        $landing_zone = get_share_landing_zone($this->share);
                
                        $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";
                        $this->log($log);
                Severity: Minor
                Found in includes/Tasks/RemoveShareTask.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 gh_fsck_metastore has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function gh_fsck_metastore($root, $path, $share) {
                        if (!is_dir("$root$path")) {
                            // Try NFC form [http://en.wikipedia.org/wiki/Unicode_equivalence#Normalization]
                            $root = normalize_utf8_characters($root);
                            $path = normalize_utf8_characters($path);
                Severity: Minor
                Found in includes/Tasks/FsckTask.php - About 1 hr to fix

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

                    Function ajaxCallFromButton has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function ajaxCallFromButton(button, ajax_action, data, onbusy_btn_text, onsuccess_btn_text, final_btn_text, onsuccess, onsuccess_delay) {
                        let $button = $(button);
                        let original_btn_text = $button.text();
                        $button.text(onbusy_btn_text).prop('disabled', true);
                        $.ajax({
                    Severity: Minor
                    Found in web-app/scripts.js - About 1 hr to fix

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

                          public function run() {
                              $devices_drives = array();
                              foreach (Config::storagePoolDrives() as $sp_drive) {
                                  $device = exec("df " . escapeshellarg($sp_drive) . " 2>/dev/null | awk '{print \$1}'");
                                  $device = preg_replace('@/dev/(sd[a-z])[0-9]?@', '\1', $device);
                      Severity: Minor
                      Found in includes/CLI/IoStatsCliRunner.php - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language