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);
- 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 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
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.
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
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"
Further reading
Function choose_metastores_backups
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public static function choose_metastores_backups($try_restore=TRUE) {
$num_metastore_backups_needed = 2;
if (count(Config::storagePoolDrives()) < 2) {
Config::set(CONFIG_METASTORE_BACKUPS, array());
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
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);
Method create_metafiles
has 55 lines of code (exceeds 25 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);
Method save_metafiles
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function save_metafiles($share, $path, $filename, $metafiles) {
if (count($metafiles) == 0) {
static::remove_metafiles($share, $path, $filename);
return;
}
Method choose_metastores_backups
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function choose_metastores_backups($try_restore=TRUE) {
$num_metastore_backups_needed = 2;
if (count(Config::storagePoolDrives()) < 2) {
Config::set(CONFIG_METASTORE_BACKUPS, array());
return;
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);
Function get_metastores
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function get_metastores($use_cache=TRUE) {
if (!$use_cache) {
static::$metastores = [];
}
if (empty(static::$metastores)) {
- 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 get_metafile_data_filenames
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function get_metafile_data_filenames($share, $path, $filename, $first_only=FALSE) {
$filenames = array();
if ($first_only) {
$share_file = get_share_landing_zone($share) . "/$path/$filename";
- 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_metafiles
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function get_metafiles($share, $path, $filename=NULL, $load_nok_metafiles=FALSE, $quiet=FALSE, $check_symlink=TRUE) {
Method get_metafiles_for_file
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function get_metafiles_for_file($share, $path, $filename=NULL, $load_nok_metafiles=FALSE, $quiet=FALSE, $check_symlink=TRUE) {
Avoid deeply nested control flow statements. Open
if (isset($this->metafiles[$full_filename])) {
continue;
}
Avoid deeply nested control flow statements. Open
if ($file=='.' || $file=='..') {
continue;
}
Avoid deeply nested control flow statements. Open
} else if (empty($metafile->is_linked) && $metafile->path == $share_file_link_to) {
if (!$quiet) {
Log::debug(' Changing is_linked to TRUE for ' . $metafile->path);
}
$metafile->is_linked = TRUE;
Avoid deeply nested control flow statements. Open
if (!$quiet) {
Log::debug(' Changing is_linked to FALSE for ' . $metafile->path);
}
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct($share, $path, $load_nok_metafiles=FALSE, $quiet=FALSE, $check_symlink=TRUE) {
Method create_metafiles
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function create_metafiles($share, $full_path, $num_copies_required, $filesize, $metafiles=[]) {