wikimedia/mediawiki-core

View on GitHub
includes/api/ApiQueryBlocks.php

Summary

Maintainability
F
4 days
Test Coverage

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

    public function execute() {
        $db = $this->getDB();
        $params = $this->extractRequestParams();
        $this->requireMaxOneParameter( $params, 'users', 'ip' );

Severity: Minor
Found in includes/api/ApiQueryBlocks.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

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

    public function execute() {
        $db = $this->getDB();
        $params = $this->extractRequestParams();
        $this->requireMaxOneParameter( $params, 'users', 'ip' );

Severity: Major
Found in includes/api/ApiQueryBlocks.php - About 1 day to fix

    File ApiQueryBlocks.php has 438 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Copyright © 2007 Roan Kattouw <roan.kattouw@gmail.com>
     *
     * This program is free software; you can redistribute it and/or modify
    Severity: Minor
    Found in includes/api/ApiQueryBlocks.php - About 6 hrs to fix

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

          public function getAllowedParams() {
              $blockCIDRLimit = $this->getConfig()->get( MainConfigNames::BlockCIDRLimit );
      
              return [
                  'start' => [
      Severity: Major
      Found in includes/api/ApiQueryBlocks.php - About 3 hrs to fix

        Method getRestrictionData has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function getRestrictionData( IResultWrapper $result, $limit ) {
                $partialIds = [];
                $count = 0;
                foreach ( $result as $row ) {
                    if ( ++$count <= $limit && !( $row->ipb_sitewide ?? $row->bl_sitewide ) ) {
        Severity: Minor
        Found in includes/api/ApiQueryBlocks.php - About 1 hr to fix

          Function getRestrictionData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getRestrictionData( IResultWrapper $result, $limit ) {
                  $partialIds = [];
                  $count = 0;
                  foreach ( $result as $row ) {
                      if ( ++$count <= $limit && !( $row->ipb_sitewide ?? $row->bl_sitewide ) ) {
          Severity: Minor
          Found in includes/api/ApiQueryBlocks.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

          Consider simplifying this complex logical expression.
          Open

                      if ( ( isset( $show['account'] ) && isset( $show['!account'] ) )
                          || ( isset( $show['ip'] ) && isset( $show['!ip'] ) )
                          || ( isset( $show['range'] ) && isset( $show['!range'] ) )
                          || ( isset( $show['temp'] ) && isset( $show['!temp'] ) )
                      ) {
          Severity: Critical
          Found in includes/api/ApiQueryBlocks.php - About 1 hr to fix

            Method __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    ApiQuery $query,
                    $moduleName,
                    DatabaseBlockStore $blockStore,
                    BlockActionInfo $blockActionInfo,
                    BlockRestrictionStore $blockRestrictionStore,
            Severity: Major
            Found in includes/api/ApiQueryBlocks.php - About 50 mins to fix

              There are no issues that match your filters.

              Category
              Status