wikimedia/mediawiki-core

View on GitHub

Showing 11,498 of 11,498 total issues

Method handleInternalLinks2 has 267 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function handleInternalLinks2( &$s ) {
        static $tc = false, $e1, $e1_img;
        # the % is needed to support urlencoded titles as well
        if ( !$tc ) {
            $tc = Title::legalChars() . '#%';
Severity: Major
Found in includes/parser/Parser.php - About 1 day to fix

    Function execute has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
    Open

        public function execute( $par ) {
            $this->setHeaders();
            $this->outputHeader();
            $config = $this->getConfig();
    
    
    Severity: Minor
    Found in includes/specials/SpecialExport.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

    LocalFile has 71 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class LocalFile extends File {
        private const VERSION = 13; // cache version
    
        private const CACHE_FIELD_MAX_LEN = 1000;
    
    
    Severity: Major
    Found in includes/filerepo/file/LocalFile.php - About 1 day to fix

      File ApiQueryImageInfo.php has 604 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/ApiQueryImageInfo.php - About 1 day to fix

        Function deflate$1 has 261 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const deflate$1 = (strm, flush) => {
        
            if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) {
              return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;
            }
        Severity: Major
        Found in resources/lib/pako/pako_deflate.js - About 1 day to fix

          Method showHistory has 261 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function showHistory() {
                  $this->checkReadOnly();
          
                  $out = $this->getOutput();
                  if ( $this->mAllowed ) {
          Severity: Major
          Found in includes/specials/SpecialUndelete.php - About 1 day to fix

            File ChangeTags.php has 601 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Recent changes tagging.
             *
             * This program is free software; you can redistribute it and/or modify
            Severity: Major
            Found in includes/changetags/ChangeTags.php - About 1 day to fix

              Function execute has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function execute( $par ) {
                      $this->setHeaders();
                      $this->outputHeader();
                      $out = $this->getOutput();
                      // Modules required for viewing the list of contributions (also when included on other pages)
              Severity: Minor
              Found in includes/specialpage/ContributionsSpecialPage.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 66 (exceeds 5 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: Minor
              Found in includes/api/ApiExpandTemplates.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 showDiffPage has 260 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function showDiffPage( $diffOnly = false ) {
                      # Allow frames except in certain special cases
                      $out = $this->getOutput();
                      $out->setPreventClickjacking( false );
                      $out->setRobotPolicy( 'noindex,nofollow' );
              Severity: Major
              Found in includes/diff/DifferenceEngine.php - About 1 day to fix

                File recompressTracked.php has 600 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                /**
                 * Moves blobs indexed by trackBlobs.php to a specified list of destination
                 * clusters, and recompresses them in the process.
                 *
                Severity: Major
                Found in maintenance/storage/recompressTracked.php - About 1 day to fix

                  File Preprocessor_Hash.php has 599 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  /**
                   * Preprocessor using PHP arrays
                   *
                   * This program is free software; you can redistribute it and/or modify
                  Severity: Major
                  Found in includes/parser/Preprocessor_Hash.php - About 1 day to fix

                    Function ajax has 259 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        ajax: function( url, options ) {
                    
                            // If url is an object, simulate pre-1.5 signature
                            if ( typeof url === "object" ) {
                                options = url;
                    Severity: Major
                    Found in resources/lib/jquery/jquery.js - About 1 day to fix

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

                          protected function loadMetadataFromString( $metadataString ) {
                              $this->extraDataLoaded = true;
                              $this->metadataArray = [];
                              $this->metadataBlobs = [];
                              $this->unloadedMetadataBlobs = [];
                      Severity: Major
                      Found in includes/filerepo/file/LocalFile.php and 1 other location - About 1 day to fix
                      includes/filerepo/file/ArchivedFile.php on lines 558..595

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

                      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

                          protected function loadMetadataFromString( $metadataString ) {
                              $this->extraDataLoaded = true;
                              $this->metadataArray = [];
                              $this->metadataBlobs = [];
                              $this->unloadedMetadataBlobs = [];
                      Severity: Major
                      Found in includes/filerepo/file/ArchivedFile.php and 1 other location - About 1 day to fix
                      includes/filerepo/file/LocalFile.php on lines 1147..1184

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

                      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

                      ResourceLoader has 70 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class ResourceLoader implements LoggerAwareInterface {
                          /** @var int */
                          public const CACHE_VERSION = 9;
                          /** @var string JavaScript / CSS pragma to disable minification. * */
                          public const FILTER_NOMIN = '/*@nomin*/';
                      Severity: Major
                      Found in includes/ResourceLoader/ResourceLoader.php - About 1 day to fix

                        SpecialPage has 70 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        class SpecialPage implements MessageLocalizer {
                            /**
                             * @var string The canonical name of this special page
                             * Also used as the message key for the default <h1> heading,
                             * @see getDescription()
                        Severity: Major
                        Found in includes/specialpage/SpecialPage.php - About 1 day to fix

                          File DatabaseSqlite.php has 593 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/rdbms/database/DatabaseSqlite.php - About 1 day to fix

                            File Html.php has 593 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            <?php
                            /**
                             * Collection of methods to generate HTML content
                             *
                             * Copyright © 2009 Aryeh Gregor
                            Severity: Major
                            Found in includes/Html/Html.php - About 1 day to fix

                              File LogFormatter.php has 593 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              <?php
                              /**
                               * Contains a class for formatting log entries
                               *
                               * This program is free software; you can redistribute it and/or modify
                              Severity: Major
                              Found in includes/logging/LogFormatter.php - About 1 day to fix
                                Severity
                                Category
                                Status
                                Source
                                Language