wikimedia/mediawiki-core

View on GitHub

Showing 9,426 of 11,461 total issues

File HTMLFormField.php has 762 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace MediaWiki\HTMLForm;

use HtmlArmor;
Severity: Major
Found in includes/htmlform/HTMLFormField.php - About 1 day to fix

    Function checkSettings has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring.
    Open

        public function checkSettings(
            ApiBase $module, array $params, string $name, array $options
        ): array {
            $options['module'] = $module;
            $settings = $params[$name];
    Severity: Minor
    Found in includes/api/Validator/ApiParamValidator.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 setup has 356 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      setup(props, { emit, slots, attrs }) {
        const computedMenuItems = computed(() => {
          const menuItemsWithFooter = props.footer && props.menuItems ? [...props.menuItems, props.footer] : props.menuItems;
          return menuItemsWithFooter.map((menuItem) => __spreadProps(__spreadValues({}, menuItem), {
            id: useGeneratedId("menu-item")
    Severity: Major
    Found in resources/lib/codex/codex.js - About 1 day to fix

      EditPage has 93 functions (exceeds 20 allowed). Consider refactoring.
      Open

      #[\AllowDynamicProperties]
      class EditPage implements IEditObject {
          use DeprecationHelper;
          use ProtectedHookAccessorTrait;
      
      
      Severity: Major
      Found in includes/editpage/EditPage.php - About 1 day to fix

        HTMLForm has 93 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class HTMLForm extends ContextSource {
            use ProtectedHookAccessorTrait;
        
            /** @var string[] A mapping of 'type' inputs onto standard HTMLFormField subclasses */
            public static $typeMappings = [
        Severity: Major
        Found in includes/htmlform/HTMLForm.php - About 1 day to fix

          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
                                Severity
                                Category
                                Status
                                Source
                                Language