wikimedia/mediawiki-core

View on GitHub
maintenance/storage/trackBlobs.php

Summary

Maintainability
D
2 days
Test Coverage

Function findOrphanBlobs has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    private function findOrphanBlobs() {
        if ( !extension_loaded( 'gmp' ) ) {
            echo "Can't find orphan blobs, need bitfield support provided by GMP.\n";

            return;
Severity: Minor
Found in maintenance/storage/trackBlobs.php - About 5 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

File trackBlobs.php has 332 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Adds blobs from a given external storage cluster to the blob_tracking table.
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Minor
Found in maintenance/storage/trackBlobs.php - About 4 hrs to fix

    Method findOrphanBlobs has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function findOrphanBlobs() {
            if ( !extension_loaded( 'gmp' ) ) {
                echo "Can't find orphan blobs, need bitfield support provided by GMP.\n";
    
                return;
    Severity: Major
    Found in maintenance/storage/trackBlobs.php - About 3 hrs to fix

      Method trackRevisions has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function trackRevisions() {
              $dbw = $this->getPrimaryDB();
              $dbr = $this->getReplicaDB();
      
              $textClause = $this->getTextClause();
      Severity: Major
      Found in maintenance/storage/trackBlobs.php - About 3 hrs to fix

        Method trackOrphanText has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function trackOrphanText() {
                # Wait until the blob_tracking table is available in the replica DB
                $dbw = $this->getPrimaryDB();
                $dbr = $this->getReplicaDB();
                $this->getServiceContainer()->getDBLoadBalancerFactory()->waitForReplication( [ 'timeout' => 100_000 ] );
        Severity: Major
        Found in maintenance/storage/trackBlobs.php - About 2 hrs to fix

          Function trackOrphanText has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              private function trackOrphanText() {
                  # Wait until the blob_tracking table is available in the replica DB
                  $dbw = $this->getPrimaryDB();
                  $dbr = $this->getReplicaDB();
                  $this->getServiceContainer()->getDBLoadBalancerFactory()->waitForReplication( [ 'timeout' => 100_000 ] );
          Severity: Minor
          Found in maintenance/storage/trackBlobs.php - About 2 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 trackRevisions has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              private function trackRevisions() {
                  $dbw = $this->getPrimaryDB();
                  $dbr = $this->getReplicaDB();
          
                  $textClause = $this->getTextClause();
          Severity: Minor
          Found in maintenance/storage/trackBlobs.php - About 2 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

          There are no issues that match your filters.

          Category
          Status