wikimedia/mediawiki-core

View on GitHub
includes/specials/SpecialImport.php

Summary

Maintainability
F
3 days
Test Coverage

Function doImport has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

    private function doImport() {
        $isUpload = false;
        $request = $this->getRequest();
        $sourceName = $request->getVal( 'source' );
        $assignKnownUsers = $request->getCheck( 'assignKnownUsers' );
Severity: Minor
Found in includes/specials/SpecialImport.php - About 6 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 showForm has 148 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function showForm() {
        $action = $this->getPageTitle()->getLocalURL( [ 'action' => 'submit' ] );
        $user = $this->getUser();
        $out = $this->getOutput();
        $this->addHelpLink( 'https://meta.wikimedia.org/wiki/Special:MyLanguage/Help:Import', true );
Severity: Major
Found in includes/specials/SpecialImport.php - About 5 hrs to fix

    File SpecialImport.php has 380 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Implements Special:Import
     *
     * Copyright © 2003,2005 Brooke Vibber <bvibber@wikimedia.org>
    Severity: Minor
    Found in includes/specials/SpecialImport.php - About 5 hrs to fix

      Method doImport has 126 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function doImport() {
              $isUpload = false;
              $request = $this->getRequest();
              $sourceName = $request->getVal( 'source' );
              $assignKnownUsers = $request->getCheck( 'assignKnownUsers' );
      Severity: Major
      Found in includes/specials/SpecialImport.php - About 5 hrs to fix

        Function showForm has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            private function showForm() {
                $action = $this->getPageTitle()->getLocalURL( [ 'action' => 'submit' ] );
                $user = $this->getUser();
                $out = $this->getOutput();
                $this->addHelpLink( 'https://meta.wikimedia.org/wiki/Special:MyLanguage/Help:Import', true );
        Severity: Minor
        Found in includes/specials/SpecialImport.php - About 3 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 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function execute( $par ) {
                $this->useTransactionalTimeLimit();
        
                $this->setHeaders();
                $this->outputHeader();
        Severity: Minor
        Found in includes/specials/SpecialImport.php - About 1 hr to fix

          Method getMappingFormPart has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function getMappingFormPart( $sourceName ) {
                  $defaultNamespace = $this->getConfig()->get( MainConfigNames::ImportTargetNamespace );
                  return [
                      'mapping' => [
                          'type' => 'radio',
          Severity: Minor
          Found in includes/specials/SpecialImport.php - About 1 hr to fix

            There are no issues that match your filters.

            Category
            Status