wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

File MessagesSr_el.php has 393 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/** Serbian (Latin script) (srpski (latinica))
 *
 * @file
 * @ingroup Languages
Severity: Minor
Found in languages/messages/MessagesSr_el.php - About 5 hrs to fix

    File MessagesZh_hans.php has 393 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /** Simplified Chinese (中文(简体))
     *
     * @file
     * @ingroup Languages
    Severity: Minor
    Found in languages/messages/MessagesZh_hans.php - About 5 hrs to fix

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

      $namespaceAliases = [
          'Xısusi'               => NS_SPECIAL,
          'Werênayış'            => NS_TALK,
          'Mesac'                => NS_TALK,
          'Karber_werênayış'     => NS_USER_TALK,
      Severity: Major
      Found in languages/messages/MessagesDiq.php and 4 other locations - About 5 hrs to fix
      includes/Html/Html.php on lines 254..280
      languages/messages/MessagesAs.php on lines 27..51
      languages/messages/MessagesFf.php on lines 12..37
      languages/messages/MessagesMhr.php on lines 35..62

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

      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 5 locations. Consider refactoring.
      Open

      $namespaceAliases = [
          // Fallbacks for all 'ru' namespace aliases
          'Медиа'                              => NS_MEDIA,
          'Служебная'                          => NS_SPECIAL,
          'Обсуждение'                         => NS_TALK,
      Severity: Major
      Found in languages/messages/MessagesMhr.php and 4 other locations - About 5 hrs to fix
      includes/Html/Html.php on lines 254..280
      languages/messages/MessagesAs.php on lines 27..51
      languages/messages/MessagesDiq.php on lines 27..51
      languages/messages/MessagesFf.php on lines 12..37

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

      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 5 locations. Consider refactoring.
      Open

                  $validTypes = [
                      'hidden' => true,
                      'text' => true,
                      'password' => true,
                      'checkbox' => true,
      Severity: Major
      Found in includes/Html/Html.php and 4 other locations - About 5 hrs to fix
      languages/messages/MessagesAs.php on lines 27..51
      languages/messages/MessagesDiq.php on lines 27..51
      languages/messages/MessagesFf.php on lines 12..37
      languages/messages/MessagesMhr.php on lines 35..62

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

      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 5 locations. Consider refactoring.
      Open

      $namespaceAliases = [
          'Média'                  => NS_MEDIA,
          'Spécial'                => NS_SPECIAL,
          'Discussion'             => NS_TALK,
          'Utilisateur'            => NS_USER,
      Severity: Major
      Found in languages/messages/MessagesFf.php and 4 other locations - About 5 hrs to fix
      includes/Html/Html.php on lines 254..280
      languages/messages/MessagesAs.php on lines 27..51
      languages/messages/MessagesDiq.php on lines 27..51
      languages/messages/MessagesMhr.php on lines 35..62

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

      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 5 locations. Consider refactoring.
      Open

      $namespaceAliases = [
          'विशेष' => NS_SPECIAL,
          'वार्ता' => NS_TALK,
          'বার্তা' => NS_TALK,
          'सदस्य' => NS_USER,
      Severity: Major
      Found in languages/messages/MessagesAs.php and 4 other locations - About 5 hrs to fix
      includes/Html/Html.php on lines 254..280
      languages/messages/MessagesDiq.php on lines 27..51
      languages/messages/MessagesFf.php on lines 12..37
      languages/messages/MessagesMhr.php on lines 35..62

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

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

          protected function extractResourceLoaderModules( $dir, array $info ) {
              $defaultPaths = $info['ResourceFileModulePaths'] ?? false;
              if ( isset( $defaultPaths['localBasePath'] ) ) {
                  if ( $defaultPaths['localBasePath'] === '' ) {
                      // Avoid double slashes (e.g. /extensions/Example//path)
      Severity: Minor
      Found in includes/registration/ExtensionProcessor.php - About 5 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 fetchBlobs has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          private function fetchBlobs( $blobAddresses, $queryFlags ) {
              $textIdToBlobAddress = [];
              $result = [];
              $errors = [];
              foreach ( $blobAddresses as $blobAddress ) {
      Severity: Minor
      Found in includes/Storage/SqlBlobStore.php - About 5 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 consistencyCheck has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          public function consistencyCheck( array $paths ) {
              $status = $this->newStatus();
              if ( $this->syncChecks == 0 || count( $this->backends ) <= 1 ) {
                  return $status; // skip checks
              }
      Severity: Minor
      Found in includes/libs/filebackend/FileBackendMultiWrite.php - About 5 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 trySubmit has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          public function trySubmit() {
              $valid = true;
              $hoistedErrors = Status::newGood();
              if ( $this->mValidationErrorMessage ) {
                  foreach ( $this->mValidationErrorMessage as $error ) {
      Severity: Minor
      Found in includes/htmlform/HTMLForm.php - About 5 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 36 (exceeds 5 allowed). Consider refactoring.
      Open

          public function execute() {
              $this->prepare();
      
              if ( !$this->status->isOK() ) {
                  return Status::wrap( $this->status ); // TODO B/C; move this to callers
      Severity: Minor
      Found in includes/http/GuzzleHttpRequest.php - About 5 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 autoConvert has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          public function autoConvert( $text, $toVariant = false ) {
              $this->loadTables();
      
              if ( !$toVariant ) {
                  $toVariant = $this->getPreferredVariant();
      Severity: Minor
      Found in includes/language/LanguageConverter.php - About 5 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 initLanguage has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          private function initLanguage( $code ) {
              if ( isset( $this->initialisedLangs[$code] ) ) {
                  return;
              }
      
      
      Severity: Minor
      Found in includes/language/LocalisationCache.php - About 5 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 getCommentInternal has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          private function getCommentInternal( ?IReadableDatabase $db, $key, $row, $fallback = false ) {
              $row = (array)$row;
              if ( array_key_exists( "{$key}_text", $row ) && array_key_exists( "{$key}_data", $row ) ) {
                  $cid = $row["{$key}_cid"] ?? null;
                  $text = $row["{$key}_text"];
      Severity: Minor
      Found in includes/CommentStore/CommentStore.php - About 5 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 36 (exceeds 5 allowed). Consider refactoring.
      Open

          public function execute( array $session ) {
              $this->session = $session;
      
              if ( isset( $session['settings'] ) ) {
                  $this->settings = $session['settings'] + $this->settings;
      Severity: Minor
      Found in includes/installer/WebInstaller.php - About 5 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 initFromQueryResult has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          private function initFromQueryResult( $res, &$remaining = null, $processTitles = null ) {
              if ( $remaining !== null && $processTitles === null ) {
                  ApiBase::dieDebug( __METHOD__, 'Missing $processTitles parameter when $remaining is provided' );
              }
      
      
      Severity: Minor
      Found in includes/api/ApiPageSet.php - About 5 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 36 (exceeds 5 allowed). Consider refactoring.
      Open

          public function execute( $par ) {
              $config = $this->getConfig();
              $credits = self::getCredits( ExtensionRegistry::getInstance(), $config );
      
              $this->setHeaders();
      Severity: Minor
      Found in includes/specials/SpecialVersion.php - About 5 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 toString has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          public function toString() {
              $paramString = '';
              if ( $this->params ) {
                  foreach ( $this->params as $key => $value ) {
                      if ( $paramString != '' ) {
      Severity: Minor
      Found in includes/jobqueue/Job.php - About 5 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 validateAttributes has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function validateAttributes( array $attribs, array $allowed ): array {
              if ( isset( $allowed[0] ) ) {
                  // Calling this function with a sequential array is
                  // deprecated.  For now just convert it.
                  wfDeprecated( __METHOD__ . ' with sequential array', '1.35' );
      Severity: Minor
      Found in includes/parser/Sanitizer.php - About 5 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