wikimedia/mediawiki-core

View on GitHub
includes/jobqueue/JobQueueRedis.php

Summary

Maintainability
D
2 days
Test Coverage

File JobQueueRedis.php has 499 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
Severity: Minor
Found in includes/jobqueue/JobQueueRedis.php - About 1 day to fix

    JobQueueRedis has 37 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class JobQueueRedis extends JobQueue {
        /** @var RedisConnectionPool */
        protected $redisPool;
        /** @var LoggerInterface */
        protected $logger;
    Severity: Minor
    Found in includes/jobqueue/JobQueueRedis.php - About 4 hrs to fix

      Method pushBlobs has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      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'];
      Severity: Major
      Found in includes/jobqueue/JobQueueRedis.php - About 2 hrs to fix

        Method doBatchPush has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        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 );
        Severity: Minor
        Found in includes/jobqueue/JobQueueRedis.php - About 1 hr to fix

          Function doBatchPush has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          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 );
          Severity: Minor
          Found in includes/jobqueue/JobQueueRedis.php - About 1 hr to fix

          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

              protected function doAck( RunnableJob $job ) {
                  $uuid = $job->getMetadata( 'uuid' );
                  if ( $uuid === null ) {
                      throw new UnexpectedValueException( "Job of type '{$job->getType()}' has no UUID." );
                  }
          Severity: Minor
          Found in includes/jobqueue/JobQueueRedis.php - About 1 hr to fix

            Method popAndAcquireBlob has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function popAndAcquireBlob( RedisConnRef $conn ) {
                    static $script =
                    /** @lang Lua */
            <<<LUA
                    local kUnclaimed, kSha1ById, kIdBySha1, kClaimed, kAttempts, kData = unpack(KEYS)
            Severity: Minor
            Found in includes/jobqueue/JobQueueRedis.php - About 1 hr to fix

              Function unserialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function unserialize( $blob ) {
                      $fields = unserialize( $blob );
                      if ( is_object( $fields ) ) {
                          if ( $fields->enc === 'gzip' && function_exists( 'gzinflate' ) ) {
                              $fields = unserialize( gzinflate( $fields->blob ) );
              Severity: Minor
              Found in includes/jobqueue/JobQueueRedis.php - About 35 mins to fix

              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

              There are no issues that match your filters.

              Category
              Status