wikimedia/mediawiki-core

View on GitHub

Showing 11,461 of 11,461 total issues

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

OO.ui.PopupToolGroup.prototype.onToolbarResize = function () {
    if ( !this.narrowConfig ) {
        return;
    }
    if ( this.toolbar.isNarrow() ) {
Severity: Major
Found in resources/lib/ooui/oojs-ui-toolbars.js and 1 other location - About 1 day to fix
resources/lib/ooui/oojs-ui-toolbars.js on lines 984..1012

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

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.Tool.prototype.onToolbarResize = function () {
    if ( !this.narrowConfig ) {
        return;
    }
    if ( this.toolbar.isNarrow() ) {
Severity: Major
Found in resources/lib/ooui/oojs-ui-toolbars.js and 1 other location - About 1 day to fix
resources/lib/ooui/oojs-ui-toolbars.js on lines 2176..2204

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

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 loadSessionInfoFromStore has a Cognitive Complexity of 88 (exceeds 5 allowed). Consider refactoring.
Open

    private function loadSessionInfoFromStore( SessionInfo &$info, WebRequest $request ) {
        $key = $this->store->makeKey( 'MWSession', $info->getId() );
        $blob = $this->store->get( $key );

        // If we got data from the store and the SessionInfo says to force use,
Severity: Minor
Found in includes/session/SessionManager.php - About 1 day 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 convertGrammar has a Cognitive Complexity of 88 (exceeds 5 allowed). Consider refactoring.
Open

    public function convertGrammar( $word, $case ) {
        $grammarForms =
            MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms );
        if ( isset( $grammarForms['tyv'][$case][$word] ) ) {
            return $grammarForms['tyv'][$case][$word];
Severity: Minor
Found in includes/languages/LanguageTyv.php - About 1 day 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 createSetupStore has 351 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
      let scope;
      const optionsForPlugin = assign({ actions: {} }, options);
      /* istanbul ignore if */
      // @ts-expect-error: active is an internal property
Severity: Major
Found in resources/lib/pinia/pinia.iife.js - About 1 day to fix

    File SpecialWatchlist.php has 750 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: Major
    Found in includes/specials/SpecialWatchlist.php - About 1 day to fix

      File SessionManager.php has 749 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * MediaWiki\Session entry point
       *
       * This program is free software; you can redistribute it and/or modify
      Severity: Major
      Found in includes/session/SessionManager.php - About 1 day to fix

        Method getHelpInternal has 348 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function getHelpInternal( IContextSource $context, array $modules,
                array $options, &$haveModules
            ) {
                $out = '';
        
        
        Severity: Major
        Found in includes/api/ApiHelp.php - About 1 day to fix

          Function execute has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring.
          Open

              public function execute() {
                  $params = $this->extractRequestParams();
                  if ( $params['lang'] === null ) {
                      $langObj = $this->getLanguage();
                  } elseif ( !$this->languageNameUtils->isValidCode( $params['lang'] ) ) {
          Severity: Minor
          Found in includes/api/ApiQueryAllMessages.php - About 1 day 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 MainConfigNames.php has 743 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * This file is automatically generated using maintenance/generateConfigSchema.php.
           * Do not modify this file manually, edit includes/MainConfigSchema.php instead.
           * @file
          Severity: Major
          Found in includes/MainConfigNames.php - About 1 day to fix

            File config-vars.php has 741 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * This file is automatically generated using maintenance/generateConfigSchema.php.
             * Do not modify this file manually, edit includes/MainConfigSchema.php instead.
             */
            Severity: Major
            Found in docs/config-vars.php - About 1 day to fix

              File SpecialRecentChanges.php has 740 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: Major
              Found in includes/specials/SpecialRecentChanges.php - About 1 day to fix

                Function openShowImage has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function openShowImage() {
                        $context = $this->getContext();
                        $mainConfig = $context->getConfig();
                        $enableUploads = $mainConfig->get( MainConfigNames::EnableUploads );
                        $send404Code = $mainConfig->get( MainConfigNames::Send404Code );
                Severity: Minor
                Found in includes/page/ImagePage.php - About 1 day 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 InfoAction.php has 739 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                /**
                 * Displays information about a page.
                 *
                 * Copyright © 2011 Alexandre Emsenhuber
                Severity: Major
                Found in includes/actions/InfoAction.php - About 1 day to fix

                  File NormalizeAr.php has 737 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  // Generated by generateNormalizerDataAr.php. Do not modify!
                  
                  namespace MediaWiki\Languages\Data;
                  
                  
                  Severity: Major
                  Found in includes/languages/data/NormalizeAr.php - About 1 day to fix

                    Function pluralRuleParser has 341 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function pluralRuleParser(rule, number) {
                        'use strict';
                    
                        /*
                        Syntax: see http://unicode.org/reports/tr35/#Language_Plural_Rules
                    Severity: Major
                    Found in resources/lib/CLDRPluralRuleParser/CLDRPluralRuleParser.js - About 1 day to fix

                      File TextPassDumper.php has 734 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      /**
                       * BackupDumper that postprocesses XML dumps from dumpBackup.php to add page text
                       *
                       * Copyright (C) 2005 Brooke Vibber <bvibber@wikimedia.org>
                      Severity: Major
                      Found in maintenance/includes/TextPassDumper.php - About 1 day to fix

                        File jquery.ui.sortable.js has 733 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        /*!
                         * jQuery UI Sortable 1.9.2
                         * http://jqueryui.com
                         *
                         * Copyright 2012 jQuery Foundation and other contributors
                        Severity: Major
                        Found in resources/lib/jquery.ui/jquery.ui.sortable.js - About 1 day to fix

                          FileBackendStore has 89 functions (exceeds 20 allowed). Consider refactoring.
                          Open

                          abstract class FileBackendStore extends FileBackend {
                              /** @var WANObjectCache */
                              protected $memCache;
                              /** @var BagOStuff */
                              protected $srvCache;
                          Severity: Major
                          Found in includes/libs/filebackend/FileBackendStore.php - About 1 day to fix

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

                                function makeApi(sinon) {
                                    var push = Array.prototype.push;
                                    var slice = Array.prototype.slice;
                                    var callId = 0;
                            
                            
                            Severity: Major
                            Found in resources/lib/sinonjs/sinon.js - About 1 day to fix
                              Severity
                              Category
                              Status
                              Source
                              Language