Showing 371 of 371 total issues
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"
Further reading
File DBSpool.php
has 401 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
Copyright 2009-2020 Guillaume Boudreau
This file is part of Greyhole.
Method change_config
has 133 lines of code (exceeds 25 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); };
}
Function trash_file
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
public static function trash_file($real_path, $file_was_modified = FALSE) {
$is_symlink = FALSE;
clearstatcache();
if (is_link($real_path)) {
$is_symlink = 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 samba_restart
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
public static function samba_restart() {
Log::info("The Samba daemon will now restart...");
if (is_file('/etc/init/smbd.conf')) {
exec("/sbin/restart smbd");
} else if (is_file('/etc/init.d/samba')) {
- 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 functions.inc.php
has 374 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
Copyright 2020 Guillaume Boudreau
This file is part of Greyhole.
Method init
has 123 lines of code (exceeds 25 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) {
Function get_free_space
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public static function get_free_space($for_sp_drive) {
if (time() > StoragePool::$last_df_time + Config::get(CONFIG_DF_CACHE_TIME)) {
$dfs = [];
exec(ConfigHelper::$df_command, $responses);
$responses_arr = array();
- 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 convertStoragePoolDrivesTagFiles
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public static function convertStoragePoolDrivesTagFiles() {
global $going_drive;
$drives_definitions = Settings::get('sp_drives_definitions', TRUE);
if (!$drives_definitions) {
- 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 execute
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$share = $this->share;
$full_path = $this->full_path;
$task_id = $this->id;
Method balance_file
has 119 lines of code (exceeds 25 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;
Function directory_uuid
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
public static function directory_uuid($dir) {
$dev = exec('df ' . escapeshellarg($dir) . ' 2> /dev/null | grep \'/dev\' | awk \'{print $1}\'');
if (!is_dir($dir)) {
return FALSE;
}
- 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
DB
has 36 functions (exceeds 20 allowed). Consider refactoring. Open
final class DB {
/** @var stdClass */
protected static $options; // connection options
/** @var PDO */
Method check_drives
has 116 lines of code (exceeds 25 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;
Function samba_check_vfs
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
public static function samba_check_vfs() {
$vfs_is_ok = FALSE;
// Samba version
$version = str_replace('.', '', SambaUtils::samba_get_version());
- 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 json_pretty_print
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
function json_pretty_print($json) {
if (defined('JSON_PRETTY_PRINT')) {
if (is_string($json)) {
$json = json_decode($json);
}
- 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_metafiles
has a Cognitive Complexity of 30 (exceeds 5 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);
- 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"