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{
- 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_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{
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.
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
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 execute
has 101 lines of code (exceeds 25 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
Method gh_fsck
has 56 lines of code (exceeds 25 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);
Function gh_fsck_metastore
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function gh_fsck_metastore($root, $path, $share) {
if (!is_dir("$root$path")) {
// Try NFC form [http://en.wikipedia.org/wiki/Unicode_equivalence#Normalization]
$root = normalize_utf8_characters($root);
$path = normalize_utf8_characters($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
Method gh_fsck_metastore
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function gh_fsck_metastore($root, $path, $share) {
if (!is_dir("$root$path")) {
// Try NFC form [http://en.wikipedia.org/wiki/Unicode_equivalence#Normalization]
$root = normalize_utf8_characters($root);
$path = normalize_utf8_characters($path);
Method gh_fsck_file
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function gh_fsck_file($path, $filename, $file_type, $source, $share, $storage_path = FALSE, $num_retries = 1) {
Avoid deeply nested control flow statements. Open
while ($count_md5 > 500) {
Log::debug("MD5 tasks pending: $count_md5");
$query = "SELECT id, action, share, full_path, additional_info, complete FROM tasks WHERE complete = 'yes' AND action = 'md5' ORDER BY id LIMIT 1";
$task = DB::getFirst($query);
if ($task) {
Function gh_fsck_reset_du
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function gh_fsck_reset_du($share, $full_path=null) {
if (!$this->has_option(OPTION_DU)) {
$this->additional_info .= '|' . OPTION_DU;
}
$params = array('share' => $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
Avoid deeply nested control flow statements. Open
if (gh_is_file_locked($key) !== FALSE) {
Log::debug(" File copy is locked. Won't remove it.");
continue;
}
Avoid deeply nested control flow statements. Open
if (!$expected_md5) {
Log::debug(" MD5 not found in 'checksum' table ($share/$file_path/$filename). Will calculate it from the source file.");
$output = exec("md5sum " . escapeshellarg($original_file_path));
$output = explode(' ', $output);
$expected_md5 = $output[0];
Avoid deeply nested control flow statements. Open
if (isset($file_metafiles[$key])) {
unset($file_metafiles[$key]);
}
Avoid deeply nested control flow statements. Open
if (empty($file_path)) {
$expected_md5 = DB::getFirstValue($q, ['share' => $share, 'full_path' => $filename]);
}
Method update_symlink
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function update_symlink($target, $symlink, $share, $file_path, $filename) {
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;