wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Method modifyHelp has 107 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function modifyHelp( array &$help, array $options, array &$tocData ) {
        // Wish PHP had an "array_insert_before". Instead, we have to manually
        // reindex the array to get 'permissions' in the right place.
        $oldHelp = $help;
        $help = [];
Severity: Major
Found in includes/api/ApiMain.php - About 4 hrs to fix

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

        public function execute() {
            $services = $this->getServiceContainer();
            $permissionManager = $services->getPermissionManager();
    
            $request = $this->getRequest();
    Severity: Major
    Found in includes/filerepo/AuthenticatedFileEntryPoint.php - About 4 hrs to fix

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

      <?php
      /** Atayal (Tayal)
       *
       * @file
       * @ingroup Languages
      Severity: Major
      Found in languages/messages/MessagesTay.php and 2 other locations - About 4 hrs to fix
      languages/messages/MessagesAtj.php on lines 1..32
      languages/messages/MessagesKab.php on lines 1..32

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

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

      <?php
      /** Atikamekw
       *
       * @file
       * @ingroup Languages
      Severity: Major
      Found in languages/messages/MessagesAtj.php and 2 other locations - About 4 hrs to fix
      languages/messages/MessagesKab.php on lines 1..32
      languages/messages/MessagesTay.php on lines 1..32

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

      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 ( !$method || $method === 'internalRemoveHtmlTags' ) {
                  $tiny = strlen( $textWithNoHtml );
                  $sm = strlen( $textWithHtmlSm );
                  $lg = round( strlen( $textWithHtmlLg ) / 1000 ) . 'K';
                  $benches["Sanitizer::internalRemoveHtmlTags (input: $tiny)"] = static function () use ( $textWithNoHtml ) {
      Severity: Major
      Found in maintenance/benchmarks/benchmarkSanitizer.php and 1 other location - About 4 hrs to fix
      maintenance/benchmarks/benchmarkSanitizer.php on lines 116..129

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

      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 ( !$method || $method === 'removeSomeTags' ) {
                  $tiny = strlen( $textWithNoHtml );
                  $sm = strlen( $textWithHtmlSm );
                  $lg = round( strlen( $textWithHtmlLg ) / 1000 ) . 'K';
                  $benches["Sanitizer::removeSomeTags (input: $tiny)"] = static function () use ( $textWithNoHtml ) {
      Severity: Major
      Found in maintenance/benchmarks/benchmarkSanitizer.php and 1 other location - About 4 hrs to fix
      maintenance/benchmarks/benchmarkSanitizer.php on lines 80..93

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

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

      <?php
      /** Kabyle (Taqbaylit)
       *
       * @file
       * @ingroup Languages
      Severity: Major
      Found in languages/messages/MessagesKab.php and 2 other locations - About 4 hrs to fix
      languages/messages/MessagesAtj.php on lines 1..32
      languages/messages/MessagesTay.php on lines 1..32

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

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

      <?php
      /**
       * Class for blocks stored in the database.
       *
       * This program is free software; you can redistribute it and/or modify
      Severity: Minor
      Found in includes/block/DatabaseBlock.php - About 4 hrs to fix

        File DjVuImage.php has 344 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * DjVu image handler.
         *
         * Copyright © 2006 Brooke Vibber <bvibber@wikimedia.org>
        Severity: Minor
        Found in includes/media/DjVuImage.php - About 4 hrs to fix

          File MessagesKo.php has 344 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /** Korean (한국어)
           *
           * @file
           * @ingroup Languages
          Severity: Minor
          Found in languages/messages/MessagesKo.php - About 4 hrs to fix

            Function getOldIDFromRequest has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getOldIDFromRequest() {
                    $this->mRedirectUrl = false;
            
                    $request = $this->getContext()->getRequest();
                    $oldid = $request->getIntOrNull( 'oldid' );
            Severity: Minor
            Found in includes/page/Article.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 undeleteRevisions has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                private function undeleteRevisions( ProperPageIdentity $page, array $timestamps, string $comment ): StatusValue {
                    if ( $this->readOnlyMode->isReadOnly() ) {
                        throw new ReadOnlyError();
                    }
            
            
            Severity: Minor
            Found in includes/page/UndeletePage.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 getData has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                private function getData(): array {
                    if ( $this->data ) {
                        return $this->data;
                    }
            
            
            Severity: Minor
            Found in includes/ResourceLoader/ClientHtml.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 29 (exceeds 5 allowed). Consider refactoring.
            Open

                public function __construct(
                    array $options = [],
                    string $localBasePath = null,
                    string $remoteBasePath = null
                ) {
            Severity: Minor
            Found in includes/ResourceLoader/FileModule.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 import has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                public function import( ImportableOldRevision $importableRevision, $doUpdates = true ) {
                    $dbw = $this->dbProvider->getPrimaryDatabase();
            
                    # Sneak a single revision into place
                    $user = $importableRevision->getUserObj() ?: $this->userFactory->newFromName( $importableRevision->getUser() );
            Severity: Minor
            Found in includes/import/ImportableOldRevisionImporter.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 format has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                public function format( $diff ) {
                    $xi = $yi = 1;
                    $block = false;
                    $context = [];
            
            
            Severity: Minor
            Found in includes/libs/Diff/DiffFormatter.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 fetchKeys has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function fetchKeys( array $keys, array $checkKeys, float $now, $touchedCb = null ) {
                    $resByKey = [];
            
                    // List of all sister keys that need to be fetched from cache
                    $allSisterKeys = [];
            Severity: Minor
            Found in includes/libs/objectcache/WANObjectCache.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 getSidebar has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function getSidebar( $options = [] ) {
                    // Force the rendering of the following portals
                    $sidebar = $this->data['sidebar'];
                    if ( !isset( $sidebar['SEARCH'] ) ) {
                        // @phan-suppress-next-line PhanTypeMismatchDimAssignment False positive
            Severity: Minor
            Found in includes/skins/BaseTemplate.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 onSubmit has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                public function onSubmit( $data ) {
                    if ( !$this->getRequest()->getCheck( 'wpSave' ) ) {
                        // Diff or preview
                        return false;
                    }
            Severity: Minor
            Found in includes/actions/McrUndoAction.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 generateConvTable has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                private function generateConvTable() {
                    // Special case optimisation
                    if ( !$this->mBidtable && !$this->mUnidtable ) {
                        $this->mConvTable = [];
                        return;
            Severity: Minor
            Found in includes/language/ConverterRule.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