wikimedia/mediawiki-core

View on GitHub

Showing 11,498 of 11,498 total issues

File JobQueueDB.php has 643 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/jobqueue/JobQueueDB.php - About 1 day to fix

    Function applyTransformations has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
    Open

        protected static function applyTransformations( array $dataIn, array $transforms ) {
            $strip = $transforms['Strip'] ?? 'none';
            if ( $strip === 'base' ) {
                $transforms['Strip'] = 'none';
            }
    Severity: Minor
    Found in includes/api/ApiResult.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 72 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function run( ApiPageSet $resultPageSet = null ) {
            $pageSet = $this->getPageSet();
            $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
            $pageCount = count( $pageSet->getGoodAndMissingPages() );
            $revCount = $pageSet->getRevisionCount();
    Severity: Minor
    Found in includes/api/ApiQueryDeletedRevisions.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 __construct has 283 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __construct( $file, $byteOrder = '' ) {
            /**
             * Page numbers here refer to pages in the Exif 2.2 standard
             *
             * Note, Exif::UNDEFINED is treated as a string, not as an array of bytes
    Severity: Major
    Found in includes/media/Exif.php - About 1 day to fix

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

      $namespaceAliases = [
          'Медйа'            => NS_MEDIA,
          'Белхан'           => NS_SPECIAL,
          'Башхо'            => NS_SPECIAL,
          'Дийца'            => NS_TALK,
      Severity: Major
      Found in languages/messages/MessagesCe.php and 1 other location - About 1 day to fix
      languages/messages/MessagesKk_arab.php on lines 57..101

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

      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

      $namespaceAliases = [
          # Aliases to kk-cyrl namespaces
          'Таспа'               => NS_MEDIA,
          'Арнайы'              => NS_SPECIAL,
          'Талқылау'            => NS_TALK,
      Severity: Major
      Found in languages/messages/MessagesKk_arab.php and 1 other location - About 1 day to fix
      languages/messages/MessagesCe.php on lines 31..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 312.

      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

      Method recordUpload3 has 280 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function recordUpload3(
              string $oldver,
              string $comment,
              string $pageText,
              Authority $performer,
      Severity: Major
      Found in includes/filerepo/file/LocalFile.php - About 1 day to fix

        Method check has 280 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function check( $fix = false, $xml = '' ) {
                $dbr = $this->getReplicaDB();
                if ( $fix ) {
                    print "Checking, will fix errors if possible...\n";
                } else {
        Severity: Major
        Found in maintenance/storage/checkStorage.php - About 1 day to fix

          File Exif.php has 633 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * Extraction and validation of image metadata.
           *
           * This program is free software; you can redistribute it and/or modify
          Severity: Major
          Found in includes/media/Exif.php - About 1 day to fix

            File ApiResult.php has 633 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/api/ApiResult.php - About 1 day to fix

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

                File ParserOptions.php has 632 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

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

                  Function sendRequest has 279 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          sendRequest: function ( params ) {
                              var deferreds = [],
                                  paramsAreForced = !!params,
                                  displayParams = {},
                                  ajaxOptions = {},
                  Severity: Major
                  Found in resources/src/mediawiki.special.apisandbox/apisandbox.js - About 1 day to fix

                    Method continueAuthentication has 279 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function continueAuthentication( array $reqs ) {
                            $session = $this->request->getSession();
                            try {
                                if ( !$session->canSetUser() ) {
                                    // Caller should have called canAuthenticateNow()
                    Severity: Major
                    Found in includes/auth/AuthManager.php - About 1 day to fix

                      File MimeAnalyzer.php has 629 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/mime/MimeAnalyzer.php - About 1 day to fix

                        Function makeList has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function makeList( array $a, $mode = self::LIST_COMMA ) {
                                $first = true;
                                $list = '';
                                $keyWarning = null;
                        
                        
                        Severity: Minor
                        Found in includes/libs/rdbms/platform/SQLPlatform.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 extractPageInfo has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function extractPageInfo( $pageid, $page ) {
                                $title = $this->titleFactory->newFromPageIdentity( $page );
                                $pageInfo = [];
                                // $page->exists() needs pageid, which is not set for all title objects
                                $pageExists = $pageid > 0;
                        Severity: Minor
                        Found in includes/api/ApiQueryInfo.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 extractRowInfo has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function extractRowInfo( $row ) {
                                /* Determine the title of the page that has been changed. */
                                $title = Title::makeTitle( $row->rc_namespace, $row->rc_title );
                                $user = $this->getUser();
                        
                        
                        Severity: Minor
                        Found in includes/api/ApiQueryRecentChanges.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

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

                                    if ( data.collisionWidth > outerWidth ) {
                                        // element is initially over the left side of within
                                        if ( overLeft > 0 && overRight <= 0 ) {
                                            newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
                                            position.left += overLeft - newOverRight;
                        Severity: Major
                        Found in resources/lib/jquery.ui/jquery.ui.position.js and 1 other location - About 1 day to fix
                        resources/lib/jquery.ui/jquery.ui.position.js on lines 335..360

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

                        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 ( data.collisionHeight > outerHeight ) {
                                        // element is initially over the top of within
                                        if ( overTop > 0 && overBottom <= 0 ) {
                                            newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
                                            position.top += overTop - newOverBottom;
                        Severity: Major
                        Found in resources/lib/jquery.ui/jquery.ui.position.js and 1 other location - About 1 day to fix
                        resources/lib/jquery.ui/jquery.ui.position.js on lines 298..323

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

                        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