wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function checkLinkTable has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkLinkTable( $table, $fieldPrefix, $ns, $name, $options,
        $extraConds = []
    ) {
        $dbw = $this->getPrimaryDB();

Severity: Minor
Found in maintenance/namespaceDupes.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 setup has 143 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  setup(props, { slots, emit }) {
    const rootElement = ref();
    const tabListElement = ref();
    const prevScroller = ref();
    const nextScroller = ref();
Severity: Major
Found in resources/lib/codex/codex.js - About 5 hrs to fix

    Method watchlistPreferences has 143 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function watchlistPreferences(
            User $user, IContextSource $context, &$defaultPreferences
        ) {
            $watchlistdaysMax = ceil( $this->options->get( MainConfigNames::RCMaxAge ) / ( 3600 * 24 ) );
    
    
    Severity: Major
    Found in includes/preferences/DefaultPreferencesFactory.php - About 5 hrs to fix

      Method groupCheckboxes has 143 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function groupCheckboxes( $usergroups, UserIdentity $user ) {
              $allgroups = $this->userGroupManager->listAllGroups();
              $ret = '';
      
              // Get the list of preset expiry times from the system message
      Severity: Major
      Found in includes/specials/SpecialUserRights.php - About 5 hrs to fix

        File MWDebug.php has 405 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/debug/MWDebug.php - About 5 hrs to fix

          Function suggestions has 142 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              $.fn.suggestions = function () {
                  // Multi-context fields
                  const args = arguments;
          
                  $( this ).each( function () {
          Severity: Major
          Found in resources/src/jquery/jquery.suggestions.js - About 5 hrs to fix

            Method doQuotes has 142 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function doQuotes( $text ) {
                    $arr = preg_split( "/(''+)/", $text, -1, PREG_SPLIT_DELIM_CAPTURE );
                    $countarr = count( $arr );
                    if ( $countarr == 1 ) {
                        return $text;
            Severity: Major
            Found in includes/parser/Parser.php - About 5 hrs to fix

              ChangesList has 42 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class ChangesList extends ContextSource {
                  use ProtectedHookAccessorTrait;
              
                  public const CSS_CLASS_PREFIX = 'mw-changeslist-';
              
              
              Severity: Minor
              Found in includes/recentchanges/ChangesList.php - About 5 hrs to fix

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

                            if ( word.slice( -1 ) === 'ա' ) {
                                word = word.slice( 0, -1 ) + 'այի';
                            } else if ( word.slice( -1 ) === 'ո' ) {
                                word = word.slice( 0, -1 ) + 'ոյի';
                            } else if ( word.slice( -4 ) === 'գիրք' ) {
                Severity: Major
                Found in resources/src/mediawiki.language/languages/hy.js and 1 other location - About 5 hrs to fix
                resources/lib/jquery.i18n/src/languages/hy.js on lines 11..19

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

                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

                                if ( word.slice( -1 ) === 'ա' ) {
                                    word = word.slice( 0, -1 ) + 'այի';
                                } else if ( word.slice( -1 ) === 'ո' ) {
                                    word = word.slice( 0, -1 ) + 'ոյի';
                                } else if ( word.slice( -4 ) === 'գիրք' ) {
                Severity: Major
                Found in resources/lib/jquery.i18n/src/languages/hy.js and 1 other location - About 5 hrs to fix
                resources/src/mediawiki.language/languages/hy.js on lines 16..24

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

                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

                        calendar: {
                            sameDay: '[danas u] LT',
                            nextDay: '[sutra u] LT',
                            nextWeek: function () {
                                switch (this.day()) {
                Severity: Major
                Found in resources/lib/moment/locale/hr.js and 1 other location - About 5 hrs to fix
                resources/lib/moment/locale/sl.js on lines 118..154

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

                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

                        calendar: {
                            sameDay: '[danes ob] LT',
                            nextDay: '[jutri ob] LT',
                
                            nextWeek: function () {
                Severity: Major
                Found in resources/lib/moment/locale/sl.js and 1 other location - About 5 hrs to fix
                resources/lib/moment/locale/hr.js on lines 103..138

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

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

                /* global pluralRuleParser */
                ( function ( $ ) {
                    'use strict';
                
                    // jscs:disable
                Severity: Minor
                Found in resources/lib/jquery.i18n/src/jquery.i18n.language.js - About 5 hrs to fix

                  File WikiModule.php has 402 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/ResourceLoader/WikiModule.php - About 5 hrs to fix

                    Method moveToInternal has 141 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function moveToInternal(
                            UserIdentity $user,
                            &$nt,
                            $reason = '',
                            $createRedirect = true,
                    Severity: Major
                    Found in includes/page/MovePage.php - About 5 hrs to fix

                      Method execute has 141 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function execute() {
                              $params = $this->extractRequestParams();
                      
                              // Parameter validation
                              $this->requireAtLeastOneParameter(
                      Severity: Major
                      Found in includes/api/ApiComparePages.php - About 5 hrs to fix

                        Method renderImageGallery has 141 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function renderImageGallery( $text, array $params ) {
                                $mode = false;
                                if ( isset( $params['mode'] ) ) {
                                    $mode = $params['mode'];
                                }
                        Severity: Major
                        Found in includes/parser/Parser.php - About 5 hrs to fix

                          File SvgHandler.php has 401 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          <?php
                          /**
                           * Handler for SVG images.
                           *
                           * This program is free software; you can redistribute it and/or modify
                          Severity: Minor
                          Found in includes/media/SvgHandler.php - About 5 hrs to fix

                            Function configure has 140 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                function configure( context, property, value ) {
                            
                                    // Validate creation using fallback values
                                    switch ( property ) {
                                        case 'fetch':
                            Severity: Major
                            Found in resources/src/jquery/jquery.suggestions.js - About 5 hrs to fix

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

                                      return this.api.chunkedUpload( this.getFile(), {
                                          watchlist: ( this.getWatchlist() ) ? 1 : undefined,
                                          comment: this.getComment(),
                                          filename: this.getFilename(),
                                          text: this.getText()
                              Severity: Major
                              Found in resources/src/mediawiki.Upload.js and 1 other location - About 5 hrs to fix
                              resources/src/mediawiki.Upload.js on lines 388..405

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

                              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

                              Severity
                              Category
                              Status
                              Source
                              Language