wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function run has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public function run( $resultPageSet = null ) {
        $params = $this->extractRequestParams();

        if ( isset( $params['title'] ) && !isset( $params['lang'] ) ) {
            $this->dieWithError(
Severity: Minor
Found in includes/api/ApiQueryLangBacklinks.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 outputPageList has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    private function outputPageList( $groups ) {
        $out = $this->getOutput();

        // Legend
        $includesRestrictedPages = false;
Severity: Minor
Found in includes/specials/SpecialSpecialPages.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 internalRemoveHtmlTags has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public static function internalRemoveHtmlTags( string $text, ?callable $processCallback = null,
        $args = [], array $extratags = [], array $removetags = []
    ): string {
        $tagData = self::getRecognizedTagData( $extratags, $removetags );
        $htmlsingle = $tagData['htmlsingle'];
Severity: Minor
Found in includes/parser/Sanitizer.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 extensionSubstitution has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public function extensionSubstitution( array $params, PPFrame $frame, bool $processNowiki = false ) {
        static $errorStr = '<span class="error">';

        $name = $frame->expand( $params['name'] );
        if ( str_starts_with( $name, $errorStr ) ) {
Severity: Minor
Found in includes/parser/Parser.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 execute has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        if ( $this->hasOption( 'd' ) ) {
            $d = $this->getOption( 'd' );
            if ( $d > 0 ) {
                LoggerFactory::registerProvider( new ConsoleSpi );
Severity: Minor
Found in maintenance/eval.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

File Makefile.py has 357 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @author Philip
import os
import platform
Severity: Minor
Found in maintenance/language/zhtable/Makefile.py - About 4 hrs to fix

    Function setupFields has 114 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        mw.widgets.datetime.DateTimeInputWidget.prototype.setupFields = function () {
            let i, $field, spec, placeholder, sz, maxlength;
    
            const
                spanValFunc = function ( v ) {
    Severity: Major
    Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 4 hrs to fix

      Function p has 114 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  var p = new Promise(function (resolve, reject) {
                    if (search == 'farzher') return resolve([{
                      target: "farzher was here (^-^*)/",
                      score: 0,
                      indexes: [0, 1, 2, 3, 4, 5, 6],
      Severity: Major
      Found in resources/lib/qunitjs/qunit.js - About 4 hrs to fix

        Method formatValue has 114 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function formatValue( $field, $value ) {
                /** @var stdClass $row */
                $row = $this->mCurrentRow;
                $linkRenderer = $this->getLinkRenderer();
        
        
        Severity: Major
        Found in includes/specials/pagers/ProtectedPagesPager.php - About 4 hrs to fix

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

          mw.widgets.RowWidget.prototype.removeItems = function ( items ) {
              OO.ui.mixin.GroupElement.prototype.removeItems.call( this, items );
          
              const cells = this.getItems();
              for ( let i = 0, len = cells.length; i < len; i++ ) {
          resources/src/mediawiki.widgets/Table/mw.widgets.TableWidget.js on lines 301..308

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

          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

          mw.widgets.TableWidget.prototype.removeItems = function ( items ) {
              OO.ui.mixin.GroupElement.prototype.removeItems.call( this, items );
          
              const rows = this.getItems();
              for ( let i = 0, len = rows.length; i < len; i++ ) {
          resources/src/mediawiki.widgets/Table/mw.widgets.RowWidget.js on lines 138..145

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

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

          <?php
          
          namespace MediaWiki\Settings;
          
          use MediaWiki\Config\Config;
          Severity: Minor
          Found in includes/Settings/SettingsBuilder.php - About 4 hrs to fix

            File IPTC.php has 356 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Class for some IPTC functions.
             *
             * This program is free software; you can redistribute it and/or modify
            Severity: Minor
            Found in includes/media/IPTC.php - About 4 hrs to fix

              Function MWWDateInputWidget has 113 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  mw.widgets.DateInputWidget = function MWWDateInputWidget( config ) {
                      // Config initialization
                      config = Object.assign( {
                          precision: 'day',
                          longDisplayFormat: false,
              Severity: Major
              Found in resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js - About 4 hrs to fix

                File CLDRPluralRuleParser.js has 355 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                /**
                 * cldrpluralparser.js
                 * A parser engine for CLDR plural rules.
                 *
                 * Copyright 2012-2014 Santhosh Thottingal and other contributors
                Severity: Minor
                Found in resources/lib/CLDRPluralRuleParser/CLDRPluralRuleParser.js - About 4 hrs to fix

                  Method prepareContent has 113 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function prepareContent(
                          UserIdentity $user,
                          RevisionSlotsUpdate $slotsUpdate,
                          $useStash = true
                      ) {
                  Severity: Major
                  Found in includes/Storage/DerivedPageDataUpdater.php - About 4 hrs to fix

                    SessionBackend has 35 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    final class SessionBackend {
                        /** @var SessionId */
                        private $id;
                    
                        /** @var bool */
                    Severity: Minor
                    Found in includes/session/SessionBackend.php - About 4 hrs to fix

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

                      OO.ui.TagItemWidget.prototype.toggleValid = function ( valid ) {
                          valid = valid === undefined ? !this.valid : !!valid;
                      
                          if ( this.valid !== valid ) {
                              this.valid = valid;
                      Severity: Major
                      Found in resources/lib/ooui/oojs-ui-widgets.js and 1 other location - About 4 hrs to fix
                      resources/lib/ooui/oojs-ui-widgets.js on lines 5129..5139

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

                      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.TagMultiselectWidget.prototype.toggleValid = function ( valid ) {
                          valid = valid === undefined ? !this.valid : !!valid;
                      
                          if ( this.valid !== valid ) {
                              this.valid = valid;
                      Severity: Major
                      Found in resources/lib/ooui/oojs-ui-widgets.js and 1 other location - About 4 hrs to fix
                      resources/lib/ooui/oojs-ui-widgets.js on lines 4206..4216

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

                      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 jquery.ui.button.js has 354 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      /*!
                       * jQuery UI Button 1.9.2
                       * http://jqueryui.com
                       *
                       * Copyright 2012 jQuery Foundation and other contributors
                      Severity: Minor
                      Found in resources/lib/jquery.ui/jquery.ui.button.js - About 4 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language