wikimedia/mediawiki-core

View on GitHub
includes/api/ApiQuery.php

Summary

Maintainability
F
3 days
Test Coverage

File ApiQuery.php has 827 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: Major
Found in includes/api/ApiQuery.php - About 1 day to fix

    Method outputGeneralPageInfo has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function outputGeneralPageInfo() {
            $pageSet = $this->getPageSet();
            $result = $this->getResult();
    
            // We can't really handle max-result-size failure here, but we need to
    Severity: Major
    Found in includes/api/ApiQuery.php - About 3 hrs to fix

      Function outputGeneralPageInfo has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          private function outputGeneralPageInfo() {
              $pageSet = $this->getPageSet();
              $result = $this->getResult();
      
              // We can't really handle max-result-size failure here, but we need to
      Severity: Minor
      Found in includes/api/ApiQuery.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 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function execute() {
              $this->mParams = $this->extractRequestParams();
      
              // Instantiate requested modules
              $allModules = [];
      Severity: Major
      Found in includes/api/ApiQuery.php - About 2 hrs to fix

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

            private function instantiateModules( &$modules, $param ) {
                $wasPosted = $this->getRequest()->wasPosted();
                if ( isset( $this->mParams[$param] ) ) {
                    foreach ( $this->mParams[$param] as $moduleName ) {
                        $instance = $this->mModuleMgr->getModule( $moduleName, $param );
        Severity: Minor
        Found in includes/api/ApiQuery.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

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

            public function execute() {
                $this->mParams = $this->extractRequestParams();
        
                // Instantiate requested modules
                $allModules = [];
        Severity: Minor
        Found in includes/api/ApiQuery.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 getAllowedParams has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getAllowedParams( $flags = 0 ) {
                $result = [
                    'prop' => [
                        ParamValidator::PARAM_ISMULTI => true,
                        ParamValidator::PARAM_TYPE => 'submodule',
        Severity: Minor
        Found in includes/api/ApiQuery.php - About 1 hr to fix

          Method doExport has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function doExport( $pageSet, $result ) {
                  $exportTitles = [];
                  $titles = $pageSet->getGoodPages();
                  if ( count( $titles ) ) {
                      /** @var Title $title */
          Severity: Minor
          Found in includes/api/ApiQuery.php - About 1 hr to fix

            Function doExport has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private function doExport( $pageSet, $result ) {
                    $exportTitles = [];
                    $titles = $pageSet->getGoodPages();
                    if ( count( $titles ) ) {
                        /** @var Title $title */
            Severity: Minor
            Found in includes/api/ApiQuery.php - About 55 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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    ApiMain $main,
                    $action,
                    ObjectFactory $objectFactory,
                    WikiExporterFactory $wikiExporterFactory,
                    TitleFormatter $titleFormatter,
            Severity: Minor
            Found in includes/api/ApiQuery.php - About 45 mins to fix

              Function isReadMode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function isReadMode() {
                      // We need to make an exception for certain meta modules that should be
                      // accessible even without the 'read' right. Restrict the exception as
                      // much as possible: no other modules allowed, and no pageset
                      // parameters either. We do allow the 'rawcontinue' and 'indexpageids'
              Severity: Minor
              Found in includes/api/ApiQuery.php - About 35 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