wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function animateFilterAndLang has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    private function animateFilterAndLang( $name ) {
        $this->debug( "animate filter for tag $name" );
        if ( $this->reader->nodeType !== XMLReader::ELEMENT ) {
            return;
        }
Severity: Minor
Found in includes/media/SVGReader.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 contributionsSub has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    protected function contributionsSub( $userObj, $targetName ) {
        $isAnon = $userObj->isAnon();
        if ( !$isAnon && $userObj->isHidden() &&
            !$this->permissionManager->userHasRight( $this->getUser(), 'hideuser' )
        ) {
Severity: Minor
Found in includes/specialpage/ContributionsSpecialPage.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 execute has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        // ConvertibleTimestamp::time() used so we can fake the current time in tests
        $endTime = ConvertibleTimestamp::time() + self::MAX_EXECUTE_SECONDS;

        $props = array_fill_keys( $this->getParameter( 'prop' ), true );
Severity: Minor
Found in includes/api/ApiQueryLanguageinfo.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 execute has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $services = $this->getServiceContainer();
        $permissionManager = $services->getPermissionManager();

        $request = $this->getRequest();
Severity: Minor
Found in includes/filerepo/AuthenticatedFileEntryPoint.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 execute has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        global $IP;

        // We want to allow "" for the wikidb, meaning don't call select_db()
        $wiki = $this->hasOption( 'wikidb' ) ? $this->getOption( 'wikidb' ) : false;
Severity: Minor
Found in maintenance/sql.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 doDBUpdates has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doDBUpdates() {
        $mode = $this->getOption( 'mode', 'both' );
        $begin = $this->getOption( 'begin', '' );
        $throttle = $this->getOption( 'throttle', 0 );

Severity: Minor
Found in maintenance/cleanupEmptyCategories.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 execute has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        // Extensions will do stuff like $wgResourceModules += array(...) which is a
        // fatal unless an array is already set. So set an empty value.
        // And use the weird $__settings name to avoid any conflicts
        // with real poorly named settings.
Severity: Minor
Found in maintenance/convertExtensionToRegistration.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 checkNamespace has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkNamespace( $ns, $name, $options ) {
        $targets = $this->getTargetList( $ns, $name, $options );
        $count = $targets->numRows();
        $this->totalPages += $count;
        if ( $count == 0 ) {
Severity: Minor
Found in maintenance/namespaceDupes.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 execute has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $username = $this->getArg( 0 );
        $password = $this->getArg( 1 );
        $force = $this->hasOption( 'force' );
        $inGroups = [];
Severity: Minor
Found in maintenance/createAndPromote.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

File PPFrame_Hash.php has 413 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Minor
Found in includes/parser/PPFrame_Hash.php - About 5 hrs to fix

    File ParserCache.php has 413 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Cache for outputs of the PHP parser
     *
     * This program is free software; you can redistribute it and/or modify
    Severity: Minor
    Found in includes/parser/ParserCache.php - About 5 hrs to fix

      File LocalRepo.php has 413 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * This program is free software; you can redistribute it and/or modify
       * it under the terms of the GNU General Public License as published by
       * the Free Software Foundation; either version 2 of the License, or
      Severity: Minor
      Found in includes/filerepo/LocalRepo.php - About 5 hrs to fix

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

            public function execute() {
                $oldLayout = $this->getOption( 'oldlayout' );
                if ( !in_array( $oldLayout, [ 'name', 'sha1' ] ) ) {
                    $this->fatalError( "Invalid old layout." );
                }
        Severity: Major
        Found in maintenance/migrateFileRepoLayout.php - About 5 hrs to fix

          Method cleanupTable has 147 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function cleanupTable( $tableParams ) {
                  [ $table, $prefix ] = $tableParams;
                  $idField = $tableParams['idField'] ?? "{$prefix}_id";
                  $nsField = $tableParams['nsField'] ?? "{$prefix}_namespace";
                  $titleField = $tableParams['titleField'] ?? "{$prefix}_title";
          Severity: Major
          Found in maintenance/cleanupInvalidDbKeys.php - About 5 hrs to fix

            Function updateUI has 146 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                mw.widgets.CalendarWidget.prototype.updateUI = function ( fade ) {
                    const $bodyWrapper = this.$bodyWrapper;
            
                    if ( this.lazyInitOnToggle ) {
                        // We're being called from the constructor and not being shown yet, do nothing
            Severity: Major
            Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js - About 5 hrs to fix

              Method doTransform has 146 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
                      if ( !$this->normaliseParams( $image, $params ) ) {
                          return new TransformParameterError( $params );
                      }
              
              
              Severity: Major
              Found in includes/media/TransformationalImageHandler.php - About 5 hrs to fix

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

                    protected function run( ApiPageSet $resultPageSet = null ) {
                        $db = $this->getDB();
                        $params = $this->extractRequestParams( false );
                
                        $result = $this->getResult();
                Severity: Major
                Found in includes/api/ApiQueryAllRevisions.php - About 5 hrs to fix

                  LBFactory has 43 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  abstract class LBFactory implements ILBFactory {
                      /** @var CriticalSectionProvider|null */
                      private $csProvider;
                      /**
                       * @var callable|null An optional callback that returns a ScopedCallback instance,
                  Severity: Minor
                  Found in includes/libs/rdbms/lbfactory/LBFactory.php - About 5 hrs to fix

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                    $namespaceAliases = [
                        'Medija'                   => NS_MEDIA,
                        'Specijalno'               => NS_SPECIAL,
                        'Saradnik'                 => NS_USER,
                        'Suradnik'                 => NS_USER,
                    Severity: Major
                    Found in languages/messages/MessagesSr_el.php and 1 other location - About 5 hrs to fix
                    languages/messages/MessagesJv.php on lines 29..54

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 200.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                    $namespaceAliases = [ // Kept former namespaces for backwards compatibility - T155957
                        'Cithakan_Dhiskusi'    => NS_TEMPLATE_TALK,
                        'Dhiskusi'             => NS_TALK,
                        'Dhiskusi_$1'          => NS_PROJECT_TALK,
                        'Dhiskusi_Cithakan'    => NS_TEMPLATE_TALK,
                    Severity: Major
                    Found in languages/messages/MessagesJv.php and 1 other location - About 5 hrs to fix
                    languages/messages/MessagesSr_el.php on lines 47..72

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 200.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Severity
                    Category
                    Status
                    Source
                    Language