wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function processTable has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    private function processTable( IDatabase $db, $op, $table, $nsField, $titleField, $pkFields ) {
        if ( $this->tables !== null && !in_array( $table, $this->tables, true ) ) {
            $this->output( "Skipping table `$table`, not in --tables.\n" );
            return;
        }
Severity: Minor
Found in maintenance/uppercaseTitlesForUnicodeTransition.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 4 locations. Consider refactoring.
Open

mw.language.convertGrammar = function ( word, form ) {
    const grammarForms = mw.language.getData( 'dsb', 'grammarForms' );
    if ( grammarForms && grammarForms[ form ] ) {
        return grammarForms[ form ][ word ];
    }
Severity: Major
Found in resources/src/mediawiki.language/languages/dsb.js and 3 other locations - About 3 hrs to fix
resources/src/mediawiki.language/languages/bs.js on lines 5..19
resources/src/mediawiki.language/languages/hsb.js on lines 5..19
resources/src/mediawiki.language/languages/sl.js on lines 5..19

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

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 4 locations. Consider refactoring.
Open

mw.language.convertGrammar = function ( word, form ) {
    const grammarForms = mw.language.getData( 'hsb', 'grammarForms' );
    if ( grammarForms && grammarForms[ form ] ) {
        return grammarForms[ form ][ word ];
    }
Severity: Major
Found in resources/src/mediawiki.language/languages/hsb.js and 3 other locations - About 3 hrs to fix
resources/src/mediawiki.language/languages/bs.js on lines 5..19
resources/src/mediawiki.language/languages/dsb.js on lines 5..19
resources/src/mediawiki.language/languages/sl.js on lines 5..19

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

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 4 locations. Consider refactoring.
Open

mw.language.convertGrammar = function ( word, form ) {
    const grammarForms = mw.language.getData( 'sl', 'grammarForms' );
    if ( grammarForms && grammarForms[ form ] ) {
        return grammarForms[ form ][ word ];
    }
Severity: Major
Found in resources/src/mediawiki.language/languages/sl.js and 3 other locations - About 3 hrs to fix
resources/src/mediawiki.language/languages/bs.js on lines 5..19
resources/src/mediawiki.language/languages/dsb.js on lines 5..19
resources/src/mediawiki.language/languages/hsb.js on lines 5..19

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

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 4 locations. Consider refactoring.
Open

mw.language.convertGrammar = function ( word, form ) {
    const grammarForms = mw.language.getData( 'bs', 'grammarForms' );
    if ( grammarForms && grammarForms[ form ] ) {
        return grammarForms[ form ][ word ];
    }
Severity: Major
Found in resources/src/mediawiki.language/languages/bs.js and 3 other locations - About 3 hrs to fix
resources/src/mediawiki.language/languages/dsb.js on lines 5..19
resources/src/mediawiki.language/languages/hsb.js on lines 5..19
resources/src/mediawiki.language/languages/sl.js on lines 5..19

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

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

                    for (var keyI = keysLen - 1; keyI >= 0; --keyI) {
                      var key = keys[keyI];
                      var target = getValue(obj, key);
                      if (!target) {
                        objResults[keyI] = null;
Severity: Major
Found in resources/lib/qunitjs/qunit.js and 1 other location - About 3 hrs to fix
resources/lib/qunitjs/qunit.js on lines 4425..4434

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

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

                for (var keyI = keysLen - 1; keyI >= 0; --keyI) {
                  var key = keys[keyI];
                  var target = getValue(obj, key);
                  if (!target) {
                    objResults[keyI] = null;
Severity: Major
Found in resources/lib/qunitjs/qunit.js and 1 other location - About 3 hrs to fix
resources/lib/qunitjs/qunit.js on lines 4546..4555

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

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 MessagesMk.php has 329 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/** Macedonian (македонски)
 *
 * @file
 * @ingroup Languages
Severity: Minor
Found in languages/messages/MessagesMk.php - About 3 hrs to fix

    File MessagesKk_arab.php has 329 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /** Kazakh (Arabic script) (قازاقشا (تٴوتە))
     *
     * @file
     * @ingroup Languages
    Severity: Minor
    Found in languages/messages/MessagesKk_arab.php - About 3 hrs to fix

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

      $namespaceAliases = [
          'Aiuto'                => NS_HELP,
          'Ajuto'                => NS_HELP,
          'Discusion_Imàjine'    => NS_FILE_TALK,
          'Discussion'           => NS_TALK,
      Severity: Major
      Found in languages/messages/MessagesVec.php and 2 other locations - About 3 hrs to fix
      languages/messages/MessagesKw.php on lines 37..57
      languages/messages/MessagesPfl.php on lines 36..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 160.

      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 3 locations. Consider refactoring.
      Open

      $namespaceAliases = [
          'Arbednek'           => NS_SPECIAL,
          'Cows'               => NS_TALK,
          'Kescows'            => NS_TALK,
          'Cows_Devnydhyer'    => NS_USER_TALK,
      Severity: Major
      Found in languages/messages/MessagesKw.php and 2 other locations - About 3 hrs to fix
      languages/messages/MessagesPfl.php on lines 36..57
      languages/messages/MessagesVec.php on lines 52..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 160.

      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 3 locations. Consider refactoring.
      Open

      $namespaceAliases = [
          # German namespaces
          'Medium'                 => NS_MEDIA,
          'Spezial'                => NS_SPECIAL,
          'Diskussion'             => NS_TALK,
      Severity: Major
      Found in languages/messages/MessagesPfl.php and 2 other locations - About 3 hrs to fix
      languages/messages/MessagesKw.php on lines 37..57
      languages/messages/MessagesVec.php on lines 52..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 160.

      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

      Function doPreview has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function doPreview( config ) {
              config = Object.assign( {
                  $previewNode: $( '#wikiPreview' ),
                  $diffNode: $( '#wikiDiff' ),
                  $formNode: $( '#editform' ),
      Severity: Major
      Found in resources/src/mediawiki.page.preview.js - About 3 hrs to fix

        Method checkActionPermissions has 97 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function checkActionPermissions(
                $action,
                User $user,
                PermissionStatus $status,
                $rigor,
        Severity: Major
        Found in includes/Permissions/PermissionManager.php - About 3 hrs to fix

          Method expandFileInfo has 97 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function expandFileInfo( Context $context, $fileInfo, $debugKey ) {
                  if ( is_string( $fileInfo ) ) {
                      // Inline common case
                      return [
                          'name' => $fileInfo,
          Severity: Major
          Found in includes/ResourceLoader/FileModule.php - About 3 hrs to fix

            Method handleStatus has 97 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function handleStatus( Status $status, $resultDetails ): bool {
                    $statusValue = is_int( $status->value ) ? $status->value : 0;
            
                    /**
                     * @todo FIXME: once the interface for internalAttemptSavePrivate() is made
            Severity: Major
            Found in includes/editpage/EditPage.php - About 3 hrs to fix

              Method submit has 97 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function submit() {
                      global $wgPasswordPolicy;
              
                      $retVal = true;
                      $this->parent->setVarsFromRequest( [ 'wgSitename', '_NamespaceType',
              Severity: Major
              Found in includes/installer/WebInstallerName.php - About 3 hrs to fix

                Method __construct has 97 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function __construct(
                        WatchedItemStoreInterface $watchedItemStore = null,
                        MessageCache $messageCache = null,
                        UserOptionsLookup $userOptionsLookup = null,
                        ChangeTagsStore $changeTagsStore = null,
                Severity: Major
                Found in includes/specials/SpecialRecentChanges.php - About 3 hrs to fix

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

                      public function run( array $options ) {
                          $type = $options['type'] ?? false;
                          $maxJobs = $options['maxJobs'] ?? false;
                          $maxTime = $options['maxTime'] ?? false;
                          $throttle = $options['throttle'] ?? true;
                  Severity: Major
                  Found in includes/jobqueue/JobRunner.php - About 3 hrs to fix

                    Method getLogText has 97 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
                            if ( !$block ) {
                                return '';
                            }
                    
                    
                    Severity: Major
                    Found in includes/recentchanges/EnhancedChangesList.php - About 3 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language