wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

$namespaceAliases = [
    # Aliases to kk-cyrl namespaces
    'Таспа'               => NS_MEDIA,
    'Арнайы'              => NS_SPECIAL,
    'Талқылау'            => NS_TALK,
Severity: Major
Found in languages/messages/MessagesKk_latn.php and 1 other location - About 1 day to fix
languages/messages/MessagesKk_cyrl.php on lines 50..90

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

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

TransactionManager has 66 functions (exceeds 20 allowed). Consider refactoring.
Open

class TransactionManager {
    /** Transaction is in a error state requiring a full or savepoint rollback */
    public const STATUS_TRX_ERROR = 1;
    /** Transaction is active and in a normal state */
    public const STATUS_TRX_OK = 2;
Severity: Major
Found in includes/libs/rdbms/database/TransactionManager.php - About 1 day to fix

    File DeletePage.php has 569 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace MediaWiki\Page;
    
    use BadMethodCallException;
    Severity: Major
    Found in includes/page/DeletePage.php - About 1 day to fix

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

              do {
                if (s.pending === s.pending_buf_size) {
                  //--- HCRC_UPDATE(beg) ---//
                  if (s.gzhead.hcrc && s.pending > beg) {
                    strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);
      Severity: Major
      Found in resources/lib/pako/pako_deflate.js and 1 other location - About 1 day to fix
      resources/lib/pako/pako_deflate.js on lines 3194..3215

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

      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

              do {
                if (s.pending === s.pending_buf_size) {
                  //--- HCRC_UPDATE(beg) ---//
                  if (s.gzhead.hcrc && s.pending > beg) {
                    strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);
      Severity: Major
      Found in resources/lib/pako/pako_deflate.js and 1 other location - About 1 day to fix
      resources/lib/pako/pako_deflate.js on lines 3159..3180

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

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

          private function extractRowInfo( $row ) {
              $logEntry = DatabaseLogEntry::newFromRow( $row );
              $vals = [
                  ApiResult::META_TYPE => 'assoc',
              ];
      Severity: Minor
      Found in includes/api/ApiQueryLogEvents.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 showIndirectLinks has 239 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function showIndirectLinks(
              $level, LinkTarget $target, $limit, $offsetNamespace = 0, $offsetPageID = 0, $dir = 'next'
          ) {
              $out = $this->getOutput();
              $dbr = $this->dbProvider->getReplicaDatabase();
      Severity: Major
      Found in includes/specials/SpecialWhatLinksHere.php - About 1 day to fix

        File util.js has 564 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        
        let config = require( './config.json' );
        const portletLinkOptions = require( './portletLinkOptions.json' );
        const infinityValues = require( './infinityValues.json' );
        Severity: Major
        Found in resources/src/mediawiki.util/util.js - About 1 day to fix

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

              public function execute() {
                  $params = $this->extractRequestParams();
                  $activeUserDays = $this->getConfig()->get( MainConfigNames::ActiveUserDays );
          
                  $db = $this->getDB();
          Severity: Major
          Found in includes/api/ApiQueryAllUsers.php - About 1 day to fix

            ApiPageSet has 65 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class ApiPageSet extends ApiBase {
                /**
                 * Constructor flag: The new instance of ApiPageSet will ignore the 'generator=' parameter
                 * @since 1.21
                 */
            Severity: Major
            Found in includes/api/ApiPageSet.php - About 1 day to fix

              File jquery.ui.resizable.js has 561 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /*!
               * jQuery UI Resizable 1.9.2
               * http://jqueryui.com
               *
               * Copyright 2012 jQuery Foundation and other contributors
              Severity: Major
              Found in resources/lib/jquery.ui/jquery.ui.resizable.js - About 1 day to fix

                File ThumbnailEntryPoint.php has 561 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                /**
                 * Entry point implementation for retrieving media thumbnails, created by a MediaHandler
                 * subclass or proxy request if FileRepo::getThumbProxyUrl is configured.
                 *
                Severity: Major
                Found in includes/filerepo/ThumbnailEntryPoint.php - About 1 day to fix

                  Function run has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function run( $resultPageSet = null ) {
                          $db = $this->getDB();
                  
                          $params = $this->extractRequestParams();
                  
                  
                  Severity: Minor
                  Found in includes/api/ApiQueryAllPages.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 60 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function execute() {
                          $user = $this->getUser();
                  
                          if ( !$user->isRegistered() ) {
                              $this->dieWithError( 'watchlistanontext', 'notloggedin' );
                  Severity: Minor
                  Found in includes/api/ApiSetNotificationTimestamp.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 doVariants has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function doVariants( &$classes ) {
                          $linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
                          $linkBatch = $linkBatchFactory->newLinkBatch();
                          $variantMap = []; // maps $pdbkey_Variant => $keys (of link holders)
                          $output = $this->parent->getOutput();
                  Severity: Minor
                  Found in includes/parser/LinkHolderArray.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 renderImageGallery has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function renderImageGallery( $text, array $params ) {
                          $mode = false;
                          if ( isset( $params['mode'] ) ) {
                              $mode = $params['mode'];
                          }
                  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 doMoveToExternal has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function doMoveToExternal() {
                          $success = true;
                          $dbr = $this->getReplicaDB();
                  
                          $count = $this->maxID - $this->minID + 1;
                  Severity: Minor
                  Found in maintenance/storage/moveToExternal.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 IntroMessageBuilder.php has 559 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  namespace MediaWiki\EditPage;
                  
                  use LogEventsList;
                  Severity: Major
                  Found in includes/editpage/IntroMessageBuilder.php - About 1 day to fix

                    File SiteConfig.php has 558 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    /**
                     * Copyright (C) 2011-2022 Wikimedia Foundation and others.
                     *
                     * This program is free software; you can redistribute it and/or modify
                    Severity: Major
                    Found in includes/parser/Parsoid/Config/SiteConfig.php - About 1 day to fix

                      Method loadSessionInfoFromStore has 234 lines of code (exceeds 25 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: Major
                      Found in includes/session/SessionManager.php - About 1 day to fix
                        Severity
                        Category
                        Status
                        Source
                        Language