wikimedia/mediawiki-core

View on GitHub

Showing 11,461 of 11,461 total issues

Function find_middle_snake has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring.
Open

    private function find_middle_snake( $bottoml1, $topl1, $bottoml2, $topl2, &$V, &$snake ) {
        $from = &$this->from;
        $to = &$this->to;
        $V0 = &$V[0];
        $V1 = &$V[1];
Severity: Minor
Found in includes/libs/Diff/DiffEngine.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 getCoreUpdateList has 376 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function getCoreUpdateList() {
        return [
            // Exception to the sequential updates. Renaming pagecontent and mwuser.
            // Introduced in 1.36.
            [ 'renameTable', 'pagecontent', 'text' ],
Severity: Major
Found in includes/installer/PostgresUpdater.php - About 1 day to fix

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

        _getParentOffset: function() {
    
            //Get the offsetParent and cache its position
            this.offsetParent = this.helper.offsetParent();
            var po = this.offsetParent.offset();
    Severity: Major
    Found in resources/lib/jquery.ui/jquery.ui.draggable.js and 1 other location - About 1 day to fix
    resources/lib/jquery.ui/jquery.ui.sortable.js on lines 817..842

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

    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

        _getParentOffset: function() {
    
    
            //Get the offsetParent and cache its position
            this.offsetParent = this.helper.offsetParent();
    Severity: Major
    Found in resources/lib/jquery.ui/jquery.ui.sortable.js and 1 other location - About 1 day to fix
    resources/lib/jquery.ui/jquery.ui.draggable.js on lines 309..333

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

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

        public static function getInfo( $file, $prop, $result, $thumbParams = null, $opts = false ) {
            $anyHidden = false;
    
            $services = MediaWikiServices::getInstance();
    
    
    Severity: Minor
    Found in includes/api/ApiQueryImageInfo.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 SpecialUserRights.php has 783 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/specials/SpecialUserRights.php - About 1 day to fix

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

          private function run( ApiPageSet $resultPageSet = null ) {
              $settings = self::$settings[$this->getModuleName()];
      
              $db = $this->getDB();
              $params = $this->extractRequestParams();
      Severity: Minor
      Found in includes/api/ApiQueryBacklinksprop.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 LanguageConverter.php has 777 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/LanguageConverter.php - About 1 day to fix

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

          File UserGroupManager.php has 771 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/user/UserGroupManager.php - About 1 day to fix

            Function getMetadata has a Cognitive Complexity of 90 (exceeds 5 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: Minor
            Found in includes/media/GIFMetadataExtractor.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 run has a Cognitive Complexity of 90 (exceeds 5 allowed). Consider refactoring.
            Open

                private function run( $resultPageSet = null ) {
                    $params = $this->extractRequestParams();
            
                    $categoryTitle = $this->getTitleOrPageId( $params )->getTitle();
                    if ( $categoryTitle->getNamespace() !== NS_CATEGORY ) {
            Severity: Minor
            Found in includes/api/ApiQueryCategoryMembers.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 DatabasePostgres.php has 763 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/DatabasePostgres.php - About 1 day to fix

              File HTMLFormField.php has 762 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              namespace MediaWiki\HTMLForm;
              
              use HtmlArmor;
              Severity: Major
              Found in includes/htmlform/HTMLFormField.php - About 1 day to fix

                Function checkSettings has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function checkSettings(
                        ApiBase $module, array $params, string $name, array $options
                    ): array {
                        $options['module'] = $module;
                        $settings = $params[$name];
                Severity: Minor
                Found in includes/api/Validator/ApiParamValidator.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 setup has 356 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  setup(props, { emit, slots, attrs }) {
                    const computedMenuItems = computed(() => {
                      const menuItemsWithFooter = props.footer && props.menuItems ? [...props.menuItems, props.footer] : props.menuItems;
                      return menuItemsWithFooter.map((menuItem) => __spreadProps(__spreadValues({}, menuItem), {
                        id: useGeneratedId("menu-item")
                Severity: Major
                Found in resources/lib/codex/codex.js - About 1 day to fix

                  EditPage has 93 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  #[\AllowDynamicProperties]
                  class EditPage implements IEditObject {
                      use DeprecationHelper;
                      use ProtectedHookAccessorTrait;
                  
                  
                  Severity: Major
                  Found in includes/editpage/EditPage.php - About 1 day to fix

                    HTMLForm has 93 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class HTMLForm extends ContextSource {
                        use ProtectedHookAccessorTrait;
                    
                        /** @var string[] A mapping of 'type' inputs onto standard HTMLFormField subclasses */
                        public static $typeMappings = [
                    Severity: Major
                    Found in includes/htmlform/HTMLForm.php - About 1 day to fix

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

                          private $table = [
                              'а' => 'a',
                              'б' => 'b',
                              'в' => 'v',
                              'г' => 'g',
                      Severity: Major
                      Found in includes/language/converters/TgConverter.php and 1 other location - About 1 day to fix
                      includes/language/converters/UzConverter.php on lines 65..102

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

                      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

                          public $toCyrillic = [
                              'a' => 'а', 'A' => 'А',
                              'b' => 'б', 'B' => 'Б',
                              'd' => 'д', 'D' => 'Д',
                              // at the beginning of a word and after a vowel, "э" is used instead of "e"
                      Severity: Major
                      Found in includes/language/converters/UzConverter.php and 1 other location - About 1 day to fix
                      includes/language/converters/TgConverter.php on lines 31..105

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language