gboudreau/Greyhole

View on GitHub

Showing 334 of 371 total issues

Function drawPieChartDiskUsage has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function drawPieChartDiskUsage(ctx, du_stats) {
    let dataset = [];
    let labels = [];
    let colors = [];
    let paths = [];
Severity: Major
Found in web-app/scripts.js - About 2 hrs to fix

    Function loadStatusLogs has a Cognitive Complexity of 17 (exceeds 5 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 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 check_going_dir has a Cognitive Complexity of 17 (exceeds 5 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 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 gh_fsck has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function gh_fsck($path, $share, $storage_path = FALSE) {
            $path = clean_dir($path);
            Log::debug("Entering $path");
            $this->fsck_report->count(FSCK_COUNT_LZ_DIRS);
    
    
    Severity: Major
    Found in includes/Tasks/FsckTask.php - About 2 hrs to fix

      Method create_metafiles has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function create_metafiles($share, $full_path, $num_copies_required, $filesize, $metafiles=[]) {
              $found_link_metafile = FALSE;
      
              list($path, ) = explode_full_path($full_path);
      
      
      Severity: Major
      Found in includes/Metastores.php - About 2 hrs to fix

        Method save_metafiles has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function save_metafiles($share, $path, $filename, $metafiles) {
                if (count($metafiles) == 0) {
                    static::remove_metafiles($share, $path, $filename);
                    return;
                }
        Severity: Major
        Found in includes/Metastores.php - About 2 hrs to fix

          File BalanceTask.php has 254 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /*
          Copyright 2009-2020 Guillaume Boudreau
          
          This file is part of Greyhole.
          Severity: Minor
          Found in includes/Tasks/BalanceTask.php - About 2 hrs to fix

            Function get_stats has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function get_stats() {
                    $totals = array(
                        'total_space' => 0,
                        'used_space' => 0,
                        'free_space' => 0,
            Severity: Minor
            Found in includes/CLI/StatsCliRunner.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 run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function run() {
                    Log::setAction(ACTION_MD5_WORKER);
            
                    $drives_clause = array();
                    $params = array();
            Severity: Minor
            Found in includes/CLI/MD5WorkerCliRunner.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 gh_write_process_metafiles has a Cognitive Complexity of 16 (exceeds 5 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) {
                    $landing_zone = get_share_landing_zone($share);
                    list($path, $filename) = explode_full_path($full_path);
            
                    // Only need to check for locking if we have something to do!
            Severity: Minor
            Found in includes/Tasks/WriteTask.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 fix_symlinks_on_share has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

            function fix_symlinks_on_share($share_name) {
                $share_options = SharesConfig::getConfigForShare($share_name);
                echo "Looking for broken symbolic links in the share '$share_name'...";
                chdir($share_options[CONFIG_LANDING_ZONE]);
                exec("find -L . -type l", $result);
            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 run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function run() {
                    $shares_names = array_keys(SharesConfig::getShares());
                    natcasesort($shares_names);
            
                    $max_share_strlen = max(array_merge(array_map('mb_strlen', $shares_names), array(7)));
            Severity: Minor
            Found in includes/CLI/ViewQueueCliRunner.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 get_stats has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function get_stats() {
                    $totals = array(
                        'total_space' => 0,
                        'used_space' => 0,
                        'free_space' => 0,
            Severity: Major
            Found in includes/CLI/StatsCliRunner.php - About 2 hrs to fix

              Method execute has 51 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: Major
              Found in includes/Tasks/UnlinkTask.php - About 2 hrs to fix

                Method __construct has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function __construct() {
                        $this->cliCommandsDefinitions = array(
                            new CliCommandDefinition('help',             '?',   null,             null,                           "Display this help and exit."),
                            new CliCommandDefinition('daemon',           'D',   null,             DaemonRunner::class,            "Start the daemon."),
                            new CliCommandDefinition('pause',            'P',   null,             PauseCliRunner::class,          "Pause the daemon."),
                Severity: Minor
                Found in includes/CLI/CommandLineHelper.php - About 2 hrs to fix

                  Method close_all_tasks has 50 lines of code (exceeds 25 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

                    Method close_task has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function close_task($act, $share, $fd, $fullpath, &$tasks) {
                            if (!empty($fullpath)) {
                                $prop = 'full_path';
                                $prop_value = $fullpath;
                            } else {
                    Severity: Minor
                    Found in includes/DBSpool.php - About 1 hr to fix

                      Method choose_metastores_backups has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function choose_metastores_backups($try_restore=TRUE) {
                              $num_metastore_backups_needed = 2;
                              if (count(Config::storagePoolDrives()) < 2) {
                                  Config::set(CONFIG_METASTORE_BACKUPS, array());
                                  return;
                      Severity: Minor
                      Found in includes/Metastores.php - About 1 hr to fix

                        Function _trigger has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected static function _trigger($event_type, $context) {
                                if (!isset(static::$hooks[$event_type])) {
                                    return;
                                }
                                $hooks = static::$hooks[$event_type];
                        Severity: Minor
                        Found in includes/Hook.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 gh_fsck_metastore has a Cognitive Complexity of 15 (exceeds 5 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

                        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