wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Method getMetadata has 159 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getMetadata( $filename ) {
        self::$gifFrameSep = pack( "C", ord( "," ) ); // 2C
        self::$gifExtensionSep = pack( "C", ord( "!" ) ); // 21
        self::$gifTerm = pack( "C", ord( ";" ) ); // 3B

Severity: Major
Found in includes/media/GIFMetadataExtractor.php - About 6 hrs to fix

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

        final protected function doPrepare( array $params ) {
            /** @noinspection PhpUnusedLocalVariableInspection */
            $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );
            $status = $this->newStatus();
    
    
    Severity: Major
    Found in includes/libs/filebackend/FileBackendStore.php and 2 other locations - About 6 hrs to fix
    includes/libs/filebackend/FileBackendStore.php on lines 508..531
    includes/libs/filebackend/FileBackendStore.php on lines 545..568

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

    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 3 locations. Consider refactoring.
    Open

        final protected function doPublish( array $params ) {
            /** @noinspection PhpUnusedLocalVariableInspection */
            $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );
            $status = $this->newStatus();
    
    
    Severity: Major
    Found in includes/libs/filebackend/FileBackendStore.php and 2 other locations - About 6 hrs to fix
    includes/libs/filebackend/FileBackendStore.php on lines 471..494
    includes/libs/filebackend/FileBackendStore.php on lines 508..531

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

    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 3 locations. Consider refactoring.
    Open

        final protected function doSecure( array $params ) {
            /** @noinspection PhpUnusedLocalVariableInspection */
            $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );
            $status = $this->newStatus();
    
    
    Severity: Major
    Found in includes/libs/filebackend/FileBackendStore.php and 2 other locations - About 6 hrs to fix
    includes/libs/filebackend/FileBackendStore.php on lines 471..494
    includes/libs/filebackend/FileBackendStore.php on lines 545..568

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

    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

    FileModule has 46 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class FileModule extends Module {
        /** @var string Local base path, see __construct() */
        protected $localBasePath = '';
    
        /** @var string Remote base path, see __construct() */
    Severity: Minor
    Found in includes/ResourceLoader/FileModule.php - About 6 hrs to fix

      Handler has 46 functions (exceeds 20 allowed). Consider refactoring.
      Open

      abstract class Handler {
      
          /**
           * @see Validator::KNOWN_PARAM_SOURCES
           */
      Severity: Minor
      Found in includes/Rest/Handler.php - About 6 hrs to fix

        Function setDocument has 158 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function setDocument( node ) {
            var subWindow,
                doc = node ? node.ownerDocument || node : preferredDoc;
        
            // Return early if doc is invalid or already selected
        Severity: Major
        Found in resources/lib/jquery/jquery.js - About 6 hrs to fix

          Method run has 157 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function run( $resultPageSet = null ) {
                  $db = $this->getDB();
          
                  $params = $this->extractRequestParams();
          
          
          Severity: Major
          Found in includes/api/ApiQueryAllPages.php - About 6 hrs to fix

            File DiscordianDateTimeFormatter.js has 428 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

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

              Function makeCSPDirectives has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function makeCSPDirectives( $policyConfig, $mode ) {
                      if ( $policyConfig === false ) {
                          // CSP is disabled
                          return '';
                      }
              Severity: Minor
              Found in includes/Request/ContentSecurityPolicy.php - About 6 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 41 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function run( $resultPageSet = null ) {
                      $params = $this->extractRequestParams();
                      $result = $this->getResult();
              
                      $qp = $this->getSpecialPage( $params['page'] );
              Severity: Minor
              Found in includes/api/ApiQueryQueryPage.php - About 6 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 doImport has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function doImport() {
                      $isUpload = false;
                      $request = $this->getRequest();
                      $sourceName = $request->getVal( 'source' );
                      $assignKnownUsers = $request->getCheck( 'assignKnownUsers' );
              Severity: Minor
              Found in includes/specials/SpecialImport.php - About 6 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 normalizeSubpageLink has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function normalizeSubpageLink( $contextTitle, $target, &$text ) {
                      # Valid link forms:
                      # Foobar -- normal
                      # :Foobar -- override special treatment of prefix (images, language links)
                      # /Foobar -- convert to CurrentPage/Foobar
              Severity: Minor
              Found in includes/linker/Linker.php - About 6 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 execute has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function execute() {
                      $mcc = new MemcachedClient( [
                          'persistent' => true,
                          'debug' => $this->hasOption( 'debug' ),
                      ] );
              Severity: Minor
              Found in maintenance/mcc.php - About 6 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

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

                          } else {
                              $link.text( mw.msg( 'unwatching' ) );
                              promise = api.unwatch( title ).done( () => {
                                  $subjectLink.removeClass( 'mw-watched-item' );
                                  $link.text( mw.msg( 'watch' ) );
              resources/src/mediawiki.special.unwatchedPages/unwatchedPages.js on lines 21..31

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

              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 ( !$subjectLink.hasClass( 'mw-watched-item' ) ) {
                              $link.text( mw.msg( 'watching' ) );
                              promise = api.watch( title ).done( () => {
                                  $subjectLink.addClass( 'mw-watched-item' );
                                  $link.text( mw.msg( 'unwatch' ) );
              resources/src/mediawiki.special.unwatchedPages/unwatchedPages.js on lines 31..41

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

              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 BlockListPager.php has 427 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/specials/pagers/BlockListPager.php - About 6 hrs to fix

                Function size has 156 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                $.effects.effect.size = function( o, done ) {
                
                    // Create element
                    var original, baseline, factor,
                        el = $( this ),
                Severity: Major
                Found in resources/lib/jquery.ui/jquery.ui.effect-scale.js - About 6 hrs to fix

                  Method newRevisionsFromBatch has 156 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function newRevisionsFromBatch(
                          $rows,
                          array $options = [],
                          $queryFlags = 0,
                          PageIdentity $page = null
                  Severity: Major
                  Found in includes/Revision/RevisionStore.php - About 6 hrs to fix

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

                        public function execute( $par ) {
                            $this->setHeaders();
                            $this->addHelpLink( 'Help:Renameuser' );
                    
                            $this->checkPermissions();
                    Severity: Major
                    Found in includes/specials/SpecialRenameUser.php - About 6 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language