wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

File BookletLayout.js has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global moment */
( function () {

    /**
     * @classdesc Encapsulates the process of uploading a file
Severity: Minor
Found in resources/src/mediawiki.Upload.BookletLayout/BookletLayout.js - About 4 hrs to fix

    Function useFloating has 115 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function useFloating(reference, floating, options) {
      if (options === void 0) {
        options = {};
      }
      const whileElementsMountedOption = options.whileElementsMounted;
    Severity: Major
    Found in resources/lib/codex/codex.js - About 4 hrs to fix

      Method fetchBlobs has 115 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function fetchBlobs( $blobAddresses, $queryFlags ) {
              $textIdToBlobAddress = [];
              $result = [];
              $errors = [];
              foreach ( $blobAddresses as $blobAddress ) {
      Severity: Major
      Found in includes/Storage/SqlBlobStore.php - About 4 hrs to fix

        Method tsToHebrew has 115 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function tsToHebrew( $ts ) {
                # Parse date
                $year = (int)substr( $ts, 0, 4 );
                $month = (int)substr( $ts, 4, 2 );
                $day = (int)substr( $ts, 6, 2 );
        Severity: Major
        Found in includes/language/Language.php - About 4 hrs to fix

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

                      if (
                          ( this.isClippedVertically() || this.isFloatableOutOfView() ) &&
                          this.originalVerticalPosition !== 'center'
                      ) {
                          // If opening the menu in one direction causes it to be clipped, flip it
          Severity: Major
          Found in resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js and 1 other location - About 4 hrs to fix
          resources/lib/ooui/oojs-ui-core.js on lines 8818..8835

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

          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

                      if (
                          ( this.isClippedVertically() || this.isFloatableOutOfView() ) &&
                          this.originalVerticalPosition !== 'center'
                      ) {
                          // If opening the menu in one direction causes it to be clipped, flip it
          Severity: Major
          Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 4 hrs to fix
          resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js on lines 656..673

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

          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 SelectQueryBuilder.php has 358 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          namespace Wikimedia\Rdbms;
          
          use Wikimedia\Rdbms\Platform\ISQLPlatform;
          Severity: Minor
          Found in includes/libs/rdbms/querybuilder/SelectQueryBuilder.php - About 4 hrs to fix

            File MediaHandler.php has 358 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/media/MediaHandler.php - About 4 hrs to fix

              File JobRunner.php has 358 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/jobqueue/JobRunner.php - About 4 hrs to fix

                File compressOld.php has 358 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                /**
                 * Compress the text of a wiki.
                 *
                 * Usage:
                Severity: Minor
                Found in maintenance/storage/compressOld.php - About 4 hrs to fix

                  Function save has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function save( $closing = false ) {
                          $anon = $this->user->isAnon();
                  
                          if ( !$anon && $this->provider->getManager()->isUserSessionPrevented( $this->user->getName() ) ) {
                              $this->logger->debug(
                  Severity: Minor
                  Found in includes/session/SessionBackend.php - About 4 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 doDelete has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function doDelete(
                          Title $title,
                          LocalFile $file,
                          ?string $oldimage,
                          $reason,
                  Severity: Minor
                  Found in includes/page/File/FileDeleteForm.php - About 4 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 handleTypeTar has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function handleTypeTar( $moduleName, $destDir, array $info, string $fileType ) {
                          $info += [ 'src' => null, 'integrity' => null, 'dest' => null ];
                          if ( $info['src'] === null ) {
                              throw new LogicException( "Module '$moduleName' must have a 'src' key." );
                          }
                  Severity: Minor
                  Found in includes/ResourceLoader/ForeignResourceManager.php - About 4 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 showEditForm has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function showEditForm() {
                          # need to parse the preview early so that we know which templates are used,
                          # otherwise users with "show preview after edit box" will get a blank list
                          # we parse this near the beginning so that setHeaders can do the title
                          # setting work instead of leaving it in getPreviewText
                  Severity: Minor
                  Found in includes/editpage/EditPage.php - About 4 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 edit has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function edit() {
                          // Allow extensions to modify/prevent this form or submission
                          if ( !$this->getHookRunner()->onAlternateEdit( $this ) ) {
                              return;
                          }
                  Severity: Minor
                  Found in includes/editpage/EditPage.php - About 4 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 debugInfo has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function debugInfo( ParserOutput $po ): string {
                          $text = '';
                  
                          $limitReportData = $po->getLimitReportData();
                          // If nothing set it, we can't get it.
                  Severity: Minor
                  Found in includes/OutputTransform/Stages/RenderDebugInfo.php - About 4 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 getCharset has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function getCharset( $tag ) {
                          // According to iim standard, charset is defined by the tag 1:90.
                          // in which there are iso 2022 escape sequences to specify the character set.
                          // the iim standard seems to encourage that all necessary escape sequences are
                          // in the 1:90 tag, but says it doesn't have to be.
                  Severity: Minor
                  Found in includes/media/IPTC.php - About 4 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 getAliasList has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function getAliasList(): array {
                          if ( $this->aliases === null ) {
                              $aliases = $this->contLang->getSpecialPageAliases();
                              $pageList = $this->getPageList();
                  
                  
                  Severity: Minor
                  Found in includes/specialpage/SpecialPageFactory.php - About 4 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 31 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function run( $resultPageSet = null ) {
                          $params = $this->extractRequestParams();
                  
                          if ( isset( $params['title'] ) && !isset( $params['prefix'] ) ) {
                              $this->dieWithError(
                  Severity: Minor
                  Found in includes/api/ApiQueryIWBacklinks.php - About 4 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 31 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function execute() {
                          $user = $this->getUser();
                          $params = $this->extractRequestParams();
                  
                          if ( $user->isBot() ) {
                  Severity: Minor
                  Found in includes/api/ApiStashEdit.php - About 4 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

                  Severity
                  Category
                  Status
                  Source
                  Language