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 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 execute_next_task
has 103 lines of code (exceeds 25 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);
Function close_task
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function close_task($act, $share, $fd, $fullpath, &$tasks) {
if (!empty($fullpath)) {
$prop = 'full_path';
$prop_value = $fullpath;
} 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
Function close_all_tasks
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function close_all_tasks($tasks) {
$q = "SELECT COUNT(*) FROM tasks WHERE complete = 'no'";
$has_incomplete_tasks = (int) DB::getFirstValue($q);
$q = "SELECT COUNT(*) FROM tasks WHERE complete = 'written'";
- 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 close_all_tasks
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function close_all_tasks($tasks) {
$q = "SELECT COUNT(*) FROM tasks WHERE complete = 'no'";
$has_incomplete_tasks = (int) DB::getFirstValue($q);
$q = "SELECT COUNT(*) FROM tasks WHERE complete = 'written'";
Method close_task
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function close_task($act, $share, $fd, $fullpath, &$tasks) {
if (!empty($fullpath)) {
$prop = 'full_path';
$prop_value = $fullpath;
} else {
Method isFileLocked
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function isFileLocked($share, $full_path) {
$db_spool = static::getInstance();
$idx = clean_dir("$share/$full_path");
if (isset($db_spool->locked_files[$idx])) {
return $db_spool->locked_files[$idx];
Function delete_tasks
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function delete_tasks($task_ids) {
if (empty($task_ids)) {
return;
}
if (is_string($task_ids)) {
- 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 close_task
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function close_task($act, $share, $fd, $fullpath, &$tasks) {
Method insert
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function insert($action, $share, $full_path, $additional_info, $fd) {
Avoid too many return
statements within this method. Open
return FALSE;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return FALSE;
Avoid too many return
statements within this method. Open
return $result;
Function fetch_next_tasks
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function fetch_next_tasks($incl_md5, $update_idle, $include_written = TRUE) {
$where_clause = "";
if (!empty($this->locked_shares)) {
$where_clause .= " AND share NOT IN ('" . implode("','", array_keys($this->locked_shares)) . "')";
}
- 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 isFileLocked
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function isFileLocked($share, $full_path) {
$db_spool = static::getInstance();
$idx = clean_dir("$share/$full_path");
if (isset($db_spool->locked_files[$idx])) {
return $db_spool->locked_files[$idx];
- 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"