wikimedia/mediawiki-core

View on GitHub
includes/api/ApiQueryBacklinks.php

Summary

Maintainability
F
4 days
Test Coverage

Function run has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    private function run( $resultPageSet = null ) {
        $this->params = $this->extractRequestParams( false );
        $this->redirect = isset( $this->params['redirect'] ) && $this->params['redirect'];
        $userMax = ( $this->redirect ? ApiBase::LIMIT_BIG1 / 2 : ApiBase::LIMIT_BIG1 );
        $botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2 / 2 : ApiBase::LIMIT_BIG2 );
Severity: Minor
Found in includes/api/ApiQueryBacklinks.php - About 1 day 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 ApiQueryBacklinks.php has 463 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Minor
Found in includes/api/ApiQueryBacklinks.php - About 7 hrs to fix

    Method run has 132 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function run( $resultPageSet = null ) {
            $this->params = $this->extractRequestParams( false );
            $this->redirect = isset( $this->params['redirect'] ) && $this->params['redirect'];
            $userMax = ( $this->redirect ? ApiBase::LIMIT_BIG1 / 2 : ApiBase::LIMIT_BIG1 );
            $botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2 / 2 : ApiBase::LIMIT_BIG2 );
    Severity: Major
    Found in includes/api/ApiQueryBacklinks.php - About 5 hrs to fix

      Function runSecondQuery has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          private function runSecondQuery( $resultPageSet = null ) {
              $db = $this->getDB();
              if ( isset( $this->linksMigration::$mapping[$this->bl_table] ) ) {
                  $queryInfo = $this->linksMigration->getQueryInfo( $this->bl_table, $this->bl_table );
                  $this->addTables( $queryInfo['tables'] );
      Severity: Minor
      Found in includes/api/ApiQueryBacklinks.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

      Function runFirstQuery has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          private function runFirstQuery( $resultPageSet = null ) {
              $this->addTables( [ $this->bl_table, 'page' ] );
              $this->addWhere( "{$this->bl_from}=page_id" );
              if ( $resultPageSet === null ) {
                  $this->addFields( [ 'page_id', 'page_title', 'page_namespace' ] );
      Severity: Minor
      Found in includes/api/ApiQueryBacklinks.php - About 4 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 runSecondQuery has 102 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function runSecondQuery( $resultPageSet = null ) {
              $db = $this->getDB();
              if ( isset( $this->linksMigration::$mapping[$this->bl_table] ) ) {
                  $queryInfo = $this->linksMigration->getQueryInfo( $this->bl_table, $this->bl_table );
                  $this->addTables( $queryInfo['tables'] );
      Severity: Major
      Found in includes/api/ApiQueryBacklinks.php - About 4 hrs to fix

        Method runFirstQuery has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function runFirstQuery( $resultPageSet = null ) {
                $this->addTables( [ $this->bl_table, 'page' ] );
                $this->addWhere( "{$this->bl_from}=page_id" );
                if ( $resultPageSet === null ) {
                    $this->addFields( [ 'page_id', 'page_title', 'page_namespace' ] );
        Severity: Major
        Found in includes/api/ApiQueryBacklinks.php - About 2 hrs to fix

          Method getAllowedParams has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getAllowedParams() {
                  $retval = [
                      'title' => [
                          ParamValidator::PARAM_TYPE => 'string',
                      ],
          Severity: Minor
          Found in includes/api/ApiQueryBacklinks.php - About 1 hr to fix

            There are no issues that match your filters.

            Category
            Status