wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Consider simplifying this complex logical expression.
Open

            if (
                $char === self::O &&
                $i + 1 < $l &&
                array_key_exists( $chars[ $i + 1 ], self::DIACRITICS_WITH_O )
            ) {
Severity: Critical
Found in includes/language/converters/MniConverter.php - About 7 hrs to fix

    JobQueue has 52 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class JobQueue {
        /** @var string DB domain ID */
        protected $domain;
        /** @var string Job type */
        protected $type;
    Severity: Major
    Found in includes/jobqueue/JobQueue.php - About 7 hrs to fix

      File ProlepticGregorianDateTimeFormatter.js has 472 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      ( function () {
      
          /**
           * @classdesc DateTimeFormatter for the proleptic Gregorian calendar.
           *

        File SpecialPage.php has 472 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * Parent class for all special pages.
         *
         * This program is free software; you can redistribute it and/or modify
        Severity: Minor
        Found in includes/specialpage/SpecialPage.php - About 7 hrs to fix

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

                  if ( !this.fullMonthNames ) {
                      this.fullMonthNames = {
                          1: mw.msg( 'january' ),
                          2: mw.msg( 'february' ),
                          3: mw.msg( 'march' ),
          resources/src/mediawiki.widgets.datetime/ProlepticGregorianDateTimeFormatter.js on lines 218..233

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

          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

                  if ( !this.shortMonthNames ) {
                      this.shortMonthNames = {
                          1: mw.msg( 'jan' ),
                          2: mw.msg( 'feb' ),
                          3: mw.msg( 'mar' ),
          resources/src/mediawiki.widgets.datetime/ProlepticGregorianDateTimeFormatter.js on lines 202..217

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

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

              public function getIRCActionText() {
                  $this->plaintext = true;
                  $this->irctext = true;
          
                  $entry = $this->entry;
          Severity: Major
          Found in includes/logging/LogFormatter.php - About 7 hrs to fix

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

                public function incrementResolvedStats( User $user = null ) {
                    $namespace = 'n/a';
                    $userBucket = 'n/a';
                    $statsdMetrics = [ 'edit.failures.conflict.resolved' ];
            
            
            Severity: Major
            Found in includes/editpage/TextConflictHelper.php and 1 other location - About 7 hrs to fix
            includes/editpage/TextConflictHelper.php on lines 139..171

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

            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

                public function incrementConflictStats( User $user = null ) {
                    $namespace = 'n/a';
                    $userBucket = 'n/a';
                    $statsdMetrics = [ 'edit.failures.conflict' ];
            
            
            Severity: Major
            Found in includes/editpage/TextConflictHelper.php and 1 other location - About 7 hrs to fix
            includes/editpage/TextConflictHelper.php on lines 177..211

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

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

                private function getModuleInfo( $module ) {
                    $ret = [];
                    $path = $module->getModulePath();
                    $paramValidator = $module->getMain()->getParamValidator();
            
            
            Severity: Minor
            Found in includes/api/ApiParamInfo.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

            File BlockManager.php has 467 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/block/BlockManager.php - About 7 hrs to fix

              File HistoryPager.php has 467 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              /**
               * Page history pager
               *
               * This program is free software; you can redistribute it and/or modify
              Severity: Minor
              Found in includes/actions/pagers/HistoryPager.php - About 7 hrs to fix

                Function Deferred has 180 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    Deferred: function( func ) {
                        var tuples = [
                
                                // action, add listener, callbacks,
                                // ... .then handlers, argument index, [final state]
                Severity: Major
                Found in resources/lib/jquery/jquery.js - About 7 hrs to fix

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

                              if(!o.axis || o.axis != 'y') {
                                  if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
                                      scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
                                  else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
                                      scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
                  Severity: Major
                  Found in resources/lib/jquery.ui/jquery.ui.draggable.js and 1 other location - About 7 hrs to fix
                  resources/lib/jquery.ui/jquery.ui.draggable.js on lines 717..722

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

                  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

                              if(!o.axis || o.axis != 'x') {
                                  if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
                                      scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
                                  else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
                                      scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
                  Severity: Major
                  Found in resources/lib/jquery.ui/jquery.ui.draggable.js and 1 other location - About 7 hrs to fix
                  resources/lib/jquery.ui/jquery.ui.draggable.js on lines 724..729

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

                  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 ActionEntryPoint.php has 466 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  namespace MediaWiki\Actions;
                  
                  use Action;
                  Severity: Minor
                  Found in includes/actions/ActionEntryPoint.php - About 7 hrs to fix

                    WikiImporter has 51 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class WikiImporter {
                        /** @var XMLReader|null */
                        private $reader;
                    
                        /** @var string */
                    Severity: Major
                    Found in includes/import/WikiImporter.php - About 7 hrs to fix

                      MediumSpecificBagOStuff has 51 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      abstract class MediumSpecificBagOStuff extends BagOStuff {
                          /** @var array<string,array> Map of (key => (class LOCK_* constant => value) */
                          protected $locks = [];
                          /** @var int Bytes; chunk size of segmented cache values */
                          protected $segmentationSize;
                      Severity: Major
                      Found in includes/libs/objectcache/MediumSpecificBagOStuff.php - About 7 hrs to fix

                        File ApiQueryBacklinks.php has 464 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: Minor
                        Found in includes/api/ApiQueryBacklinks.php - About 7 hrs to fix

                          Method getDiffRevision has 178 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function getDiffRevision( $prefix, array $params ) {
                                  // Back compat params
                                  $this->requireMaxOneParameter( $params, "{$prefix}text", "{$prefix}slots" );
                                  $this->requireMaxOneParameter( $params, "{$prefix}section", "{$prefix}slots" );
                                  if ( $params["{$prefix}text"] !== null ) {
                          Severity: Major
                          Found in includes/api/ApiComparePages.php - About 7 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language