wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

        delete: function ( path, body, headers ) {
            headers = objectKeysToLowerCase( headers );
            return this.ajax( path, {
                type: 'DELETE',
                headers: Object.assign( headers, { 'content-type': 'application/json' } ),
Severity: Major
Found in resources/src/mediawiki.api/rest.js and 1 other location - About 2 hrs to fix
resources/src/mediawiki.api/rest.js on lines 141..148

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

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

OO.ui.WindowInstance.prototype.isClosing = function () {
    return this.deferreds.closing.state() === 'resolved' &&
        this.deferreds.closed.state() === 'pending';
};
Severity: Major
Found in resources/lib/ooui/oojs-ui-windows.js and 1 other location - About 2 hrs to fix
resources/lib/ooui/oojs-ui-windows.js on lines 932..935

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

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

    if ( this.indeterminate !== state ) {
        this.indeterminate = state;
        this.$input.prop( 'indeterminate', this.indeterminate );
        if ( !internal ) {
            this.setSelected( false, true );
Severity: Major
Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 2 hrs to fix
resources/lib/ooui/oojs-ui-core.js on lines 10456..10463

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

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

<?php
/*
 * Copyright 2019 Wikimedia Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
Severity: Minor
Found in includes/libs/mime/MSCompoundFileReader.php - About 2 hrs to fix

    File MessagesBs.php has 254 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /** Bosnian (bosanski)
     *
     * @file
     * @ingroup Languages
    Severity: Minor
    Found in languages/messages/MessagesBs.php - About 2 hrs to fix

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

          private function enforceActionRestrictions() {
              if ( $this->actionRestrictionsEnforced ) {
                  return;
              }
              $this->actionRestrictionsEnforced = true;
      Severity: Major
      Found in includes/logging/LogPager.php and 1 other location - About 2 hrs to fix
      includes/logging/LogPager.php on lines 533..545

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

      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

              if ( isset( $params['label-message'] ) ) {
                  $this->mLabel = $this->getMessage( $params['label-message'] )->parse();
              } elseif ( isset( $params['label'] ) ) {
                  if ( $params['label'] === '&#160;' || $params['label'] === "\u{00A0}" ) {
                      // Apparently some things set &nbsp directly and in an odd format
      Severity: Major
      Found in includes/htmlform/HTMLFormField.php and 1 other location - About 2 hrs to fix
      includes/htmlform/fields/HTMLButtonField.php on lines 62..73

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

      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

              if ( isset( $info['buttonlabel-message'] ) ) {
                  $this->buttonLabel = $this->getMessage( $info['buttonlabel-message'] )->parse();
              } elseif ( isset( $info['buttonlabel'] ) ) {
                  if ( $info['buttonlabel'] === '&#160;' || $info['buttonlabel'] === "\u{00A0}" ) {
                      // Apparently some things set &nbsp directly and in an odd format
      Severity: Major
      Found in includes/htmlform/fields/HTMLButtonField.php and 1 other location - About 2 hrs to fix
      includes/htmlform/HTMLFormField.php on lines 562..573

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

      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

                  if ( $srcHandle ) {
                      $stageHandle = fopen( $fsStagePath, 'xb' );
                      if ( $stageHandle ) {
                          $bytes = stream_copy_to_stream( $srcHandle, $stageHandle );
                          $stored = ( $bytes !== false && $bytes === fstat( $srcHandle )['size'] );
      Severity: Major
      Found in includes/libs/filebackend/FSFileBackend.php and 1 other location - About 2 hrs to fix
      includes/libs/filebackend/FSFileBackend.php on lines 376..385

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

      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

                  if ( $srcHandle ) {
                      $stageHandle = fopen( $fsStagePath, 'xb' );
                      if ( $stageHandle ) {
                          $bytes = stream_copy_to_stream( $srcHandle, $stageHandle );
                          $copied = ( $bytes !== false && $bytes === fstat( $srcHandle )['size'] );
      Severity: Major
      Found in includes/libs/filebackend/FSFileBackend.php and 1 other location - About 2 hrs to fix
      includes/libs/filebackend/FSFileBackend.php on lines 314..323

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

      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

          private function enforcePerformerRestrictions() {
              // Same as enforceActionRestrictions(), except for _USER instead of _ACTION bits.
              if ( $this->performerRestrictionsEnforced ) {
                  return;
              }
      Severity: Major
      Found in includes/logging/LogPager.php and 1 other location - About 2 hrs to fix
      includes/logging/LogPager.php on lines 517..528

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

      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 prettifyIP has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          prettifyIP: function ( ip ) {
              ip = this.sanitizeIP( ip );
              if ( ip === null ) {
                  return null;
              }
      Severity: Minor
      Found in resources/src/mediawiki.util/util.js - 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

      Function parseImageUrl has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          parseImageUrl: function ( url ) {
              let name, decodedName, width, urlTemplate;
      
              // thumb.php-generated thumbnails
              // thumb.php?f=<name>&w[idth]=<width>[px]
      Severity: Minor
      Found in resources/src/mediawiki.util/util.js - 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

      Function getAccessKeyModifiers has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      function getAccessKeyModifiers( nav ) {
          if ( !nav && cachedModifiers ) {
              return cachedModifiers;
          }
      
      
      Severity: Minor
      Found in resources/src/mediawiki.util/jquery.accessKeyLabel.js - 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

      Function _sfc_render$6 has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
        const _component_cdx_table_pager = resolveComponent("cdx-table-pager");
        const _component_cdx_checkbox = resolveComponent("cdx-checkbox");
        const _component_cdx_icon = resolveComponent("cdx-icon");
        const _component_cdx_progress_bar = resolveComponent("cdx-progress-bar");
      Severity: Minor
      Found in resources/lib/codex/codex.js - 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

      Function removeWatchBatchForUser has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function removeWatchBatchForUser( UserIdentity $user, array $titles ): bool {
              if ( !$user->isRegistered() || $this->readOnlyMode->isReadOnly() ) {
                  return false;
              }
              if ( !$titles ) {
      Severity: Minor
      Found in includes/watchlist/WatchedItemStore.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

      Function moveSubpagesInternal has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private function moveSubpagesInternal( callable $subpageMoveCallback ) {
              // Do the source and target namespaces support subpages?
              if ( !$this->nsInfo->hasSubpages( $this->oldTitle->getNamespace() ) ) {
                  return Status::newFatal( 'namespace-nosubpages',
                      $this->nsInfo->getCanonicalName( $this->oldTitle->getNamespace() ) );
      Severity: Minor
      Found in includes/page/MovePage.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

      Function __construct has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __construct( $priority, array $data ) {
              if ( $priority < self::MIN_PRIORITY || $priority > self::MAX_PRIORITY ) {
                  throw new InvalidArgumentException( 'Invalid priority' );
              }
      
      
      Severity: Minor
      Found in includes/session/SessionInfo.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

      Function getAllProperties has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getAllProperties( $titles ) {
              $values = [];
              $goodIDs = $this->getGoodIDs( $titles );
              $queryIDs = [];
              foreach ( $goodIDs as $pageID ) {
      Severity: Minor
      Found in includes/page/PageProps.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

      Function rollback has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function rollback() {
              // Begin revision creation cycle by creating a PageUpdater.
              // If the page is changed concurrently after grabParentRevision(), the rollback will fail.
              // TODO: move PageUpdater to PageStore or PageUpdaterFactory or something?
              $updater = $this->wikiPageFactory->newFromTitle( $this->page )->newPageUpdater( $this->performer );
      Severity: Minor
      Found in includes/page/RollbackPage.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

      Severity
      Category
      Status
      Source
      Language