wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function groupCheckboxes has a Cognitive Complexity of 55 (exceeds 5 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: Minor
Found in includes/specials/SpecialUserRights.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 dump has 213 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var dump = (function () {
    function quote(str) {
      return '"' + str.toString().replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
    }
    function literal(o) {
Severity: Major
Found in resources/lib/qunitjs/qunit.js - About 1 day to fix

    File FilterTagMultiselectWidget.js has 521 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const ViewSwitchWidget = require( './ViewSwitchWidget.js' ),
        SaveFiltersPopupButtonWidget = require( './SaveFiltersPopupButtonWidget.js' ),
        MenuSelectWidget = require( './MenuSelectWidget.js' ),
        FilterTagItemWidget = require( './FilterTagItemWidget.js' );
    
    
    Severity: Major
    Found in resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js - About 1 day to fix

      HTMLFormField has 59 functions (exceeds 20 allowed). Consider refactoring.
      Open

      abstract class HTMLFormField {
          /** @var array|array[] */
          public $mParams;
      
          /** @var callable(mixed,array,HTMLForm):(StatusValue|string|bool|Message) */
      Severity: Major
      Found in includes/htmlform/HTMLFormField.php - About 1 day to fix

        ContentHandler has 59 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class ContentHandler {
            use ProtectedHookAccessorTrait;
        
            /**
             * Convenience function for getting flat text from a Content object. This
        Severity: Major
        Found in includes/content/ContentHandler.php - About 1 day to fix

          Function initialize has 212 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Controller.prototype.initialize = function ( filterStructure, namespaceStructure, tagList, conditionalViews ) {
              const displayConfig = mw.config.get( 'StructuredChangeFiltersDisplayConfig' ),
                  defaultSavedQueryExists = mw.config.get( 'wgStructuredChangeFiltersDefaultSavedQueryExists' ),
                  controller = this,
                  views = $.extend( true, {}, conditionalViews ),
          Severity: Major
          Found in resources/src/mediawiki.rcfilters/Controller.js - About 1 day to fix

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

                private function run( $resultPageSet = null ) {
                    $params = $this->extractRequestParams();
                    $namespaces = $this->getPageSet()->getGoodAndMissingTitlesByNamespace();
                    if ( empty( $namespaces[NS_FILE] ) ) {
                        return;
            Severity: Minor
            Found in includes/api/ApiQueryDuplicateFiles.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 populateGeneratorData has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
            Open

                public function populateGeneratorData( &$result, array $path = [] ) {
                    if ( $result instanceof ApiResult ) {
                        $data = $result->getResultData( $path );
                        if ( $data === null ) {
                            return true;
            Severity: Minor
            Found in includes/api/ApiPageSet.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

            Method compressWithConcat has 210 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function compressWithConcat( $startId, $maxChunkSize, $beginDate,
                    $endDate, $extdb = "", $maxPageId = false
                ) {
                    $dbr = $this->getReplicaDB();
                    $dbw = $this->getPrimaryDB();
            Severity: Major
            Found in maintenance/storage/compressOld.php - About 1 day to fix

              File fetch.umd.js has 515 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              (function (global, factory) {
                typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
                typeof define === 'function' && define.amd ? define(['exports'], factory) :
                (factory((global.WHATWGFetch = {})));
              }(this, (function (exports) { 'use strict';
              Severity: Major
              Found in resources/lib/fetch-polyfill/fetch.umd.js - About 1 day to fix

                File AuthManagerSpecialPage.php has 515 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                namespace MediaWiki\SpecialPage;
                
                use ErrorPageError;
                Severity: Major
                Found in includes/specialpage/AuthManagerSpecialPage.php - About 1 day to fix

                  File MessagesEn.php has 514 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  /**
                   * This is the default English localisation file containing language specific
                   * information excluding interface strings, which are stored in JSON files.
                   *
                  Severity: Major
                  Found in languages/messages/MessagesEn.php - About 1 day to fix

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

                        public function execute( $par ) {
                            $this->setHeaders();
                            $this->outputHeader();
                            $this->checkPermissions();
                            $out = $this->getOutput();
                    Severity: Major
                    Found in includes/specialpage/ContributionsSpecialPage.php - About 1 day to fix

                      File uppercaseTitlesForUnicodeTransition.php has 513 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      /**
                       * Obligatory redundant license notice. Exception to the GPL's "keep intact all
                       * the notices" clause with respect to this notice is hereby granted.
                       *
                      Severity: Major
                      Found in maintenance/uppercaseTitlesForUnicodeTransition.php - About 1 day to fix

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

                                'messages' => [
                                    'rcfilters-tag-remove',
                                    'rcfilters-activefilters',
                                    'rcfilters-activefilters-hide',
                                    'rcfilters-activefilters-show',
                        Severity: Major
                        Found in resources/Resources.php and 1 other location - About 1 day to fix
                        includes/parser/MagicWordFactory.php on lines 44..128

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

                        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

                            protected function getFunctionReport() {
                                $data = $this->getFunctionStats();
                                usort( $data, static function ( $a, $b ) {
                                    return $b['real'] <=> $a['real']; // descending
                                } );
                        Severity: Major
                        Found in includes/profiler/ProfilerSectionOnly.php and 1 other location - About 1 day to fix
                        includes/profiler/ProfilerXhprof.php on lines 216..242

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

                        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

                            private array $mVariableIDs = [
                                '!',
                                '=',
                                'currentmonth',
                                'currentmonth1',
                        Severity: Major
                        Found in includes/parser/MagicWordFactory.php and 1 other location - About 1 day to fix
                        resources/Resources.php on lines 1886..1970

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

                        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

                            protected function getFunctionReport() {
                                $data = $this->getFunctionStats();
                                usort( $data, static function ( $a, $b ) {
                                    return $b['real'] <=> $a['real']; // descending
                                } );
                        Severity: Major
                        Found in includes/profiler/ProfilerXhprof.php and 1 other location - About 1 day to fix
                        includes/profiler/ProfilerSectionOnly.php on lines 68..94

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

                        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

                        Method finalizeHeadings has 207 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function finalizeHeadings( $text, $origText, $isMain = true ) {
                                # Inhibit editsection links if requested in the page
                                if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) {
                                    $maybeShowEditLink = false;
                                } else {
                        Severity: Major
                        Found in includes/parser/Parser.php - About 1 day to fix

                          File LogEventsList.php has 511 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          <?php
                          /**
                           * Contain classes to list log entries
                           *
                           * Copyright © 2004 Brooke Vibber <bvibber@wikimedia.org>
                          Severity: Major
                          Found in includes/logging/LogEventsList.php - About 1 day to fix
                            Severity
                            Category
                            Status
                            Source
                            Language