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

              _ctx.highlightQuery ? (openBlock(), createBlock(_component_cdx_search_result_title, {
                key: 0,
                title: _ctx.title,
                "search-query": _ctx.searchQuery,
                lang: (_a = _ctx.language) == null ? void 0 : _a.label
Severity: Major
Found in resources/lib/codex/codex.js and 1 other location - About 6 hrs to fix
resources/lib/codex/codex.js on lines 2372..2389

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

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

    function createClock(now, loopLimit) {
        loopLimit = loopLimit || 1000;

        var clock = {
            now: getEpoch(now),
Severity: Major
Found in resources/lib/sinonjs/sinon.js - About 5 hrs to fix

    Method undeleteRevisions has 149 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function undeleteRevisions( ProperPageIdentity $page, array $timestamps, string $comment ): StatusValue {
            if ( $this->readOnlyMode->isReadOnly() ) {
                throw new ReadOnlyError();
            }
    
    
    Severity: Major
    Found in includes/page/UndeletePage.php - About 5 hrs to fix

      Method showForm has 149 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function showForm() {
              $action = $this->getPageTitle()->getLocalURL( [ 'action' => 'submit' ] );
              $authority = $this->getAuthority();
              $out = $this->getOutput();
              $this->addHelpLink( 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Import', true );
      Severity: Major
      Found in includes/specials/SpecialImport.php - About 5 hrs to fix

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

                        case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
                                handled = event.ctrlKey || event.metaKey;
                                // -1 day on ctrl or command +left
                                if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
                                            -$.datepicker._get(inst, 'stepBigMonths') :
        Severity: Major
        Found in resources/lib/jquery.ui/jquery.ui.datepicker.js and 1 other location - About 5 hrs to fix
        resources/lib/jquery.ui/jquery.ui.datepicker.js on lines 576..583

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

        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.ButtonSelectWidget = function OoUiButtonSelectWidget( config ) {
            // Parent constructor
            OO.ui.ButtonSelectWidget.super.call( this, config );
        
            // Mixin constructors
        Severity: Major
        Found in resources/lib/ooui/oojs-ui-widgets.js and 1 other location - About 5 hrs to fix
        resources/lib/ooui/oojs-ui-widgets.js on lines 3532..3547

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

        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.OutlineSelectWidget = function OoUiOutlineSelectWidget( config ) {
            // Parent constructor
            OO.ui.OutlineSelectWidget.super.call( this, config );
        
            // Mixin constructors
        Severity: Major
        Found in resources/lib/ooui/oojs-ui-widgets.js and 1 other location - About 5 hrs to fix
        resources/lib/ooui/oojs-ui-widgets.js on lines 3666..3681

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

        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 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
                                handled = event.ctrlKey || event.metaKey;
                                // +1 day on ctrl or command +right
                                if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
                                            +$.datepicker._get(inst, 'stepBigMonths') :
        Severity: Major
        Found in resources/lib/jquery.ui/jquery.ui.datepicker.js and 1 other location - About 5 hrs to fix
        resources/lib/jquery.ui/jquery.ui.datepicker.js on lines 565..572

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

        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 Title.js has 414 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*!
         * @author Neil Kandalgaonkar, 2010
         * @since 1.18
         */
        
        
        Severity: Minor
        Found in resources/src/mediawiki.Title/Title.js - About 5 hrs to fix

          File mw.widgets.CalendarWidget.js has 414 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /*!
           * MediaWiki Widgets – CalendarWidget class.
           *
           * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
           * @license The MIT License (MIT); see LICENSE.txt
          Severity: Minor
          Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js - About 5 hrs to fix

            File ApiQueryRevisions.php has 414 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
             *
             * This program is free software; you can redistribute it and/or modify
            Severity: Minor
            Found in includes/api/ApiQueryRevisions.php - About 5 hrs to fix

              Method onView has 148 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function onView() {
                      $out = $this->getOutput();
                      $request = $this->getRequest();
                      $config = $this->context->getConfig();
                      $services = MediaWikiServices::getInstance();
              Severity: Major
              Found in includes/actions/HistoryAction.php - About 5 hrs to fix

                Method doHeader has 148 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function doHeader( $opts, $numRows ) {
                        $user = $this->getUser();
                        $out = $this->getOutput();
                        $skin = $this->getSkin();
                        // For legacy skins render the tabs in the subtitle
                Severity: Major
                Found in includes/specials/SpecialWatchlist.php - About 5 hrs to fix

                  Method streamThumb has 148 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function streamThumb( array $params ) {
                          $headers = []; // HTTP headers to send
                  
                          $fileName = $params['f'] ?? '';
                  
                  
                  Severity: Major
                  Found in includes/filerepo/ThumbnailEntryPoint.php - About 5 hrs to fix

                    Function imageHistoryLine has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function imageHistoryLine( $iscur, $file, $formattedComment ) {
                            $user = $this->getUser();
                            $lang = $this->getLanguage();
                            $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
                            $timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
                    Severity: Minor
                    Found in includes/page/ImageHistoryList.php - About 5 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 getPreviewText has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function getPreviewText() {
                            $out = $this->context->getOutput();
                            $config = $this->context->getConfig();
                    
                            if ( $config->get( MainConfigNames::RawHtml ) && !$this->mTokenOk ) {
                    Severity: Minor
                    Found in includes/editpage/EditPage.php - About 5 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 makeLink has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function makeLink( $key, $item, $options = [] ) {
                            $html = $item['html'] ?? null;
                            $icon = $item['icon'] ?? null;
                            if ( $html ) {
                                return [
                    Severity: Minor
                    Found in includes/skins/components/SkinComponentLink.php - About 5 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 tsToHebrew has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private static function tsToHebrew( $ts ) {
                            # Parse date
                            $year = (int)substr( $ts, 0, 4 );
                            $month = (int)substr( $ts, 4, 2 );
                            $day = (int)substr( $ts, 6, 2 );
                    Severity: Minor
                    Found in includes/language/Language.php - About 5 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 formatNumInternal has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function formatNumInternal(
                            string $number, bool $noTranslate, bool $noSeparators
                        ): string {
                            $translateNumerals = $this->config->get( MainConfigNames::TranslateNumerals );
                    
                    
                    Severity: Minor
                    Found in includes/language/Language.php - About 5 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 parseCachedTable has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function parseCachedTable( $code, $subpage = '', $recursive = true ) {
                            static $parsed = [];
                    
                            $key = 'Conversiontable/' . $code;
                            if ( $subpage ) {
                    Severity: Minor
                    Found in includes/language/LanguageConverter.php - About 5 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