wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

    public function execute() {
        if ( !$this->enabled ) {
            $this->fatalError( "Nothing to do -- \$wgUseFileCache is disabled." );
        }

Severity: Major
Found in maintenance/rebuildFileCache.php - About 4 hrs to fix

    File MessagesUr.php has 351 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /** Urdu (اردو)
     *
     * @file
     * @ingroup Languages
    Severity: Minor
    Found in languages/messages/MessagesUr.php - About 4 hrs to fix

      Function makeModuleResponse has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function makeModuleResponse( Context $context,
              array $modules, array $missing = []
          ) {
              if ( $modules === [] && $missing === [] ) {
                  return <<<MESSAGE
      Severity: Minor
      Found in includes/ResourceLoader/ResourceLoader.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 stream has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function stream(
              $headers = [], $sendErrors = true, $optHeaders = [], $flags = 0
          ) {
              $headless = ( $flags & self::STREAM_HEADLESS );
      
      
      Severity: Minor
      Found in includes/libs/filebackend/HTTPFileStreamer.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 wfArrayToCgi has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      function wfArrayToCgi( $array1, $array2 = null, $prefix = '' ) {
          if ( $array2 !== null ) {
              $array1 += $array2;
          }
      
      
      Severity: Minor
      Found in includes/GlobalFunctions.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 __construct has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __construct( $siteName, $admin = null, array $options = [] ) {
              global $wgPasswordPolicy;
      
              parent::__construct();
      
      
      Severity: Minor
      Found in includes/installer/CliInstaller.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 extractRowInfo has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          private function extractRowInfo( $row ) {
              $vals = [];
              $anyHidden = false;
      
              if ( $row->rev_deleted & RevisionRecord::DELETED_TEXT ) {
      Severity: Minor
      Found in includes/api/ApiQueryUserContribs.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 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function execute() {
              $params = $this->extractRequestParams();
      
              $pageObj = $this->getTitleOrPageId( $params, 'fromdbmaster' );
              $titleObj = $pageObj->getTitle();
      Severity: Minor
      Found in includes/api/ApiProtect.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 runFirstQuery has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          private function runFirstQuery( $resultPageSet = null ) {
              $this->addTables( [ $this->bl_table, 'page' ] );
              $this->addWhere( "{$this->bl_from}=page_id" );
              if ( $resultPageSet === null ) {
                  $this->addFields( [ 'page_id', 'page_title', 'page_namespace' ] );
      Severity: Minor
      Found in includes/api/ApiQueryBacklinks.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 checkConditionalRequestHeaders has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function checkConditionalRequestHeaders( $module ) {
              if ( $this->mInternalMode ) {
                  // No headers to check in internal mode
                  return true;
              }
      Severity: Minor
      Found in includes/api/ApiMain.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 showPrefixChunk has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function showPrefixChunk( $namespace, $prefix, $from = null ) {
              $from ??= $prefix;
      
              $fromList = $this->getNamespaceKeyAndText( $namespace, $from );
              $prefixList = $this->getNamespaceKeyAndText( $namespace, $prefix );
      Severity: Minor
      Found in includes/specials/SpecialPrefixIndex.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 loadFromRow has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function loadFromRow( $row, $data = null ) {
              if ( !is_object( $row ) ) {
                  throw new InvalidArgumentException( '$row must be an object' );
              }
      
      
      Severity: Minor
      Found in includes/user/User.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 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function execute() {
              $doDelete = $this->hasOption( 'delete' );
              $doDeleteTalk = $this->hasOption( 'delete-talk' );
              $langCode = $this->getOption( 'lang-code' );
      
      
      Severity: Minor
      Found in maintenance/deleteEqualMessages.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 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function execute() {
              $config = $this->getConfig();
              $extensionEntryPointListFiles = $config->get( MainConfigNames::ExtensionEntryPointListFiles );
      
              if ( !count( $extensionEntryPointListFiles )
      Severity: Minor
      Found in maintenance/mergeMessageFileList.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

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

              if ( isset( $params['5:array:newgroups'] ) ) {
                  $params['5:array:newgroups'] = $this->makeGroupArray( $params['5:array:newgroups'] );
      
                  $newmetadata =& $params['newmetadata'];
                  // unset old metadata entry to ensure metadata goes at the end of the params array
      Severity: Major
      Found in includes/logging/RightsLogFormatter.php and 1 other location - About 4 hrs to fix
      includes/logging/RightsLogFormatter.php on lines 182..197

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

      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 function __construct(
              LinkBatchFactory $linkBatchFactory,
              PermissionManager $permissionManager,
              IConnectionProvider $dbProvider,
              RevisionStore $revisionStore,
      Severity: Major
      Found in includes/specials/SpecialContributions.php and 1 other location - About 4 hrs to fix
      includes/specials/SpecialDeletedContributions.php on lines 71..103

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

      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 ( isset( $params['4:array:oldgroups'] ) ) {
                  $params['4:array:oldgroups'] = $this->makeGroupArray( $params['4:array:oldgroups'] );
      
                  $oldmetadata =& $params['oldmetadata'];
                  // unset old metadata entry to ensure metadata goes at the end of the params array
      Severity: Major
      Found in includes/logging/RightsLogFormatter.php and 1 other location - About 4 hrs to fix
      includes/logging/RightsLogFormatter.php on lines 199..214

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

      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 function __construct(
              PermissionManager $permissionManager,
              IConnectionProvider $dbProvider,
              RevisionStore $revisionStore,
              NamespaceInfo $namespaceInfo,
      Severity: Major
      Found in includes/specials/SpecialDeletedContributions.php and 1 other location - About 4 hrs to fix
      includes/specials/SpecialContributions.php on lines 70..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 171.

      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 MwWidgetsDatetimeCalendarWidget has 110 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          mw.widgets.datetime.CalendarWidget = function MwWidgetsDatetimeCalendarWidget( config ) {
              // Configuration initialization
              config = Object.assign( {
                  min: null,
                  max: null,
      Severity: Major
      Found in resources/src/mediawiki.widgets.datetime/CalendarWidget.js - About 4 hrs to fix

        Method rollback has 110 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function rollback() {
                // Begin revision creation cycle by creating a PageUpdater.
                // If the page is changed concurrently after grabParentRevision(), the rollback will fail.
                // TODO: move PageUpdater to PageStore or PageUpdaterFactory or something?
                $updater = $this->wikiPageFactory->newFromTitle( $this->page )->newPageUpdater( $this->performer );
        Severity: Major
        Found in includes/page/RollbackPage.php - About 4 hrs to fix
          Severity
          Category
          Status
          Source
          Language