wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

File SearchHighlighter.php has 382 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Basic search engine highlighting
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Minor
Found in includes/search/SearchHighlighter.php - About 5 hrs to fix

    DatabaseMySQL has 39 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DatabaseMySQL extends Database {
        /** @var string|null */
        private $sslKeyPath;
        /** @var string|null */
        private $sslCertPath;
    Severity: Minor
    Found in includes/libs/rdbms/database/DatabaseMySQL.php - About 5 hrs to fix

      DatabaseBlockStore has 39 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class DatabaseBlockStore {
          /** The old schema */
          public const SCHEMA_IPBLOCKS = 'ipblocks';
          /** The new schema */
          public const SCHEMA_BLOCK = 'block';
      Severity: Minor
      Found in includes/block/DatabaseBlockStore.php - About 5 hrs to fix

        QueryPage has 39 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class QueryPage extends SpecialPage {
            /** @var bool Whether or not we want plain listoutput rather than an ordered list */
            protected $listoutput = false;
        
            /** @var int The offset and limit in use, as passed to the query() function */
        Severity: Minor
        Found in includes/specialpage/QueryPage.php - About 5 hrs to fix

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

              public function execute() {
                  $params = $this->extractRequestParams();
                  if ( $params['lang'] === null ) {
                      $langObj = $this->getLanguage();
                  } elseif ( !$this->languageNameUtils->isValidCode( $params['lang'] ) ) {
          Severity: Major
          Found in includes/api/ApiQueryAllMessages.php - About 5 hrs to fix

            File CalendarWidget.js has 380 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            ( function () {
            
                /**
                 * @classdesc CalendarWidget displays a calendar that can be used to select a date. It
                 * uses {@link mw.widgets.datetime.DateTimeFormatter DateTimeFormatter} to get the details of
            Severity: Minor
            Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js - About 5 hrs to fix

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

                  function makeApi(sinon) {
                      sinon.fakeServer = {
                          create: function (config) {
                              var server = sinon.create(this);
                              server.configure(config);
              Severity: Major
              Found in resources/lib/sinonjs/sinon.js - About 5 hrs to fix

                Method prepareQuery has 128 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function prepareQuery( array $users, $limit ) {
                        $this->resetQueryParams();
                        $db = $this->getDB();
                
                        $queryBuilder = $this->revisionStore->newSelectQueryBuilder( $db )->joinComment()->joinPage();
                Severity: Major
                Found in includes/api/ApiQueryUserContribs.php - About 5 hrs to fix

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

                      public function execute() {
                          // Cache may vary on the user because ParserOptions gets data from it
                          $this->getMain()->setCacheMode( 'anon-public-user-private' );
                  
                          // Get parameters
                  Severity: Major
                  Found in includes/api/ApiExpandTemplates.php - About 5 hrs to fix

                    Method save has 128 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function save(
                            ParserOutput $parserOutput,
                            PageRecord $page,
                            $popts,
                            $cacheTime = null,
                    Severity: Major
                    Found in includes/parser/ParserCache.php - About 5 hrs to fix

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

                              }, _ctx.otherAttrs, {
                                onBlur: _cache[1] || (_cache[1] = (...args) => _ctx.onInputBlur && _ctx.onInputBlur(...args)),
                                onFocus: _cache[2] || (_cache[2] = (...args) => _ctx.onInputFocus && _ctx.onInputFocus(...args)),
                                onKeydown: _cache[3] || (_cache[3] = (...args) => _ctx.onInputKeydown && _ctx.onInputKeydown(...args))
                              }), null, 16, _hoisted_2$f)), [
                      Severity: Major
                      Found in resources/lib/codex/codex.js and 1 other location - About 5 hrs to fix
                      resources/lib/codex/codex.js on lines 1989..1993

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

                      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

                      OO.ui.IndexLayout.prototype.onStackLayoutFocus = function ( e ) {
                          // Find the tab panel that an element was focused within
                          const $target = $( e.target ).closest( '.oo-ui-tabPanelLayout' );
                          for ( const name in this.tabPanels ) {
                              // Check for tab panel match, exclude current tab panel to find only tab panel changes
                      Severity: Major
                      Found in resources/lib/ooui/oojs-ui-widgets.js and 1 other location - About 5 hrs to fix
                      resources/lib/ooui/oojs-ui-widgets.js on lines 2022..2032

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

                      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

                          for ( let i = 0; i < this.items.length; i++ ) {
                              const highlighted = this.items[ i ] === item;
                              if ( this.items[ i ].isHighlighted() !== highlighted ) {
                                  this.items[ i ].setHighlighted( highlighted );
                                  if ( changed ) {
                      Severity: Major
                      Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 5 hrs to fix
                      resources/lib/ooui/oojs-ui-core.js on lines 7968..7979

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

                      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

                              }, _ctx.otherAttrs, {
                                onBlur: _cache[5] || (_cache[5] = (...args) => _ctx.onInputBlur && _ctx.onInputBlur(...args)),
                                onFocus: _cache[6] || (_cache[6] = (...args) => _ctx.onInputFocus && _ctx.onInputFocus(...args)),
                                onKeydown: _cache[7] || (_cache[7] = (...args) => _ctx.onInputKeydown && _ctx.onInputKeydown(...args))
                              }), null, 16, _hoisted_4$6), [
                      Severity: Major
                      Found in resources/lib/codex/codex.js and 1 other location - About 5 hrs to fix
                      resources/lib/codex/codex.js on lines 1975..1979

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

                      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

                          for ( let i = 0; i < this.items.length; i++ ) {
                              const pressed = this.items[ i ] === item;
                              if ( this.items[ i ].isPressed() !== pressed ) {
                                  this.items[ i ].setPressed( pressed );
                                  if ( changed ) {
                      Severity: Major
                      Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 5 hrs to fix
                      resources/lib/ooui/oojs-ui-core.js on lines 7776..7787

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

                      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

                      OO.ui.BookletLayout.prototype.onStackLayoutFocus = function ( e ) {
                          // Find the page that an element was focused within
                          const $target = $( e.target ).closest( '.oo-ui-pageLayout' );
                          for ( const name in this.pages ) {
                              // Check for page match, exclude current page to find only page changes
                      Severity: Major
                      Found in resources/lib/ooui/oojs-ui-widgets.js and 1 other location - About 5 hrs to fix
                      resources/lib/ooui/oojs-ui-widgets.js on lines 2617..2628

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

                      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 RedisBagOStuff.php has 379 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/libs/objectcache/RedisBagOStuff.php - About 5 hrs to fix

                        Function dropDefaults has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private static function dropDefaults( $element, array $attribs ) {
                                // Whenever altering this array, please provide a covering test case
                                // in HtmlTest::provideElementsWithAttributesHavingDefaultValues
                                static $attribDefaults = [
                                    'area' => [ 'shape' => 'rect' ],
                        Severity: Minor
                        Found in includes/Html/Html.php - About 5 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 runSecondQuery has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function runSecondQuery( $resultPageSet = null ) {
                                $db = $this->getDB();
                                if ( isset( $this->linksMigration::$mapping[$this->bl_table] ) ) {
                                    $queryInfo = $this->linksMigration->getQueryInfo( $this->bl_table, $this->bl_table );
                                    $this->addTables( $queryInfo['tables'] );
                        Severity: Minor
                        Found in includes/api/ApiQueryBacklinks.php - About 5 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 run has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function run( $resultPageSet = null ) {
                                $params = $this->extractRequestParams();
                        
                                $user = $this->getWatchlistUser( $params );
                        
                        
                        Severity: Minor
                        Found in includes/api/ApiQueryWatchlistRaw.php - About 5 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

                        Severity
                        Category
                        Status
                        Source
                        Language