wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function parseTitle has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    protected function parseTitle( $request ) {
        $curid = $request->getInt( 'curid' );
        $title = $request->getText( 'title' );

        $ret = null;
Severity: Minor
Found in includes/actions/ActionEntryPoint.php - About 4 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 run has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    private function run( $resultPageSet = null ) {
        $pages = $this->getPageSet()->getGoodPages();
        if ( $pages === [] ) {
            return; // nothing to do
        }
Severity: Minor
Found in includes/api/ApiQueryImages.php - About 4 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 recCheckCondition has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    private function recCheckCondition( $cond, User $user ): bool {
        if ( is_array( $cond ) && count( $cond ) >= 2 && in_array( $cond[0], self::VALID_OPS ) ) {
            // Recursive condition
            if ( $cond[0] == '&' ) { // AND (all conds pass)
                foreach ( array_slice( $cond, 1 ) as $subcond ) {
Severity: Minor
Found in includes/user/UserGroupManager.php - About 4 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 recordUpload3 has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    public function recordUpload3(
        string $oldver,
        string $comment,
        string $pageText,
        Authority $performer,
Severity: Minor
Found in includes/filerepo/file/LocalFile.php - About 4 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 checkPreconditions has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    public function checkPreconditions( RequestInterface $request ) {
        $parser = new IfNoneMatch;
        if ( $this->eTag !== null ) {
            $resourceTag = $parser->parseETag( $this->eTag );
            if ( !$resourceTag ) {
Severity: Minor
Found in includes/Rest/ConditionalHeaderUtil.php - About 4 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 indexifyHost has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    private static function indexifyHost( $host, $reverse = true ) {
        // Canonicalize.
        $host = rawurldecode( $host );
        if ( $host !== '' ) {
            $tmp = idn_to_utf8( $host );
Severity: Minor
Found in includes/ExternalLinks/LinkFilter.php - About 4 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 getFieldForTag has 118 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    mw.widgets.datetime.DiscordianDateTimeFormatter.prototype.getFieldForTag = function ( tag, params ) {
        let spec = null;

        switch ( tag + '|' + params[ 0 ] ) {
            case 'year|#':

    Function initializeFilters has 118 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    FiltersViewModel.prototype.initializeFilters = function ( filterGroups, views ) {
        const model = this,
            items = [],
            groupConflictMap = {},
            filterConflictMap = {},
    Severity: Major
    Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js - About 4 hrs to fix

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

                  case "accusative": # tabıs
                      if ( in_array( $wordEnding, $Consonants ) ) {
                          if ( in_array( $wordLastVowel, $frontVowels ) ) {
                              $word .= "ті";
                          } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
      Severity: Major
      Found in includes/languages/LanguageKk_cyrl.php and 1 other location - About 4 hrs to fix
      includes/languages/LanguageKk_cyrl.php on lines 113..133

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

      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 "possessive dative": # täweldık + barıs
                      if ( in_array( $wordEnding, $firstPerson ) ) {
                          if ( in_array( $wordLastVowel, $frontVowels ) ) {
                              $word .= "е";
                          } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
      Severity: Major
      Found in includes/languages/LanguageKk_cyrl.php and 1 other location - About 4 hrs to fix
      includes/languages/LanguageKk_cyrl.php on lines 136..156

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

      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.mixin.IconElement = function OoUiMixinIconElement( config ) {
          // Configuration initialization
          config = config || {};
      
          // Properties
      Severity: Major
      Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 4 hrs to fix
      resources/lib/ooui/oojs-ui-core.js on lines 3197..3208

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

      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.mixin.IndicatorElement = function OoUiMixinIndicatorElement( config ) {
          // Configuration initialization
          config = config || {};
      
          // Properties
      Severity: Major
      Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 4 hrs to fix
      resources/lib/ooui/oojs-ui-core.js on lines 3048..3059

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

      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

                      pageX = containment ? (!(left - this.offset.click.left < containment[0] || left - this.offset.click.left > containment[2]) ? left : (!(left - this.offset.click.left < containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
      Severity: Major
      Found in resources/lib/jquery.ui/jquery.ui.draggable.js and 1 other location - About 4 hrs to fix
      resources/lib/jquery.ui/jquery.ui.draggable.js on lines 453..453

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

      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

                      pageY = containment ? (!(top - this.offset.click.top < containment[1] || top - this.offset.click.top > containment[3]) ? top : (!(top - this.offset.click.top < containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
      Severity: Major
      Found in resources/lib/jquery.ui/jquery.ui.draggable.js and 1 other location - About 4 hrs to fix
      resources/lib/jquery.ui/jquery.ui.draggable.js on lines 456..456

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

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

      <?php
      /** Egyptian Spoken Arabic (مصرى)
       *
       * @file
       * @ingroup Languages
      Severity: Minor
      Found in languages/messages/MessagesArz.php - About 4 hrs to fix

        Function OoUiSelectFileInputWidget has 117 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        OO.ui.SelectFileInputWidget = function OoUiSelectFileInputWidget( config ) {
            config = config || {};
        
            // Construct buttons before parent method is called (calling setDisabled)
            this.selectButton = new OO.ui.ButtonWidget( Object.assign( {
        Severity: Major
        Found in resources/lib/ooui/oojs-ui-core.js - About 4 hrs to fix

          Function computePosition has 117 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          OO.ui.PopupWidget.prototype.computePosition = function () {
              const popupPos = {},
                  anchorCss = { left: '', right: '', top: '', bottom: '' },
                  popupPositionOppositeMap = {
                      above: 'below',
          Severity: Major
          Found in resources/lib/ooui/oojs-ui-core.js - About 4 hrs to fix

            Method getPreviewText has 117 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getPreviewText() {
                    $out = $this->context->getOutput();
                    $config = $this->context->getConfig();
            
                    if ( $config->get( MainConfigNames::RawHtml ) && !$this->mTokenOk ) {
            Severity: Major
            Found in includes/editpage/EditPage.php - About 4 hrs to fix

              Method contributionsSub has 117 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function contributionsSub( $userObj, $targetName ) {
                      $isAnon = $userObj->isAnon();
                      if ( !$isAnon && $userObj->isHidden() &&
                          !$this->permissionManager->userHasRight( $this->getUser(), 'hideuser' )
                      ) {
              Severity: Major
              Found in includes/specialpage/ContributionsSpecialPage.php - About 4 hrs to fix

                Method getCoreUpdateList has 117 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function getCoreUpdateList() {
                        return [
                            // 1.36
                            [ 'modifyField', 'redirect', 'rd_title', 'patch-redirect-rd_title-varbinary.sql' ],
                            [ 'modifyField', 'pagelinks', 'pl_title', 'patch-pagelinks-pl_title-varbinary.sql' ],
                Severity: Major
                Found in includes/installer/MysqlUpdater.php - About 4 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language