wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

<?php
/**
 * Check for articles to fix after adding/deleting namespaces
 *
 * Copyright © 2005-2007 Brooke Vibber <bvibber@wikimedia.org>
Severity: Major
Found in maintenance/namespaceDupes.php - About 1 day to fix

    Function doUpdateRestrictions has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

        public function doUpdateRestrictions( array $limit, array $expiry,
            &$cascade, $reason, UserIdentity $user, $tags = []
        ) {
            $services = MediaWikiServices::getInstance();
            $readOnlyMode = $services->getReadOnlyMode();
    Severity: Minor
    Found in includes/page/WikiPage.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

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

            if ( 'name' in config ) {
                // Use this instead of <input type="hidden">, because hidden inputs do not have separate
                // 'value' and 'defaultValue' properties. The script on Special:Preferences
                // (mw.special.preferences.confirmClose) checks this property to see if a field was changed.
                this.$hiddenInput = $( '<textarea>' )
    resources/src/mediawiki.widgets/mw.widgets.NamespacesMultiselectWidget.js on lines 56..73

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

    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 ( 'name' in config ) {
                // Use this instead of <input type="hidden">, because hidden inputs do not have separate
                // 'value' and 'defaultValue' properties. The script on Special:Preferences
                // (mw.special.preferences.confirmClose) checks this property to see if a field was changed.
                this.$hiddenInput = $( '<textarea>' )
    resources/src/mediawiki.widgets/mw.widgets.TitlesMultiselectWidget.js on lines 57..74

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

    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 makeApi has 206 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function makeApi(sinon) {
            function getCallbackError(behavior, func, args) {
                if (behavior.callArgAt < 0) {
                    var msg;
    
    
    Severity: Major
    Found in resources/lib/sinonjs/sinon.js - About 1 day to fix

      Method getFormFields has 205 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getFormFields() {
              $conf = $this->getConfig();
              $blockAllowsUTEdit = $conf->get( MainConfigNames::BlockAllowsUTEdit );
      
              $this->getOutput()->enableOOUI();
      Severity: Major
      Found in includes/specials/SpecialBlock.php - About 1 day to fix

        File MultiHttpClient.php has 507 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * HTTP service client
         *
         * This program is free software; you can redistribute it and/or modify
        Severity: Major
        Found in includes/libs/http/MultiHttpClient.php - About 1 day to fix

          ChangesListSpecialPage has 57 functions (exceeds 20 allowed). Consider refactoring.
          Open

          abstract class ChangesListSpecialPage extends SpecialPage {
          
              /** @var string */
              protected $rcSubpage;
          
          
          Severity: Major
          Found in includes/specialpage/ChangesListSpecialPage.php - About 1 day to fix

            DatabaseUpdater has 57 functions (exceeds 20 allowed). Consider refactoring.
            Open

            abstract class DatabaseUpdater {
                public const REPLICATION_WAIT_TIMEOUT = 300;
            
                /**
                 * Array of updates to perform on the database
            Severity: Major
            Found in includes/installer/DatabaseUpdater.php - About 1 day to fix

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

                  private function execute() {
                      $text = $this->text;
                      # Parsing through the text line by line.  The main thing
                      # happening here is handling of block-level elements p, pre,
                      # and making lists from lines starting with * # : etc.
              Severity: Major
              Found in includes/parser/BlockLevelPass.php - About 1 day to fix

                Function segmentSplitter has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function segmentSplitter( $filename ) {
                        $showXMP = XMPReader::isSupported();
                
                        $segmentCount = 0;
                
                
                Severity: Minor
                Found in includes/media/JpegMetadataExtractor.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 execute has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function execute() {
                        $params = $this->extractRequestParams();
                
                        // Parameter validation
                        $this->requireAtLeastOneParameter(
                Severity: Minor
                Found in includes/api/ApiComparePages.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 processTitlesArray has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function processTitlesArray( $titles ) {
                        $linkBatch = $this->linkBatchFactory->newLinkBatch();
                
                        /** @var Title[] $titleObjects */
                        $titleObjects = [];
                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

                Function statelessFetchTemplate has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function statelessFetchTemplate( $page, $parser = false ) {
                        $title = Title::castFromLinkTarget( $page ); // for compatibility with return type
                        $text = $skip = false;
                        $finalTitle = $title;
                        $deps = [];
                Severity: Minor
                Found in includes/parser/Parser.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 generateFirstChars has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function generateFirstChars() {
                        $file = fopen( "{$this->dataDir}/allkeys.txt", 'r' );
                        if ( !$file ) {
                            $this->fatalError( "Unable to open allkeys.txt" );
                        }
                Severity: Minor
                Found in maintenance/language/generateCollationData.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 execute has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function execute() {
                        $backendGroup = $this->getServiceContainer()->getFileBackendGroup();
                        $src = $backendGroup->get( $this->getOption( 'src' ) );
                        $dst = $backendGroup->get( $this->getOption( 'dst' ) );
                        $containers = explode( '|', $this->getOption( 'containers' ) );
                Severity: Minor
                Found in maintenance/copyFileBackend.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 expand has 202 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function expand( $root, $flags = 0 ) {
                        static $expansionDepth = 0;
                        if ( is_string( $root ) ) {
                            return $root;
                        }
                Severity: Major
                Found in includes/parser/PPFrame_Hash.php - About 1 day to fix

                  File ParamValidator.php has 502 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  namespace Wikimedia\ParamValidator;
                  
                  use DomainException;
                  Severity: Major
                  Found in includes/libs/ParamValidator/ParamValidator.php - About 1 day to fix

                    File MimeMap.php has 502 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/libs/mime/MimeMap.php - About 1 day to fix

                      File ApiQueryWatchlist.php has 502 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      /**
                       * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
                       *
                       * This program is free software; you can redistribute it and/or modify
                      Severity: Major
                      Found in includes/api/ApiQueryWatchlist.php - About 1 day to fix
                        Severity
                        Category
                        Status
                        Source
                        Language