Showing 334 of 371 total issues
File StoragePool.php
has 560 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
Copyright 2009-2020 Guillaume Boudreau
This file is part of Greyhole.
Function create_file_copies_from_metafiles
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
public static function create_file_copies_from_metafiles($metafiles, $share, $full_path, $source_file, $missing_only = FALSE) {
$landing_zone = get_share_landing_zone($share);
list($path, $filename) = explode_full_path($full_path);
- Read upRead up
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_mkdir
has a Cognitive Complexity of 57 (exceeds 5 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)) {
- Read upRead up
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 balance_file
has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring. Open
private function balance_file($file, $share, $share_options, $source_drive, &$pool_drives_avail_space, $balance_direction_asc, &$file_too_large_warnings) {
$num_total_drives = count($pool_drives_avail_space);
$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;
- Read upRead up
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 54 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
$new_conf_hash = static::get_conf_hash();
if ($this->has_option(OPTION_IF_CONF_CHANGED)) {
// Let's check if the conf file changed since the last fsck
- Read upRead up
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 choose_target_drives
has 210 lines of code (exceeds 25 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;
Method parse_samba_spool
has 197 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function parse_samba_spool() {
Log::setAction(ACTION_READ_SAMBA_POOL);
$db_spool = DBSpool::getInstance();
Function execute
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
$share = $this->share;
$full_path = $this->full_path;
$landing_zone = get_share_landing_zone($share);
- Read upRead up
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 DB.php
has 472 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
Copyright 2014-2020 Guillaume Boudreau
This file is part of Greyhole.
Function next
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
#[\ReturnTypeWillChange]
public function next() {
$this->metafiles = array();
while (count($this->directory_stack) > 0 && $this->directory_stack !== NULL) {
$dir = array_pop($this->directory_stack);
- Read upRead up
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 create_file_copy
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
public static function create_file_copy($source_file, &$destination_file, $expected_md5 = NULL, &$error = NULL) {
if (gh_is_file($source_file) && $source_file == $destination_file) {
Log::debug(" Destination $destination_file is the same as the source. Nothing to do here; this file copy is ready!");
return TRUE;
}
- Read upRead up
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
has a Cognitive Complexity of 46 (exceeds 5 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);
- Read upRead up
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_check_md5
has 173 lines of code (exceeds 25 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";
Method get_config_html
has 161 lines of code (exceeds 25 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'>";
Function create_file_copies
has a Cognitive Complexity of 42 (exceeds 5 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);
- Read upRead up
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 _log
has a Cognitive Complexity of 41 (exceeds 5 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) {
- Read upRead up
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_next_task
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
public function execute_next_task() {
if (!empty($this->next_tasks)) {
$task = array_shift($this->next_tasks);
} else {
$this->next_tasks = $this->fetch_next_tasks(TRUE, TRUE);
- Read upRead up
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 Metastores.php
has 425 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
Copyright 2009-2020 Guillaume Boudreau
This file is part of Greyhole.
Method execute
has 152 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$this->fix_symlinks_scanned_dirs = [];
$share = $this->share;
$full_path = $this->full_path;
Function save_metafiles
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
public static function save_metafiles($share, $path, $filename, $metafiles) {
if (count($metafiles) == 0) {
static::remove_metafiles($share, $path, $filename);
return;
}
- Read upRead up
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"