File JobQueueDB.php
has 640 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
JobQueueDB
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
class JobQueueDB extends JobQueue {
/* seconds to cache info without re-validating */
private const CACHE_TTL_SHORT = 30;
/* seconds a job can live once claimed */
private const MAX_AGE_PRUNE = 7 * 24 * 3600;
Method recycleAndDeleteStaleJobs
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function recycleAndDeleteStaleJobs() {
$now = time();
$count = 0; // affected rows
$dbw = $this->getPrimaryDB();
/** @noinspection PhpUnusedLocalVariableInspection */
Method claimRandom
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function claimRandom( $uuid, $rand, $gte ) {
$dbw = $this->getPrimaryDB();
/** @noinspection PhpUnusedLocalVariableInspection */
$scope = $this->getScopedNoTrxFlag( $dbw );
// Check cache to see if the queue has <= OFFSET items
Method doBatchPushInternal
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function doBatchPushInternal( IDatabase $dbw, array $jobs, $flags, $method ) {
if ( $jobs === [] ) {
return;
}
Method claimOldest
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function claimOldest( $uuid ) {
$dbw = $this->getPrimaryDB();
/** @noinspection PhpUnusedLocalVariableInspection */
$scope = $this->getScopedNoTrxFlag( $dbw );
Function doBatchPushInternal
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function doBatchPushInternal( IDatabase $dbw, array $jobs, $flags, $method ) {
if ( $jobs === [] ) {
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 claimRandom
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function claimRandom( $uuid, $rand, $gte ) {
$dbw = $this->getPrimaryDB();
/** @noinspection PhpUnusedLocalVariableInspection */
$scope = $this->getScopedNoTrxFlag( $dbw );
// Check cache to see if the queue has <= OFFSET items
- 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 getDB
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getDB( $index ) {
if ( $this->server ) {
if ( $this->conn instanceof IDatabase ) {
return $this->conn;
} elseif ( $this->conn instanceof DBError ) {
Function getDB
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function getDB( $index ) {
if ( $this->server ) {
if ( $this->conn instanceof IDatabase ) {
return $this->conn;
} elseif ( $this->conn instanceof DBError ) {
- 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 doPop
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doPop() {
$dbw = $this->getPrimaryDB();
/** @noinspection PhpUnusedLocalVariableInspection */
$scope = $this->getScopedNoTrxFlag( $dbw );
Method doGetAbandonedCount
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doGetAbandonedCount() {
if ( $this->claimTTL <= 0 ) {
return 0; // no acknowledgements
}
Function doPop
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function doPop() {
$dbw = $this->getPrimaryDB();
/** @noinspection PhpUnusedLocalVariableInspection */
$scope = $this->getScopedNoTrxFlag( $dbw );
- 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 recycleAndDeleteStaleJobs
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function recycleAndDeleteStaleJobs() {
$now = time();
$count = 0; // affected rows
$dbw = $this->getPrimaryDB();
/** @noinspection PhpUnusedLocalVariableInspection */
- 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"