wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

File Names.php has 556 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/languages/data/Names.php - About 1 day to fix

    File HtmlOutputRendererHelper.php has 556 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/Rest/Handler/Helper/HtmlOutputRendererHelper.php - About 1 day to fix

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

      <?php
      /** Lazuri (Lazuri)
       *
       * @file
       * @ingroup Languages
      Severity: Major
      Found in languages/messages/MessagesLzz.php and 1 other location - About 1 day to fix
      languages/messages/MessagesKiu.php on lines 1..46

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

      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

      <?php
      /** Kirmanjki (Kırmancki)
       *
       * @file
       * @ingroup Languages
      Severity: Major
      Found in languages/messages/MessagesKiu.php and 1 other location - About 1 day to fix
      languages/messages/MessagesLzz.php on lines 1..55

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

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

        setup(props, { attrs, emit, slots }) {
          const form = ref();
          const menu = ref();
          const menuId = useGeneratedId("typeahead-search-menu");
          const translatedSearchResultsLabel = useI18n("cdx-typeahead-search-search-results-label", "Search results");
      Severity: Major
      Found in resources/lib/codex/codex.js - About 1 day to fix

        Method formatRow has 232 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function formatRow( $row ) {
                $ret = '';
                $classes = [];
                $attribs = [];
                $authority = $this->getAuthority();
        Severity: Major
        Found in includes/pager/ContributionsPager.php - About 1 day to fix

          Method doSubmit has 232 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function doSubmit() {
                  $user = $this->getUser();
          
                  if ( $user->pingLimiter( 'move' ) ) {
                      throw new ThrottledError;
          Severity: Major
          Found in includes/specials/SpecialMovePage.php - About 1 day to fix

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

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

                  private function run( $resultPageSet = null ) {
                      $this->params = $this->extractRequestParams( false );
                      $this->redirect = isset( $this->params['redirect'] ) && $this->params['redirect'];
                      $userMax = ( $this->redirect ? ApiBase::LIMIT_BIG1 / 2 : ApiBase::LIMIT_BIG1 );
                      $botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2 / 2 : ApiBase::LIMIT_BIG2 );
              Severity: Minor
              Found in includes/api/ApiQueryBacklinks.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 showIndirectLinks has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function showIndirectLinks(
                      $level, LinkTarget $target, $limit, $offsetNamespace = 0, $offsetPageID = 0, $dir = 'next'
                  ) {
                      $out = $this->getOutput();
                      $dbr = $this->dbProvider->getReplicaDatabase();
              Severity: Minor
              Found in includes/specials/SpecialWhatLinksHere.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 findColonNoLinks has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function findColonNoLinks( $str, &$before, &$after ) {
                      if ( !preg_match( '/:|<|-\{/', $str, $m, PREG_OFFSET_CAPTURE ) ) {
                          # Nothing to find!
                          return false;
                      }
              Severity: Minor
              Found in includes/parser/BlockLevelPass.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 makeApi has 230 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function makeApi(sinon) {
                      sinon.xhr = sinonXhr;
              
                      sinon.extend(FakeXMLHttpRequest.prototype, sinon.EventTarget, {
                          async: true,
              Severity: Major
              Found in resources/lib/sinonjs/sinon.js - About 1 day to fix

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

                    public function execute( $par ) {
                        $this->setHeaders();
                        $this->outputHeader();
                        $config = $this->getConfig();
                
                
                Severity: Major
                Found in includes/specials/SpecialExport.php - About 1 day to fix

                  MediaWikiEntryPoint has 63 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  abstract class MediaWikiEntryPoint {
                      use ProtectedHookAccessorTrait;
                  
                      private IContextSource $context;
                      private Config $config;
                  Severity: Major
                  Found in includes/MediaWikiEntryPoint.php - About 1 day to fix

                    File intersection-observer.js has 548 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    /**
                     * Copyright 2016 Google Inc. All Rights Reserved.
                     *
                     * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.
                     *
                    Severity: Major
                    Found in resources/lib/intersection-observer/intersection-observer.js - About 1 day to fix

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

                          mw.widgets.MediaUserUploadsQueue.prototype.setup = function () {
                              return this.getFileRepos().then( ( sources ) => {
                                  if ( this.providers.length === 0 ) {
                                      // Set up the providers
                                      for ( let i = 0, len = sources.length; i < len; i++ ) {
                      resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchQueue.js on lines 37..59

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

                      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

                          mw.widgets.MediaSearchQueue.prototype.setup = function () {
                              return this.getFileRepos().then( ( sources ) => {
                                  if ( this.providers.length === 0 ) {
                                      // Set up the providers
                                      for ( let i = 0, len = sources.length; i < len; i++ ) {
                      resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaUserUploadsQueue.js on lines 41..63

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

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

                        setup(props, { slots, emit }) {
                          const rootElement = ref();
                          const tabListElement = ref();
                          const prevScroller = ref();
                          const nextScroller = 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 doGuessMimeType has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function doGuessMimeType( string $file ) {
                              // Read a chunk of the file
                              AtEase::suppressWarnings();
                              $f = fopen( $file, 'rb' );
                              AtEase::restoreWarnings();
                      Severity: Minor
                      Found in includes/libs/mime/MimeAnalyzer.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 extractDeprecatedContent has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function extractDeprecatedContent( Content $content, RevisionRecord $revision ) {
                              $vals = [];
                              $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
                      
                              if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) {
                      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

                      Severity
                      Category
                      Status
                      Source
                      Language