wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Method extractPageInfo has 201 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function extractPageInfo( $pageid, $page ) {
        $title = $this->titleFactory->newFromPageIdentity( $page );
        $pageInfo = [];
        // $page->exists() needs pageid, which is not set for all title objects
        $pageExists = $pageid > 0;
Severity: Major
Found in includes/api/ApiQueryInfo.php - About 1 day to fix

    File mediawiki.page.preview.js has 501 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    ( function () {
        const api = new mw.Api();
        const util = require( 'mediawiki.util' );
    
        /**
    Severity: Major
    Found in resources/src/mediawiki.page.preview.js - About 1 day to fix

      SwiftFileBackend has 56 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class SwiftFileBackend extends FileBackendStore {
          private const DEFAULT_HTTP_OPTIONS = [ 'httpVersion' => 'v1.1' ];
          private const AUTH_FAILURE_ERROR = 'Could not connect due to prior authentication failure';
      
          /** @var MultiHttpClient */
      Severity: Major
      Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 day to fix

        ApiMain has 56 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ApiMain extends ApiBase {
            /**
             * When no format parameter is given, this format will be used
             */
            private const API_DEFAULT_FORMAT = 'jsonfm';
        Severity: Major
        Found in includes/api/ApiMain.php - About 1 day to fix

          SqlBagOStuff has 56 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class SqlBagOStuff extends MediumSpecificBagOStuff {
              /** @var callable|null Injected function which returns a LoadBalancer */
              protected $loadBalancerCallback;
              /** @var ILoadBalancer|null */
              protected $loadBalancer;
          Severity: Major
          Found in includes/objectcache/SqlBagOStuff.php - About 1 day to fix

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

                protected function fillParserOutput(
                    Content $content,
                    ContentParseParams $cpoParams,
                    ParserOutput &$output
                ) {
            Severity: Major
            Found in includes/content/CssContentHandler.php and 1 other location - About 1 day to fix
            includes/content/JavaScriptContentHandler.php on lines 124..165

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

            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 fillParserOutput(
                    Content $content,
                    ContentParseParams $cpoParams,
                    ParserOutput &$output
                ) {
            Severity: Major
            Found in includes/content/JavaScriptContentHandler.php and 1 other location - About 1 day to fix
            includes/content/CssContentHandler.php on lines 108..149

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

            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 JobQueueRedis.php has 499 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/jobqueue/JobQueueRedis.php - About 1 day to fix

              Method showEditForm has 199 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function showEditForm() {
                      # need to parse the preview early so that we know which templates are used,
                      # otherwise users with "show preview after edit box" will get a blank list
                      # we parse this near the beginning so that setHeaders can do the title
                      # setting work instead of leaving it in getPreviewText
              Severity: Major
              Found in includes/editpage/EditPage.php - About 7 hrs to fix

                Function limit has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function limit( RateLimitSubject $subject, string $action, int $incrBy = 1 ) {
                        // Bypass limit checks for actions that are defined to be non-limitable.
                        // This is a performance optimization.
                        if ( $this->nonLimitableActions[$action] ?? false ) {
                            return false;
                Severity: Minor
                Found in includes/Permissions/RateLimiter.php - About 7 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 makeLoad has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function makeLoad( Context $mainContext, array $modules, $only,
                        array $extraQuery = []
                    ) {
                        $rl = $mainContext->getResourceLoader();
                        $chunks = [];
                Severity: Minor
                Found in includes/ResourceLoader/ClientHtml.php - About 7 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 truncateHtml has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function truncateHtml( $text, $length, $ellipsis = '...' ) {
                        # Use the localized ellipsis character
                        if ( $ellipsis == '...' ) {
                            $ellipsis = $this->msg( 'ellipsis' )->escaped();
                        }
                Severity: Minor
                Found in includes/language/Language.php - About 7 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 addExtensionOptions has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function addExtensionOptions(): void {
                        global $wgLang;
                
                        $extensions = $this->parent->findExtensions()->value;
                        '@phan-var array[] $extensions';
                Severity: Minor
                Found in includes/installer/WebInstallerOptions.php - About 7 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

                Method autoCreateUser has 197 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function autoCreateUser(
                        User $user,
                        $source,
                        $login = true,
                        $log = true,
                Severity: Major
                Found in includes/auth/AuthManager.php - About 7 hrs to fix

                  File QueryPage.php has 495 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  /**
                   * Base code for "query" special pages.
                   *
                   * This program is free software; you can redistribute it and/or modify
                  Severity: Minor
                  Found in includes/specialpage/QueryPage.php - About 7 hrs to fix

                    File DiffEngine.php has 494 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    /**
                     * New version of the difference engine
                     *
                     * Copyright © 2008 Guy Van den Broeck <guy@guyvdb.eu>
                    Severity: Minor
                    Found in includes/libs/Diff/DiffEngine.php - About 7 hrs to fix

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

                          function makeApi(sinon) {
                              function assertType(value, type, name) {
                                  var actual = sinon.typeOf(value);
                                  if (actual !== type) {
                                      throw new TypeError("Expected type of " + name + " to be " +
                      Severity: Major
                      Found in resources/lib/sinonjs/sinon.js - About 7 hrs to fix

                        Method getInfo has 196 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function getInfo( $file, $prop, $result, $thumbParams = null, $opts = false ) {
                                $anyHidden = false;
                        
                                $services = MediaWikiServices::getInstance();
                        
                        
                        Severity: Major
                        Found in includes/api/ApiQueryImageInfo.php - About 7 hrs to fix

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

                              public function execute() {
                                  /** @var Language $wgLang */
                                  global $wgLang;
                          
                                  $repo = $this->file->getRepo();
                          Severity: Major
                          Found in includes/filerepo/file/LocalFileRestoreBatch.php - About 7 hrs to fix

                            PageUpdater has 55 functions (exceeds 20 allowed). Consider refactoring.
                            Open

                            class PageUpdater {
                            
                                /**
                                 * Options that have to be present in the ServiceOptions object passed to the constructor.
                                 * @note When adding options here, also add them to PageUpdaterFactory::CONSTRUCTOR_OPTIONS.
                            Severity: Major
                            Found in includes/Storage/PageUpdater.php - About 7 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language