wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

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

        $this->addTables( 'protected_titles' );
        $this->addFields( [ 'pt_namespace', 'pt_title', 'pt_timestamp' ] );
Severity: Minor
Found in includes/api/ApiQueryProtectedTitles.php - About 6 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 extractSections has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

    private function extractSections( $text, $sectionId, $mode, $newText, ?PageReference $page = null ) {
        $magicScopeVariable = $this->lock();
        $this->startParse(
            $page,
            ParserOptions::newFromUser( RequestContext::getMain()->getUser() ),
Severity: Minor
Found in includes/parser/Parser.php - About 6 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 findFiles has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

    public function findFiles( array $items, $flags = 0 ) {
        $finalFiles = []; // map of (DB key => corresponding File) for matches

        $searchSet = []; // map of (normalized DB key => search params)
        foreach ( $items as $item ) {
Severity: Minor
Found in includes/filerepo/LocalRepo.php - About 6 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 43 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $force = $this->hasOption( 'force' );
        $threads = $this->getOption( 'threads', 1 );
        if ( $threads < 1 || $threads != intval( $threads ) ) {
            $this->output( "Invalid thread count specified; running single-threaded.\n" );
Severity: Minor
Found in maintenance/rebuildLocalisationCache.php - About 6 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 ast has 164 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        ast: function ( message ) {
            var pipe, colon, backslash, anyCharacter, dollar, digits, regularLiteral,
                regularLiteralWithoutBar, regularLiteralWithoutSpace, escapedOrLiteralWithoutBar,
                escapedOrRegularLiteral, templateContents, templateName, openTemplate,
                closeTemplate, expression, paramExpression, result,
Severity: Major
Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js - About 6 hrs to fix

    Function _sfc_render$h has 164 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
      const _component_cdx_icon = resolveComponent("cdx-icon");
      const _component_cdx_button = resolveComponent("cdx-button");
      return openBlock(), createBlock(Teleport, {
        to: _ctx.computedTarget,
    Severity: Major
    Found in resources/lib/codex/codex.js - About 6 hrs to fix

      Function makeApi has 164 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function makeApi(sinon) {
              var assert;
      
              function verifyIsStub() {
                  var method;
      Severity: Major
      Found in resources/lib/sinonjs/sinon.js - About 6 hrs to fix

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

                    switch ( form ) {
                        case 'genitive':
                            ending = hyphen + jot + 'ы';
                            break;
                        case 'dative':
        Severity: Major
        Found in resources/lib/jquery.i18n/src/languages/os.js and 1 other location - About 6 hrs to fix
        resources/src/mediawiki.language/languages/os.js on lines 39..65

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

        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

            mw.widgets.SelectWithInputWidget.static.reusePreInfuseDOM = function ( node, config ) {
                config = mw.widgets.SelectWithInputWidget.super.static.reusePreInfuseDOM( node, config );
                config.dropdowninput = OO.ui.DropdownInputWidget.static.reusePreInfuseDOM(
                    $( node ).find( '.oo-ui-dropdownInputWidget' ),
                    config.dropdowninput
        resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js on lines 59..70
        resources/src/mediawiki.widgets/mw.widgets.SizeFilterWidget.js on lines 70..81

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

        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

            mw.widgets.ComplexTitleInputWidget.static.reusePreInfuseDOM = function ( node, config ) {
                config = mw.widgets.ComplexTitleInputWidget.super.static.reusePreInfuseDOM( node, config );
                config.namespace = mw.widgets.NamespaceInputWidget.static.reusePreInfuseDOM(
                    $( node ).find( '.mw-widget-namespaceInputWidget' ),
                    config.namespace
        resources/src/mediawiki.widgets/mw.widgets.SelectWithInputWidget.js on lines 82..93
        resources/src/mediawiki.widgets/mw.widgets.SizeFilterWidget.js on lines 70..81

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

        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

            mw.widgets.SizeFilterWidget.static.reusePreInfuseDOM = function ( node, config ) {
                config = mw.widgets.SizeFilterWidget.super.static.reusePreInfuseDOM( node, config );
                config.radioselectinput = OO.ui.RadioSelectInputWidget.static.reusePreInfuseDOM(
                    $( node ).find( '.oo-ui-radioSelectInputWidget' ),
                    config.radioselectinput
        resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js on lines 59..70
        resources/src/mediawiki.widgets/mw.widgets.SelectWithInputWidget.js on lines 82..93

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

        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

            mw.widgets.SizeFilterWidget.static.gatherPreInfuseState = function ( node, config ) {
                const state = mw.widgets.SizeFilterWidget.super.static.gatherPreInfuseState( node, config );
                state.radioselectinput = OO.ui.RadioSelectInputWidget.static.gatherPreInfuseState(
                    $( node ).find( '.oo-ui-radioSelectInputWidget' ),
                    config.radioselectinput
        resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js on lines 75..86
        resources/src/mediawiki.widgets/mw.widgets.SelectWithInputWidget.js on lines 98..109

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

        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

            mw.widgets.ComplexTitleInputWidget.static.gatherPreInfuseState = function ( node, config ) {
                const state = mw.widgets.ComplexTitleInputWidget.super.static.gatherPreInfuseState( node, config );
                state.namespace = mw.widgets.NamespaceInputWidget.static.gatherPreInfuseState(
                    $( node ).find( '.mw-widget-namespaceInputWidget' ),
                    config.namespace
        resources/src/mediawiki.widgets/mw.widgets.SelectWithInputWidget.js on lines 98..109
        resources/src/mediawiki.widgets/mw.widgets.SizeFilterWidget.js on lines 86..97

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

        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

            switch ( form ) {
                case 'genitive':
                    ending = hyphen + jot + 'ы';
                    break;
                case 'dative':
        Severity: Major
        Found in resources/src/mediawiki.language/languages/os.js and 1 other location - About 6 hrs to fix
        resources/lib/jquery.i18n/src/languages/os.js on lines 44..70

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

        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

            mw.widgets.SelectWithInputWidget.static.gatherPreInfuseState = function ( node, config ) {
                const state = mw.widgets.SelectWithInputWidget.super.static.gatherPreInfuseState( node, config );
                state.dropdowninput = OO.ui.DropdownInputWidget.static.gatherPreInfuseState(
                    $( node ).find( '.oo-ui-dropdownInputWidget' ),
                    config.dropdowninput
        resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js on lines 75..86
        resources/src/mediawiki.widgets/mw.widgets.SizeFilterWidget.js on lines 86..97

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

        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 _generateHTML has 163 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _generateHTML: function(inst) {
                var today = new Date();
                today = this._daylightSavingAdjust(
                    new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
                var isRTL = this._get(inst, 'isRTL');
        Severity: Major
        Found in resources/lib/jquery.ui/jquery.ui.datepicker.js - About 6 hrs to fix

          Method recentChangesBlockGroup has 163 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function recentChangesBlockGroup( $block ) {
                  $recentChangesFlags = $this->getConfig()->get( MainConfigNames::RecentChangesFlags );
          
                  # Add the namespace and title of the block as part of the class
                  $tableClasses = [ 'mw-enhanced-rc', 'mw-changeslist-line' ];
          Severity: Major
          Found in includes/recentchanges/EnhancedChangesList.php - About 6 hrs to fix

            File UndeletePage.php has 438 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/page/UndeletePage.php - About 6 hrs to fix

              File WebInstallerOptions.php has 438 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
              Severity: Minor
              Found in includes/installer/WebInstallerOptions.php - About 6 hrs to fix

                File ImageListPager.php has 438 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/specials/pagers/ImageListPager.php - About 6 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language