wikimedia/mediawiki-core

View on GitHub
includes/api/ApiQueryBase.php

Summary

Maintainability
C
1 day
Test Coverage

ApiQueryBase has 32 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class ApiQueryBase extends ApiBase {
    use ApiQueryBlockInfoTrait;

    private ApiQuery $mQueryModule;
    private ?IReadableDatabase $mDb;
Severity: Minor
Found in includes/api/ApiQueryBase.php - About 4 hrs to fix

    File ApiQueryBase.php has 255 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/ApiQueryBase.php - About 2 hrs to fix

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

          protected function select( $method, $extraQuery = [], array &$hookData = null ) {
              $queryBuilder = clone $this->getQueryBuilder();
              if ( isset( $extraQuery['tables'] ) ) {
                  $queryBuilder->rawTables( (array)$extraQuery['tables'] );
              }
      Severity: Minor
      Found in includes/api/ApiQueryBase.php - About 1 hr to fix

        Function select has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function select( $method, $extraQuery = [], array &$hookData = null ) {
                $queryBuilder = clone $this->getQueryBuilder();
                if ( isset( $extraQuery['tables'] ) ) {
                    $queryBuilder->rawTables( (array)$extraQuery['tables'] );
                }
        Severity: Minor
        Found in includes/api/ApiQueryBase.php - About 45 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

        Method addTimestampWhereRange has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            protected function addTimestampWhereRange( $field, $dir, $start, $end, $sort = true ) {
        Severity: Minor
        Found in includes/api/ApiQueryBase.php - About 35 mins to fix

          Method addWhereRange has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              protected function addWhereRange( $field, $dir, $start, $end, $sort = true ) {
          Severity: Minor
          Found in includes/api/ApiQueryBase.php - About 35 mins to fix

            Function executeGenderCacheFromResultWrapper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function executeGenderCacheFromResultWrapper(
                    IResultWrapper $res, $fname = __METHOD__, $fieldPrefix = 'page'
                ) {
                    if ( !$res->numRows() ) {
                        return;
            Severity: Minor
            Found in includes/api/ApiQueryBase.php - About 25 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