wikimedia/mediawiki-core

View on GitHub
maintenance/refreshLinks.php

Summary

Maintainability
C
1 day
Test Coverage

File refreshLinks.php has 276 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 maintenance/refreshLinks.php - About 2 hrs to fix

    Function execute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public function execute() {
            // Note that there is a difference between not specifying the start
            // and end IDs and using the minimum and maximum values from the page
            // table. In the latter case, deleteLinksFromNonexistent() will not
            // delete entries for nonexistent IDs that fall outside the range.
    Severity: Minor
    Found in maintenance/refreshLinks.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

    Method execute has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function execute() {
            // Note that there is a difference between not specifying the start
            // and end IDs and using the minimum and maximum values from the page
            // table. In the latter case, deleteLinksFromNonexistent() will not
            // delete entries for nonexistent IDs that fall outside the range.
    Severity: Major
    Found in maintenance/refreshLinks.php - About 2 hrs to fix

      Method dfnCheckInterval has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function dfnCheckInterval( $start = null, $end = null, $batchSize = 100 ) {
              $dbw = $this->getPrimaryDB();
              $dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] );
      
              $linksTables = [
      Severity: Minor
      Found in maintenance/refreshLinks.php - About 1 hr to fix

        Method doRefreshLinks has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function doRefreshLinks(
                SelectQueryBuilder $builder,
                bool $redirectsOnly = false,
                array $indexFields = [ 'page_id' ]
            ) {
        Severity: Minor
        Found in maintenance/refreshLinks.php - About 1 hr to fix

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

              private function doRefreshLinks(
                  SelectQueryBuilder $builder,
                  bool $redirectsOnly = false,
                  array $indexFields = [ 'page_id' ]
              ) {
          Severity: Minor
          Found in maintenance/refreshLinks.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 fixRedirect has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function fixRedirect( Maintenance $maint, $id ) {
                  $page = $maint->getServiceContainer()->getWikiPageFactory()->newFromID( $id );
          
                  // In case the page just got deleted.
                  if ( $page === null ) {
          Severity: Minor
          Found in maintenance/refreshLinks.php - About 1 hr to fix

            There are no issues that match your filters.

            Category
            Status