wikimedia/mediawiki-core

View on GitHub

Showing 11,461 of 11,461 total issues

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

    protected function run( ApiPageSet $resultPageSet = null ) {
        $params = $this->extractRequestParams( false );

        // If any of those parameters are used, work in 'enumeration' mode.
        // Enum mode can only be used when exactly one page is provided.
Severity: Minor
Found in includes/api/ApiQueryRevisions.php - About 2 days 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 MessageCache.php has 918 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/language/MessageCache.php - About 2 days to fix

    Method sprintfDate has 449 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function sprintfDate( $format, $ts, DateTimeZone $zone = null, &$ttl = 'unused' ) {
            // @phan-suppress-previous-line PhanTypeMismatchDefault Type mismatch on pass-by-ref args
            $s = '';
            $raw = false;
            $roman = false;
    Severity: Major
    Found in includes/language/Language.php - About 2 days to fix

      File ApiParse.php has 902 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * Copyright © 2007 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
       *
       * This program is free software; you can redistribute it and/or modify
      Severity: Major
      Found in includes/api/ApiParse.php - About 2 days to fix

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

            public function execute() {
                $services = $this->getServiceContainer();
                $permissionManager = $services->getPermissionManager();
        
                $found = 0;
        Severity: Minor
        Found in maintenance/importImages.php - About 2 days 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 convertGrammarKk_cyrl has a Cognitive Complexity of 108 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function convertGrammarKk_cyrl( $word, $case ) {
                $grammarForms =
                    MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms );
                if ( isset( $grammarForms['kk-kz'][$case][$word] ) ) {
                    return $grammarForms['kk-kz'][$case][$word];
        Severity: Minor
        Found in includes/languages/LanguageKk_cyrl.php - About 2 days 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 execute has 432 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function execute() {
                // The data is hot but user-dependent, like page views, so we set vary cookies
                $this->getMain()->setCacheMode( 'anon-public-user-private' );
        
                // Get parameters
        Severity: Major
        Found in includes/api/ApiParse.php - About 2 days to fix

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

          ;(function (global, factory) {
             typeof exports === 'object' && typeof module !== 'undefined'
                 && typeof require === 'function' ? factory(require('../moment')) :
             typeof define === 'function' && define.amd ? define(['../moment'], factory) :
             factory(global.moment)
          Severity: Major
          Found in resources/lib/moment/locale/nn.js and 1 other location - About 2 days to fix
          resources/lib/moment/locale/nb.js on lines 7..70

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

          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

          ;(function (global, factory) {
             typeof exports === 'object' && typeof module !== 'undefined'
                 && typeof require === 'function' ? factory(require('../moment')) :
             typeof define === 'function' && define.amd ? define(['../moment'], factory) :
             factory(global.moment)
          Severity: Major
          Found in resources/lib/moment/locale/nb.js and 1 other location - About 2 days to fix
          resources/lib/moment/locale/nn.js on lines 6..69

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

          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

          ;(function (global, factory) {
             typeof exports === 'object' && typeof module !== 'undefined'
                 && typeof require === 'function' ? factory(require('../moment')) :
             typeof define === 'function' && define.amd ? define(['../moment'], factory) :
             factory(global.moment)
          Severity: Major
          Found in resources/lib/moment/locale/fil.js and 1 other location - About 2 days to fix
          resources/lib/moment/locale/tl-ph.js on lines 5..68

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

          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

          ;(function (global, factory) {
             typeof exports === 'object' && typeof module !== 'undefined'
                 && typeof require === 'function' ? factory(require('../moment')) :
             typeof define === 'function' && define.amd ? define(['../moment'], factory) :
             factory(global.moment)
          Severity: Major
          Found in resources/lib/moment/locale/tl-ph.js and 1 other location - About 2 days to fix
          resources/lib/moment/locale/fil.js on lines 6..69

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

          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 jquery.tablesorter.js has 879 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /**
           * TableSorter for MediaWiki
           *
           * Written 2011 Leo Koppelkamm
           * Based on tablesorter.com plugin, written (c) 2007 Christian Bach.
          Severity: Major
          Found in resources/src/jquery.tablesorter/jquery.tablesorter.js - About 2 days to fix

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

                public function execute() {
                    $params = $this->extractRequestParams();
            
                    $prop = array_fill_keys( $params['prop'], true );
            
            
            Severity: Minor
            Found in includes/api/ApiQueryImageInfo.php - About 2 days 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

                _convertPositionTo: function(d, pos) {
            
                    if(!pos) pos = this.position;
                    var mod = d == "absolute" ? 1 : -1;
                    var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
            Severity: Major
            Found in resources/lib/jquery.ui/jquery.ui.sortable.js and 1 other location - About 2 days to fix
            resources/lib/jquery.ui/jquery.ui.draggable.js on lines 396..417

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

            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

                _convertPositionTo: function(d, pos) {
            
                    if(!pos) pos = this.position;
                    var mod = d == "absolute" ? 1 : -1;
                    var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
            Severity: Major
            Found in resources/lib/jquery.ui/jquery.ui.draggable.js and 1 other location - About 2 days to fix
            resources/lib/jquery.ui/jquery.ui.sortable.js on lines 898..919

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

            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 ImagePage.php has 872 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/page/ImagePage.php - About 2 days to fix

              Function buildContentNavigationUrlsInternal has a Cognitive Complexity of 105 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function buildContentNavigationUrlsInternal() {
                      if ( $this->contentNavigationCached ) {
                          return $this->contentNavigationCached;
                      }
                      // Display tabs for the relevant title rather than always the title itself
              Severity: Minor
              Found in includes/skins/SkinTemplate.php - About 2 days 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 ApiUpload.php has 871 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              /**
               * Copyright © 2008 - 2010 Bryan Tong Minh <Bryan.TongMinh@Gmail.com>
               *
               * This program is free software; you can redistribute it and/or modify
              Severity: Major
              Found in includes/api/ApiUpload.php - About 2 days to fix

                Method profilePreferences has 421 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function profilePreferences(
                        User $user, IContextSource $context, &$defaultPreferences
                    ) {
                        // retrieving user name for GENDER and misc.
                        $userName = $user->getName();
                Severity: Major
                Found in includes/preferences/DefaultPreferencesFactory.php - About 2 days to fix

                  ParserOptions has 109 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class ParserOptions {
                  
                      /**
                       * Default values for all options that are relevant for caching.
                       * @see self::getDefaults()
                  Severity: Major
                  Found in includes/parser/ParserOptions.php - About 2 days to fix
                    Severity
                    Category
                    Status
                    Source
                    Language