gboudreau/Greyhole

View on GitHub

Showing 371 of 371 total issues

Function gh_fsck_file has a Cognitive Complexity of 489 (exceeds 5 allowed). Consider refactoring.
Open

    public function gh_fsck_file($path, $filename, $file_type, $source, $share, $storage_path = FALSE, $num_retries = 1) {
        $landing_zone = get_share_landing_zone($share);
        if($storage_path === FALSE) {
            $file_path = trim(mb_substr($path, mb_strlen($landing_zone)+1), '/');
        }else{
Severity: Minor
Found in includes/Tasks/FsckTask.php - About 1 wk 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_check_md5 has a Cognitive Complexity of 179 (exceeds 5 allowed). Consider refactoring.
Open

    public static function gh_check_md5($task) {
        /** @var $task AbstractTask */
        $share_options = SharesConfig::getConfigForShare($task->share);

        $query = "SELECT complete, COUNT(*) AS num, GROUP_CONCAT(id) AS ids FROM tasks WHERE action = 'md5' AND share = :share AND full_path = :full_path GROUP BY complete ORDER BY complete";
Severity: Minor
Found in includes/Tasks/Md5Task.php - About 3 days 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 choose_target_drives has a Cognitive Complexity of 164 (exceeds 5 allowed). Consider refactoring.
Open

    public static function choose_target_drives($filesize_kb, $include_full_drives, $share, $path, $log_prefix = '', &$is_sticky = NULL) {
        global $last_OOS_notification;

        foreach (SharesConfig::get($share, CONFIG_DRIVE_SELECTION_ALGORITHM) as $ds) {
            $algo = $ds->selection_algorithm;
Severity: Minor
Found in includes/StoragePool.php - About 3 days 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

File scripts.js has 1209 lines of code (exceeds 250 allowed). Consider refactoring.
Open


window.chartColors = {
    red: 'rgba(222, 66, 91, 1)',
    orange: 'rgba(255, 159, 64, 1)',
    yellow: 'rgba(255, 236, 152, 1)',
Severity: Major
Found in web-app/scripts.js - About 3 days to fix

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

        public function execute() {
            $this->fix_symlinks_scanned_dirs = [];
    
            $share = $this->share;
            $full_path = $this->full_path;
    Severity: Minor
    Found in includes/Tasks/RenameTask.php - About 2 days 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_samba_spool has a Cognitive Complexity of 111 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function parse_samba_spool() {
            Log::setAction(ACTION_READ_SAMBA_POOL);
    
            $db_spool = DBSpool::getInstance();
    
    
    Severity: Minor
    Found in includes/SambaSpool.php - About 2 days 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_file has 440 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function gh_fsck_file($path, $filename, $file_type, $source, $share, $storage_path = FALSE, $num_retries = 1) {
            $landing_zone = get_share_landing_zone($share);
            if($storage_path === FALSE) {
                $file_path = trim(mb_substr($path, mb_strlen($landing_zone)+1), '/');
            }else{
    Severity: Major
    Found in includes/Tasks/FsckTask.php - About 2 days to fix

      File common.php has 797 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /*
      Copyright 2009-2020 Guillaume Boudreau, Andrew Hopkinson
      
      This file is part of Greyhole.
      Severity: Major
      Found in includes/common.php - About 1 day to fix

        Function getopt has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function getopt($short_options, $long_options) {
                $opts_no_value = array();
                $opts_required_value = array();
                $opts_optional_value = array();
        
        
        Severity: Minor
        Found in includes/CLI/CommandLineHelper.php - About 1 day 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 91 (exceeds 5 allowed). Consider refactoring.
        Open

            public function execute() {
                $share = $this->share;
                $full_path = $this->full_path;
                $task_id = $this->id;
        
        
        Severity: Minor
        Found in includes/Tasks/WriteTask.php - About 1 day 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 change_config has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function change_config($name, $value, $log_fct, &$error = NULL) {
                if (empty($log_fct)) {
                    $log_fct = function($log) { error_log($log); };
                }
        
        
        Severity: Minor
        Found in includes/CLI/ConfigCliRunner.php - About 1 day 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

        File FsckTask.php has 710 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /*
        Copyright 2009-2020 Guillaume Boudreau
        
        This file is part of Greyhole.
        Severity: Major
        Found in includes/Tasks/FsckTask.php - About 1 day to fix

          Function get_config_html has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
          Open

          function get_config_html($config, $current_value = NULL, $fixed_width_label = TRUE) {
              $config = (object) $config;
              $html = '';
              if ($config->type == 'group') {
                  $html .= "<div class='input_group mt-4'>";
          Severity: Minor
          Found in web-app/functions.inc.php - About 1 day 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

          File ConfigHelper.php has 649 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /*
          Copyright 2014-2017 Guillaume Boudreau
          
          This file is part of Greyhole.
          Severity: Major
          Found in includes/ConfigHelper.php - About 1 day to fix

            File init.inc.php has 631 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /*
            Copyright 2020 Guillaume Boudreau
            
            This file is part of Greyhole.
            Severity: Major
            Found in web-app/init.inc.php - About 1 day to fix

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

                  private static function init() {
                      Log::setLevel(Config::get(CONFIG_LOG_LEVEL));
              
                      self::$df_command = "df -k";
                      foreach (Config::storagePoolDrives() as $sp_drive) {
              Severity: Minor
              Found in includes/ConfigHelper.php - About 1 day 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 inject_in_file has a Cognitive Complexity of 70 (exceeds 5 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 day 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_metafiles_for_file has a Cognitive Complexity of 68 (exceeds 5 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: Minor
              Found in includes/Metastores.php - About 1 day 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

              File test_cases.php has 614 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              #!/usr/bin/php
              <?php
              /*
              Copyright 2010-2020 Guillaume Boudreau
              
              
              Severity: Major
              Found in test_cases.php - About 1 day to fix

                Function check_drives has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function check_drives() {
                        Log::setAction(ACTION_CHECK_POOL);
                
                        // If last 'df' ran less than 10s ago, all the drives are already awake; no harm checking them at this time.
                        global $last_df_time;
                Severity: Minor
                Found in includes/StoragePool.php - About 1 day 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