includes/jobqueue/JobQueueRedis.php
File JobQueueRedis.php
has 499 lines of code (exceeds 250 allowed). Consider refactoring. Open
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
JobQueueRedis
has 37 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class JobQueueRedis extends JobQueue {
/** @var RedisConnectionPool */
protected $redisPool;
/** @var LoggerInterface */
protected $logger;
Method pushBlobs
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function pushBlobs( RedisConnRef $conn, array $items ) {
$args = [ $this->encodeQueueName() ];
// Next args come in 4s ([id, sha1, rtime, blob [, id, sha1, rtime, blob ... ] ] )
foreach ( $items as $item ) {
$args[] = (string)$item['uuid'];
Method doBatchPush
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function doBatchPush( array $jobs, $flags ) {
// Convert the jobs into field maps (de-duplicated against each other)
$items = []; // (job ID => job fields map)
foreach ( $jobs as $job ) {
$item = $this->getNewJobFields( $job );
Function doBatchPush
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function doBatchPush( array $jobs, $flags ) {
// Convert the jobs into field maps (de-duplicated against each other)
$items = []; // (job ID => job fields map)
foreach ( $jobs as $job ) {
$item = $this->getNewJobFields( $job );
- 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 doAck
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function doAck( RunnableJob $job ) {
$uuid = $job->getMetadata( 'uuid' );
if ( $uuid === null ) {
throw new UnexpectedValueException( "Job of type '{$job->getType()}' has no UUID." );
}
Method popAndAcquireBlob
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function popAndAcquireBlob( RedisConnRef $conn ) {
static $script =
/** @lang Lua */
<<<LUA
local kUnclaimed, kSha1ById, kIdBySha1, kClaimed, kAttempts, kData = unpack(KEYS)
Function unserialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function unserialize( $blob ) {
$fields = unserialize( $blob );
if ( is_object( $fields ) ) {
if ( $fields->enc === 'gzip' && function_exists( 'gzinflate' ) ) {
$fields = unserialize( gzinflate( $fields->blob ) );
- 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"