wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

Function execute has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $groups = MessageGroups::singleton()->getGroups();
        $mwInstance = MediaWikiServices::getInstance();
        $jobQueueGroup = $mwInstance->getJobQueueGroup();

Severity: Minor
Found in scripts/refresh-translatable-pages.php - About 1 hr 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 listPages has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function listPages(): void {
        $out = $this->getOutput();

        $res = self::loadPagesFromDB();
        $allPages = self::buildPageArray( $res );
Severity: Minor
Found in src/PageTranslation/PageTranslationSpecialPage.php - About 1 hr 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 getServers has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function getServers(
        bool $isDryRun,
        bool $shouldReindex,
        ?string $ttmServerId = null
    ): array {
Severity: Minor
Found in scripts/ttmserver-export.php - About 1 hr 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 prepareTranslationUnits has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function prepareTranslationUnits( TranslatablePage $page, ParserOutput $parserOutput ): array {
        $highest = (int)$this->messageGroupMetadata->get( $page->getMessageGroupId(), 'maxid' );

        $store = $this->translationUnitStoreFactory->getReader( $page->getPageIdentity() );
        $storedUnits = $store->getUnits();
Severity: Minor
Found in src/PageTranslation/TranslatablePageMarker.php - About 1 hr 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 rebuild has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function rebuild( float $timestamp = null ): array {
        static $recursion = 0;

        if ( $recursion > 0 ) {
            $msg = __METHOD__ . ': trying to recurse - building the index first time?';
Severity: Minor
Found in src/MessageLoading/MessageIndex.php - About 1 hr 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 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute( $par ) {
        $request = $this->getRequest();
        $user = $this->getUser();
        $this->addHelpLink( 'Help:Extension:Translate/Move_translatable_page' );
        $out = $this->getOutput();
Severity: Minor
Found in src/PageTranslation/MoveTranslatableBundleSpecialPage.php - About 1 hr 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 applyFilter has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function applyFilter( string $filter, bool $condition, ?int $value ): void {
        $keys = $this->keys;
        if ( $filter === 'fuzzy' ) {
            $keys = $this->filterFuzzy( $keys, $condition );
        } elseif ( $filter === 'hastranslation' ) {
Severity: Minor
Found in src/MessageLoading/MessageCollection.php - About 1 hr 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 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute( $par ) {
        $this->addHelpLink( 'Help:Deletion_and_undeletion' );

        $request = $this->getRequest();

Severity: Minor
Found in src/PageTranslation/DeleteTranslatableBundleSpecialPage.php - About 1 hr 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 getNames has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function getNames(): array {
        $ttmServersIds = [];
        foreach ( $this->configs as $serviceId => $config ) {
            $type = $config['type'] ?? '';
            if ( $type === 'ttmserver' || $type === 'remote-ttmserver' ) {
Severity: Minor
Found in src/TtmServer/TtmServerFactory.php - About 1 hr 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 getHopefullyValidConfigurations has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function getHopefullyValidConfigurations( string $data, ?callable $callback = null ): array {
        if ( !is_callable( $callback ) ) {
            $callback = static function ( $unused1, $unused2, $unused3 ) {
                /*noop*/
            };
Severity: Minor
Found in src/MessageGroupConfiguration/MessageGroupConfigurationParser.php - About 1 hr 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 flattenCLDRPlurals has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function flattenCLDRPlurals( array $messages ) {
        $hasNonPluralKeys = false;
        $pluralKeys = [];
        foreach ( $messages as $key => $value ) {
            if ( is_array( $value ) ) {
Severity: Minor
Found in src/MessageProcessing/ArrayFlattener.php - About 1 hr 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

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

        $( '.tp-aggregate-edit-ag-button' ).on( 'click', function ( event ) {
            var $parent = $( event.target ).closest( '.mw-tpa-group' );

            $parent.children( '.tp-display-group' ).addClass( 'hidden' );
            $parent.children( '.tp-edit-group' ).removeClass( 'hidden' );
Severity: Major
Found in resources/js/ext.translate.special.aggregategroups.js and 1 other location - About 1 hr to fix
resources/js/ext.translate.special.aggregategroups.js on lines 376..380

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

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

                $editSpan.on( 'click', function ( event ) {
                    var $parent = $( event.target ).closest( '.mw-tpa-group' );
                    $parent.children( '.tp-display-group' ).addClass( 'hidden' );
                    $parent.children( '.tp-edit-group' ).removeClass( 'hidden' );
                } );
Severity: Major
Found in resources/js/ext.translate.special.aggregategroups.js and 1 other location - About 1 hr to fix
resources/js/ext.translate.special.aggregategroups.js on lines 259..264

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

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

    $.fn.translatorSearch = function () {
        return this.each( function () {
            if ( !$.data( this, 'TranslatorSearch' ) ) {
                $.data( this, 'TranslatorSearch', new TranslatorSearch( this ) );
            }
resources/js/ext.translate.special.managetranslatorsandbox.js on lines 651..657

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

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

                        if (isNaN(value.min) || isNaN(value.max) || meta.data[i].hidden || value.min < 0 || value.max < 0) {
                            continue;
                        }
Severity: Major
Found in resources/lib/Chart.js/Chart.js and 1 other location - About 1 hr to fix
resources/lib/Chart.js/Chart.js on lines 13179..13181

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

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

    $.fn.languageFilter = function () {
        return this.each( function () {
            if ( !$.data( this, 'LanguageFilter' ) ) {
                $.data( this, 'LanguageFilter', new LanguageFilter( this ) );
            }
resources/js/ext.translate.special.managetranslatorsandbox.js on lines 721..727

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

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

    protected function loadMessagesFromCache( $groups ) {
        $messages = [];
        foreach ( $groups as $group ) {
            if ( $group instanceof self ) {
                $messages += $this->loadMessagesFromCache( $group->getGroups() );
Severity: Minor
Found in messagegroups/AggregateMessageGroup.php - About 1 hr 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

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

                        if (isNaN(value.min) || isNaN(value.max) || meta.data[i].hidden || value.min < 0 || value.max < 0) {
                            continue;
                        }
Severity: Major
Found in resources/lib/Chart.js/Chart.js and 1 other location - About 1 hr to fix
resources/lib/Chart.js/Chart.js on lines 13205..13207

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

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

    protected function doesKeyMatch( string $key, array $keyMatches ): bool {
        $normalizedKey = lcfirst( $key );
        foreach ( $keyMatches as $match ) {
            if ( is_string( $match ) ) {
                if ( lcfirst( $match ) === $normalizedKey ) {
Severity: Minor
Found in src/Validation/ValidationRunner.php - About 1 hr 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 getTooltipSize has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getTooltipSize(tooltip, model) {
    var ctx = tooltip._chart.ctx;

    var height = model.yPadding * 2; // Tooltip Padding
    var width = 0;
Severity: Minor
Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix
    Severity
    Category
    Status
    Source
    Language