wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

    public function addCategoryLinks( array $categories ) {
        if ( !$categories ) {
            return;
        }

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

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

    public function execute() {
        $lastName = $this->getOption( 'start', '' );

        $repo = $this->getServiceContainer()->getRepoGroup()->getLocalRepo();
        $dbr = $repo->getReplicaDB();
Severity: Minor
Found in maintenance/findMissingFiles.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

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

    public function execute() {
        $passwordFactory = $this->getServiceContainer()->getPasswordFactory();

        $typeInfo = $passwordFactory->getTypes();
        $layeredType = $this->getOption( 'type' );
Severity: Minor
Found in maintenance/wrapOldPasswords.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

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

    public function execute() {
        if ( !$this->hasOption( 'unicode-data-file' ) ) {
            $dataFile = 'UnicodeData.txt';
            if ( !file_exists( $dataFile ) ) {
                $this->fatalError( "Unable to find UnicodeData.txt. Please specify " .
Severity: Minor
Found in maintenance/language/generateNormalizerDataAr.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

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

Controller.prototype.toggleInvertedTags = function () {
    this.filtersModel.toggleInvertedTags();

    if (
        this.filtersModel.getFiltersByView( 'tags' ).filter(
Severity: Major
Found in resources/src/mediawiki.rcfilters/Controller.js and 1 other location - About 3 hrs to fix
resources/src/mediawiki.rcfilters/Controller.js on lines 580..593

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 110.

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

Controller.prototype.toggleInvertedNamespaces = function () {
    this.filtersModel.toggleInvertedNamespaces();

    if (
        this.filtersModel.getFiltersByView( 'namespaces' ).filter(
Severity: Major
Found in resources/src/mediawiki.rcfilters/Controller.js and 1 other location - About 3 hrs to fix
resources/src/mediawiki.rcfilters/Controller.js on lines 562..575

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 110.

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

                co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
Severity: Major
Found in resources/lib/jquery.ui/jquery.ui.sortable.js and 1 other location - About 3 hrs to fix
resources/lib/jquery.ui/jquery.ui.sortable.js on lines 892..892

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 110.

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

            case 'mm':
                if (number === 1) {
                    result += withoutSuffix ? 'minuta' : 'minuto';
                } else if (number === 2) {
                    result += withoutSuffix || isFuture ? 'minuti' : 'minutama';
Severity: Major
Found in resources/lib/moment/locale/sl.js and 1 other location - About 3 hrs to fix
resources/lib/moment/locale/sl.js on lines 47..57

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 110.

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

            case 'hh':
                if (number === 1) {
                    result += withoutSuffix ? 'ura' : 'uro';
                } else if (number === 2) {
                    result += withoutSuffix || isFuture ? 'uri' : 'urama';
Severity: Major
Found in resources/lib/moment/locale/sl.js and 1 other location - About 3 hrs to fix
resources/lib/moment/locale/sl.js on lines 34..44

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 110.

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

                co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
Severity: Major
Found in resources/lib/jquery.ui/jquery.ui.sortable.js and 1 other location - About 3 hrs to fix
resources/lib/jquery.ui/jquery.ui.sortable.js on lines 891..891

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 110.

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

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

        foreach ( array_chunk( $rows, $this->getBatchSize() ) as $chunk ) {
            // WHERE ( mod=A AND skin=A ) OR ( mod=A AND skin=B) ..
            $conds = array_map( static function ( stdClass $row ) use ( $dbw ) {
                return $dbw->makeList( (array)$row, IDatabase::LIST_AND );
            }, $chunk );
Severity: Major
Found in maintenance/purgeModuleDeps.php and 1 other location - About 3 hrs to fix
maintenance/cleanupRemovedModules.php on lines 62..76

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 157.

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

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

        foreach ( array_chunk( $rows, $this->getBatchSize() ) as $chunk ) {
            // WHERE ( mod=A AND skin=A ) OR ( mod=A AND skin=B) ..
            $conds = array_map( static function ( stdClass $row ) use ( $dbw ) {
                return $dbw->makeList( (array)$row, IDatabase::LIST_AND );
            }, $chunk );
Severity: Major
Found in maintenance/cleanupRemovedModules.php and 1 other location - About 3 hrs to fix
maintenance/purgeModuleDeps.php on lines 53..67

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 157.

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

File JobQueueFederated.php has 322 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/jobqueue/JobQueueFederated.php - About 3 hrs to fix

    Function default has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            default: withCtx(() => {
              var _a, _b, _c, _d, _e, _f;
              return [
                _ctx.showThumbnail ? (openBlock(), createBlock(_component_cdx_thumbnail, {
                  key: 0,
    Severity: Major
    Found in resources/lib/codex/codex.js - About 3 hrs to fix

      Function _create has 93 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _create: function() {
      
              var that = this, o = this.options;
              this.element.addClass("ui-resizable");
      
      
      Severity: Major
      Found in resources/lib/jquery.ui/jquery.ui.resizable.js - About 3 hrs to fix

        Function Body has 93 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function Body() {
            this.bodyUsed = false;
        
            this._initBody = function(body) {
              /*
        Severity: Major
        Found in resources/lib/fetch-polyfill/fetch.umd.js - About 3 hrs to fix

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

              public function run( $resultPageSet = null ) {
                  $params = $this->extractRequestParams();
          
                  if ( isset( $params['title'] ) && !isset( $params['prefix'] ) ) {
                      $this->dieWithError(
          Severity: Major
          Found in includes/api/ApiQueryIWBacklinks.php - About 3 hrs to fix

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

                public function getAllowedParams() {
                    $slotRoles = $this->slotRoleRegistry->getKnownRoles();
                    sort( $slotRoles, SORT_STRING );
            
                    // Parameters for the 'from' and 'to' content
            Severity: Major
            Found in includes/api/ApiComparePages.php - About 3 hrs to fix

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

                  public function run( $resultPageSet = null ) {
                      $params = $this->extractRequestParams();
              
                      if ( isset( $params['title'] ) && !isset( $params['lang'] ) ) {
                          $this->dieWithError(
              Severity: Major
              Found in includes/api/ApiQueryLangBacklinks.php - About 3 hrs to fix

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

                    public function execute( $par ) {
                        $this->checkPermissions();
                        $this->checkReadOnly();
                
                        [ $this->target, $this->type ] = $this->getTargetAndType( $par, $this->getRequest() );
                Severity: Major
                Found in includes/specials/SpecialUnblock.php - About 3 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language