wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function extractRevisionInfo has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

    protected function extractRevisionInfo( RevisionRecord $revision, $row ) {
        $vals = [];
        $anyHidden = false;

        if ( $this->fld_ids ) {
Severity: Minor
Found in includes/api/ApiQueryRevisionsBase.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 execute has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        // Get parameters
        $params = $this->extractRequestParams();

        $this->helpFormat = $params['helpformat'];
Severity: Minor
Found in includes/api/ApiParamInfo.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 execute has 227 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function execute() {
        // Parse some parameters
        $this->params = $this->extractRequestParams();

        $prop = array_fill_keys( $this->params['prop'], true );
Severity: Major
Found in includes/api/ApiQueryUserContribs.php - About 1 day to fix

    MediaHandler has 62 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class MediaHandler {
        public const TRANSFORM_LATER = 1;
        public const METADATA_GOOD = true;
        public const METADATA_BAD = false;
        public const METADATA_COMPATIBLE = 2; // for old but backwards compatible.
    Severity: Major
    Found in includes/media/MediaHandler.php - About 1 day to fix

      Function showDiffPage has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
      Open

          public function showDiffPage( $diffOnly = false ) {
              # Allow frames except in certain special cases
              $out = $this->getOutput();
              $out->setPreventClickjacking( false );
              $out->setRobotPolicy( 'noindex,nofollow' );
      Severity: Minor
      Found in includes/diff/DifferenceEngine.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 SpecialRevisionDelete.php has 538 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/SpecialRevisionDelete.php - About 1 day to fix

        File FileBackendMultiWrite.php has 532 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * Proxy backend that mirrors writes to several internal backends.
         *
         * This program is free software; you can redistribute it and/or modify
        Severity: Major
        Found in includes/libs/filebackend/FileBackendMultiWrite.php - About 1 day to fix

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

            File CategoryViewer.php has 532 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * List and paging of category members.
             *
             * This program is free software; you can redistribute it and/or modify
            Severity: Major
            Found in includes/Category/CategoryViewer.php - About 1 day to fix

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

                  public function execute() {
                      $oldLayout = $this->getOption( 'oldlayout' );
                      if ( !in_array( $oldLayout, [ 'name', 'sha1' ] ) ) {
                          $this->fatalError( "Invalid old layout." );
                      }
              Severity: Minor
              Found in maintenance/migrateFileRepoLayout.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 PageHistoryCountHandler.php has 531 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              namespace MediaWiki\Rest\Handler;
              
              use ChangeTags;
              Severity: Major
              Found in includes/Rest/Handler/PageHistoryCountHandler.php - About 1 day to fix

                Method convertGrammarKk_cyrl has 218 lines of code (exceeds 25 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: Major
                Found in includes/languages/LanguageKk_cyrl.php - About 1 day to fix

                  File jpegmeta.js has 528 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  /**
                   * This is JsJpegMeta v1.0
                   * From: https://code.google.com/p/jsjpegmeta/downloads/list
                   * From: https://github.com/bennoleslie/jsjpegmeta/blob/v1.0.0/jpegmeta.js
                   *
                  Severity: Major
                  Found in resources/src/mediawiki.libs.jpegmeta/jpegmeta.js - About 1 day to fix

                    WANObjectCache has 60 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class WANObjectCache implements
                        ExpirationAwareness,
                        StorageAwareness,
                        IStoreKeyEncoder,
                        LoggerAwareInterface
                    Severity: Major
                    Found in includes/libs/objectcache/WANObjectCache.php - About 1 day to fix

                      SiteConfig has 60 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class SiteConfig extends ISiteConfig {
                      
                          /**
                           * Regular expression fragment for matching wikitext comments.
                           * Meant for inclusion in other regular expressions.
                      Severity: Major
                      Found in includes/parser/Parsoid/Config/SiteConfig.php - About 1 day to fix

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

                            public function execute() {
                                $db = $this->getDB();
                                $params = $this->extractRequestParams();
                                $this->requireMaxOneParameter( $params, 'users', 'ip' );
                        
                        
                        Severity: Major
                        Found in includes/api/ApiQueryBlocks.php - About 1 day to fix

                          File jquery.ui.slider.js has 526 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          /*!
                           * jQuery UI Slider 1.9.2
                           * http://jqueryui.com
                           *
                           * Copyright 2012 jQuery Foundation and other contributors
                          Severity: Major
                          Found in resources/lib/jquery.ui/jquery.ui.slider.js - About 1 day to fix

                            File SessionBackend.php has 525 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            <?php
                            /**
                             * MediaWiki session backend
                             *
                             * This program is free software; you can redistribute it and/or modify
                            Severity: Major
                            Found in includes/session/SessionBackend.php - About 1 day to fix

                              Function setup has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
                              Open

                                setup(props, { emit, attrs }) {
                                  const rootElement = ref();
                                  const statusMessageContent = ref("");
                                  const computedDirection = useComputedDirection(rootElement);
                                  const input = ref();
                              Severity: Minor
                              Found in resources/lib/codex/codex.js - 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 extractOutputData has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private function extractOutputData( WatchedItem $watchedItem, array $recentChangeInfo ) {
                                      /* Determine the title of the page that has been changed. */
                                      $target = $watchedItem->getTarget();
                                      if ( $target instanceof LinkTarget ) {
                                          $title = Title::newFromLinkTarget( $target );
                              Severity: Minor
                              Found in includes/api/ApiQueryWatchlist.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

                              Severity
                              Category
                              Status
                              Source
                              Language