Showing 334 of 371 total issues
Function migrate_10_utf8
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private static function migrate_10_utf8() {
$q = "SHOW INDEX FROM du_stats WHERE key_name = 'uniqness' AND column_name = 'full_path'";
$index_def = DB::getFirst($q);
if ($index_def->Sub_part > 269) {
$q = "ALTER TABLE du_stats DROP INDEX uniqness";
- 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 get_free_space
has 47 lines of code (exceeds 25 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();
Method convertStoragePoolDrivesTagFiles
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function convertStoragePoolDrivesTagFiles() {
global $going_drive;
$drives_definitions = Settings::get('sp_drives_definitions', TRUE);
if (!$drives_definitions) {
Function loadStoragePool
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function loadStoragePool() {
$.ajax({
type: 'POST',
url: './?ajax=get_storage_pool',
success: function(data, textStatus, jqXHR) {
Method getData
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getData() {
$groups = [];
/** @var $drives_selectors PoolDriveSelector[] */
$drives_selectors = Config::get(CONFIG_DRIVE_SELECTION_ALGORITHM);
Method next
has 45 lines of code (exceeds 25 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);
Method run
has 44 lines of code (exceeds 25 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)));
Function run
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function run() {
if (file_exists('/sbin/zpool')) {
if (exec("whoami") != 'root') {
$this->log("Warning: If you are using ZFS datasets as Greyhole storage pool drives, you will need to execute this as root.");
}
- 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 loadStoragePool
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function loadStoragePool() {
$.ajax({
type: 'POST',
url: './?ajax=get_storage_pool',
success: function(data, textStatus, jqXHR) {
- 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 loadStatus
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function loadStatus() {
$.ajax({
type: 'POST',
url: './?ajax=get_status',
success: function(data, textStatus, jqXHR) {
- 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 draft
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function draft() {
$drives = array();
$drives_last_resort = array();
while (count($drives)<$this->num_drives_per_draft) {
- 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_trash_share_symlink
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static function create_trash_share_symlink($filepath_in_trash, $trash_path) {
$trash_share = SharesConfig::getConfigForShare(CONFIG_TRASH_SHARE);
if ($trash_share) {
$filepath_in_trash = clean_dir($filepath_in_trash);
$filepath_in_trash_share = str_replace($trash_path, $trash_share[CONFIG_LANDING_ZONE], $filepath_in_trash);
- 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 connect
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function connect($retry_until_successful=FALSE, $throw_exception_on_error=FALSE, $timeout = 10) {
$connect_string = 'mysql:host=' . self::$options->host . ';dbname=' . self::$options->name . ';charset=utf8mb4';
try {
self::$handle = @new PDO($connect_string, self::$options->user, self::$options->pass, array(PDO::ATTR_TIMEOUT => $timeout, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
- 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_share
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function balance_share($share, $share_options, $min_file_size) {
Log::debug("├┐ Balancing share: $share ({$min_file_size}MB or + files)");
/** @var $drives_selectors PoolDriveSelector[] */
$drives_selectors = Config::get(CONFIG_DRIVE_SELECTION_ALGORITHM);
- 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 getSambaShares
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function getSambaShares() {
exec("/usr/bin/testparm -sl 2>/dev/null | grep '\[' | grep -vi '\[global]'", $output);
$all_samba_shares = [];
foreach ($output as $line) {
if (preg_match('/\s*\[(.+)]\s*$/', $line, $re)) {
- 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 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$landing_zone = get_share_landing_zone($this->share);
$log = "Will remove '$this->share' share from the Greyhole storage pool, by moving all the data files inside this share to it's landing zone: $landing_zone";
$this->log($log);
Method migrate
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function migrate() {
$db_version = (int) Settings::get('db_version');
if ($db_version < 11) {
DB::migrate_1_frozen_thaw();
DB::migrate_2_idle();
Method parse_line_share_option
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function parse_line_share_option($name, $value) {
if (!string_starts_with($name, [CONFIG_NUM_COPIES, CONFIG_DELETE_MOVES_TO_TRASH, CONFIG_MODIFIED_MOVES_TO_TRASH, CONFIG_DRIVE_SELECTION_GROUPS, CONFIG_DRIVE_SELECTION_ALGORITHM])) {
return FALSE;
}
if (!preg_match('/^(.*)\[\s*(.*)\s*]$/', $name, $matches)) {
Method execute
has 41 lines of code (exceeds 25 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;
Method run
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run() {
Log::setAction(ACTION_MD5_WORKER);
$drives_clause = array();
$params = array();