wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

    public function toHtml( $options = [] ) {
        $services = MediaWikiServices::getInstance();
        $mainConfig = $services->getMainConfig();
        $nativeImageLazyLoading = $mainConfig->get( MainConfigNames::NativeImageLazyLoading );
        $enableLegacyMediaDOM = $mainConfig->get( MainConfigNames::ParserEnableLegacyMediaDOM );
Severity: Minor
Found in includes/media/ThumbnailImage.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 flattenArrayReal has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public function flattenArrayReal( $vals, $type = 'ul', $noHtml = false ) {
        if ( !is_array( $vals ) ) {
            return $vals; // do nothing if not an array;
        }

Severity: Minor
Found in includes/media/FormatMetadata.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 29 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $db = $this->getDB();
        $params = $this->extractRequestParams();
        $this->requireMaxOneParameter( $params, 'group', 'excludegroup', 'rights', 'excluderights' );

Severity: Minor
Found in includes/api/ApiQueryContributors.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 29 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $authority = $this->getAuthority();

        // Fail early if the user is sitewide blocked.
        $block = $authority->getBlock();
Severity: Minor
Found in includes/api/ApiPurge.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 formatValue has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public function formatValue( $field, $value ) {
        /** @var stdClass $row */
        $row = $this->mCurrentRow;
        $linkRenderer = $this->getLinkRenderer();

Severity: Minor
Found in includes/specials/pagers/ProtectedPagesPager.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 makeNamespaceRow has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    private function makeNamespaceRow( int $ns, string $localName ): string {
        $canonicalName = $this->namespaceInfo->getCanonicalName( $ns );
        if ( $canonicalName ) {
            $canonicalName = strtr( $canonicalName, '_', ' ' );
        } else {
Severity: Minor
Found in includes/specials/SpecialNamespaceInfo.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 addParserOutputMetadata has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public function addParserOutputMetadata( ParserOutput $parserOutput ) {
        // T301020 This should eventually use the standard "merge ParserOutput"
        // function between $parserOutput and $this->metadata.
        $this->addLanguageLinks( $parserOutput->getLanguageLinks() );
        $this->addCategoryLinks( $parserOutput->getCategoryMap() );
Severity: Minor
Found in includes/Output/OutputPage.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 callParserFunction has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public function callParserFunction( PPFrame $frame, $function, array $args = [] ) {
        # Case sensitive functions
        if ( isset( $this->mFunctionSynonyms[1][$function] ) ) {
            $function = $this->mFunctionSynonyms[1][$function];
        } else {
Severity: Minor
Found in includes/parser/Parser.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 acceptable has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    protected function acceptable( array &$attribs ): bool {
        $request = $this->getRequest();
        $format = $attribs['opts']['format'];

        if ( $format === ParsoidFormatHelper::FORMAT_WIKITEXT ) {
Severity: Minor
Found in includes/Rest/Handler/ParsoidHandler.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 parseQuery has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseQuery( $filteredText, $fulltext ) {
        $lc = $this->legalSearchChars( self::CHARS_NO_SYNTAX ); // Minus syntax chars (" and *)
        $searchon = '';
        $this->searchTerms = [];

Severity: Minor
Found in includes/search/SearchSqlite.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 processOptions has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processOptions() {
        $sink = null;
        $sinks = [];

        $this->schemaVersion = WikiExporter::schemaVersion();
Severity: Minor
Found in maintenance/includes/BackupDumper.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 29 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $repo = $this->getServiceContainer()->getRepoGroup()->getLocalRepo();
        $tempRepo = $repo->getTempRepo();

        $dbr = $repo->getReplicaDB();
Severity: Minor
Found in maintenance/cleanupUploadStash.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 cleanupTable has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    protected function cleanupTable( $tableParams ) {
        [ $table, $prefix ] = $tableParams;
        $idField = $tableParams['idField'] ?? "{$prefix}_id";
        $nsField = $tableParams['nsField'] ?? "{$prefix}_namespace";
        $titleField = $tableParams['titleField'] ?? "{$prefix}_title";
Severity: Minor
Found in maintenance/cleanupInvalidDbKeys.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

Method execute has 106 lines of code (exceeds 25 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: Major
Found in includes/http/GuzzleHttpRequest.php - About 4 hrs to fix

    Method replaceInternal has 106 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function replaceInternal( &$text ) {
            if ( !$this->internals ) {
                return;
            }
    
    
    Severity: Major
    Found in includes/parser/LinkHolderArray.php - About 4 hrs to fix

      File CodexModule.php has 343 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: Minor
      Found in includes/ResourceLoader/CodexModule.php - About 4 hrs to fix

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

            private const TO_LATIN = [
                'ⴰ' => 'a',
                'ⴱ' => 'b',
                'ⴳ' => 'g',
                'ⴷ' => 'd',
        Severity: Major
        Found in includes/language/converters/ShiConverter.php and 1 other location - About 4 hrs to fix
        includes/language/converters/ZghConverter.php on lines 40..73

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

        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
        /** Interslavic (Cyrillic script) (меджусловјанскы)
         *
         * @file
         * @ingroup Languages
        Severity: Major
        Found in languages/messages/MessagesIsv_cyrl.php and 1 other location - About 4 hrs to fix
        languages/messages/MessagesIsv_latn.php on lines 1..30

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

        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

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

            private const TO_LATIN = [
                'ⴰ' => 'a',
                'ⴱ' => 'b',
                'ⴳ' => 'g',
                'ⴷ' => 'd',
        Severity: Major
        Found in includes/language/converters/ZghConverter.php and 1 other location - About 4 hrs to fix
        includes/language/converters/ShiConverter.php on lines 42..75

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

        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
        /** Interslavic (Latin script) (medžuslovjansky)
         *
         * @file
         * @ingroup Languages
        Severity: Major
        Found in languages/messages/MessagesIsv_latn.php and 1 other location - About 4 hrs to fix
        languages/messages/MessagesIsv_cyrl.php on lines 1..30

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

        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

        Severity
        Category
        Status
        Source
        Language