wikimedia/mediawiki-core

View on GitHub
includes/jobqueue/JobQueueGroup.php

Summary

Maintainability
C
1 day
Test Coverage

Function pop has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function pop( $qtype = self::TYPE_DEFAULT, $flags = 0, array $ignored = [] ) {
        $job = false;

        if ( !$this->localJobClasses ) {
            throw new JobQueueError(
Severity: Minor
Found in includes/jobqueue/JobQueueGroup.php - About 3 hrs 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

Function push has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function push( $jobs ) {
        $jobs = is_array( $jobs ) ? $jobs : [ $jobs ];
        if ( $jobs === [] ) {
            return;
        }
Severity: Minor
Found in includes/jobqueue/JobQueueGroup.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 push has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function push( $jobs ) {
        $jobs = is_array( $jobs ) ? $jobs : [ $jobs ];
        if ( $jobs === [] ) {
            return;
        }
Severity: Minor
Found in includes/jobqueue/JobQueueGroup.php - About 1 hr to fix

    Method pop has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function pop( $qtype = self::TYPE_DEFAULT, $flags = 0, array $ignored = [] ) {
            $job = false;
    
            if ( !$this->localJobClasses ) {
                throw new JobQueueError(
    Severity: Minor
    Found in includes/jobqueue/JobQueueGroup.php - About 1 hr to fix

      Function getQueuesWithJobs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getQueuesWithJobs() {
              $types = [];
              foreach ( $this->getCoalescedQueues() as $info ) {
                  /** @var JobQueue $queue */
                  $queue = $info['queue'];
      Severity: Minor
      Found in includes/jobqueue/JobQueueGroup.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

      Function getCoalescedQueues has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getCoalescedQueues() {
              if ( $this->coalescedQueues === null ) {
                  $this->coalescedQueues = [];
                  foreach ( $this->jobTypeConfiguration as $type => $conf ) {
                      $conf['domain'] = $this->domain;
      Severity: Minor
      Found in includes/jobqueue/JobQueueGroup.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 __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              $domain,
              ReadOnlyMode $readOnlyMode,
              ?array $localJobClasses,
              array $jobTypeConfiguration,
              array $jobTypesExcludedFromDefaultQueue,
      Severity: Major
      Found in includes/jobqueue/JobQueueGroup.php - About 1 hr to fix

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

            public function getQueueSizes() {
                $sizeMap = [];
                foreach ( $this->getCoalescedQueues() as $info ) {
                    /** @var JobQueue $queue */
                    $queue = $info['queue'];
        Severity: Minor
        Found in includes/jobqueue/JobQueueGroup.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