gboudreau/Greyhole

View on GitHub

Showing 371 of 371 total issues

File trash.php has 304 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*
Copyright 2020 Guillaume Boudreau

This file is part of Greyhole.
Severity: Minor
Found in web-app/views/trash.php - About 3 hrs to fix

    Function loadStatusQueue has a Cognitive Complexity of 23 (exceeds 5 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 3 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 create_file_copies has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function create_file_copies($source_file, &$metafiles) {
            $copy_results = [];
    
            $copy_source = is_link($source_file) ? readlink($source_file) : $source_file;
            $source_size = gh_filesize($copy_source);
    Severity: Major
    Found in includes/StorageFile.php - About 3 hrs to fix

      File CommandLineHelper.php has 296 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/CLI/CommandLineHelper.php - About 3 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            if (unix_extensions_config === 'yes' && allow_insecure_wide_links_config === 'no') {
                $('[name=' + $.escapeSelector('smb.conf:[global]unix_extensions') + ']').parent('label').removeClass('btn-outline-primary').addClass('btn-outline-danger');
                $('[name=' + $.escapeSelector('smb.conf:[global]allow_insecure_wide_links') + ']').parent('label').removeClass('btn-outline-primary').addClass('btn-outline-danger');
            } else {
        Severity: Major
        Found in web-app/scripts.js and 1 other location - About 3 hrs to fix
        web-app/scripts.js on lines 862..865

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 97.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            } else {
                $('[name=' + $.escapeSelector('smb.conf:[global]unix_extensions') + ']').parent('label').removeClass('btn-outline-danger').addClass('btn-outline-primary');
                $('[name=' + $.escapeSelector('smb.conf:[global]allow_insecure_wide_links') + ']').parent('label').removeClass('btn-outline-danger').addClass('btn-outline-primary');
            }
        Severity: Major
        Found in web-app/scripts.js and 1 other location - About 3 hrs to fix
        web-app/scripts.js on lines 859..862

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 97.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function run has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            public function run() {
                Log::setAction(ACTION_INITIALIZE);
                Metastores::choose_metastores_backups();
                Log::setAction(ACTION_MOVE);
        
        
        Severity: Minor
        Found in includes/CLI/MoveCliRunner.php - About 3 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 is_pool_drive has a Cognitive Complexity of 22 (exceeds 5 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 3 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_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

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

              private static function _log($local_log_level, $text, $event_code) {
                  if (self::$action == 'test-config' || self::$action == ACTION_CP) {
                      $greyhole_log_file = NULL;
                      $use_syslog = FALSE;
                      if (self::$action == ACTION_CP && $local_log_level > self::$level) {
          Severity: Major
          Found in includes/Log.php - About 2 hrs to fix

            Function drawTreeMapDiskUsage has 74 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function drawTreeMapDiskUsage(ctx, du_stats) {
                let dataset = [];
                let paths = [];
                let max = 0, min = null;
            
            
            Severity: Major
            Found in web-app/scripts.js - 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
                        Severity
                        Category
                        Status
                        Source
                        Language