wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

Function validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate( $value, $alldata ) {
        $p = parent::validate( $value, $alldata );

        if ( $p !== true ) {
            return $p;
Severity: Minor
Found in src/Utilities/HTMLJsSelectToInputField.php - About 25 mins 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 runInParallel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function runInParallel( callable $mainThread, callable $forkThread ): void {
        // Fork to increase speed with parallelism. Also helps with memory usage if there are leaks.
        $pid = -1;
        if ( function_exists( 'pcntl_fork' ) ) {
            $pid = pcntl_fork();
Severity: Minor
Found in src/Utilities/ParallelExecutor.php - About 25 mins 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 forAll has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function forAll( string ...$prefixedMessagesKeys ): array {
        $languages = MessageGroupStats::getLanguages();
        $stats = [];

        if ( !$prefixedMessagesKeys ) {
Severity: Minor
Found in src/Statistics/MessagePrefixStats.php - About 25 mins 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 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $services = MediaWikiServices::getInstance();
        $db = $services->getDBLoadBalancer()->getConnection( DB_PRIMARY );

        $dbGroupIds = $db->newSelectQueryBuilder()
Severity: Minor
Found in src/Statistics/CleanupTranslationProgressStatsMaintenanceScript.php - About 25 mins 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 getMessageParameters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getMessageParameters(): array {
        $params = parent::getMessageParameters();
        $legacy = $this->entry->getParameters();

        $type = $this->entry->getFullType();
Severity: Minor
Found in src/MessageGroupProcessing/TranslatableBundleLogFormatter.php - About 25 mins 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 getContents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getContents( $titles, int $namespace ): array {
        $mwServices = MediaWikiServices::getInstance();
        $dbr = $mwServices->getConnectionProvider()->getReplicaDatabase();
        $revStore = $mwServices->getRevisionStore();
        $titleContents = [];
Severity: Minor
Found in src/Utilities/Utilities.php - About 25 mins 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 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute(): void {
        if ( !$this->groupSubscription->isEnabled() ) {
            $this->dieWithError( 'apierror-translate-messagegroupsubscription-disabled' );
        }

Severity: Minor
Found in src/MessageGroupProcessing/MessageGroupSubscriptionActionApi.php - About 25 mins 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 removeFromAggregateGroups has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function removeFromAggregateGroups( string $groupId ): void {
        // remove the page from aggregate groups, if present in any of them.
        $aggregateGroups = MessageGroups::getGroupsByType( AggregateMessageGroup::class );
        $this->messageGroupMetadata->preloadGroups( array_keys( $aggregateGroups ), __METHOD__ );
        foreach ( $aggregateGroups as $group ) {
Severity: Minor
Found in src/MessageGroupProcessing/TranslatablePageStore.php - About 25 mins 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 getTranslationUnitPagesByTitle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getTranslationUnitPagesByTitle( PageReference $title, ?string $code = null ): array {
        $mwServices = MediaWikiServices::getInstance();

        $dbw = $mwServices->getDBLoadBalancer()->getConnection( DB_PRIMARY );
        $base = $mwServices->getTitleFormatter()->getPrefixedDBkey( $title );
Severity: Minor
Found in src/MessageGroupProcessing/TranslatableBundle.php - About 25 mins 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 getMessageContent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getMessageContent( MessageHandle $handle ) {
        $groupId = Services::getInstance()->getMessageIndex()->getPrimaryGroupId( $handle );
        if ( $groupId === null ) {
            return null;
        }
Severity: Minor
Found in messagegroups/SandboxMessageGroup.php - About 25 mins 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 getBodyMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getBodyMessage() {
        $type = $this->event->getType();
        if ( $type === 'translate-mgs-message-added' ) {
            if ( $this->isBundled() ) {
                $events = $this->getBundledEvents();
Severity: Minor
Found in src/MessageGroupProcessing/MessageGroupSubscriptionPresentationModel.php - About 25 mins 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 getIssues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getIssues( Message $message, string $targetLanguage ): ValidationIssues {
        $issues = new ValidationIssues();

        // We skip certain validations if we don't know the expected keywords
        $expectedKeywords = UnicodePlural::getPluralKeywords( $targetLanguage );
Severity: Minor
Found in src/Validation/Validators/UnicodePluralValidator.php - About 25 mins 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 getInsertablesSuggester has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getInsertablesSuggester() {
        $suggesters = [];
        $insertableConf = $this->getFromConf( 'INSERTABLES' ) ?? [];

        foreach ( $insertableConf as $config ) {
Severity: Minor
Found in messagegroups/MessageGroupBase.php - About 25 mins 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 getIssues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getIssues( Message $message, string $targetLanguage ): ValidationIssues {
        $issues = new ValidationIssues();

        $pluralRule = GettextPlural::getPluralRule( $targetLanguage );
        // Skip validation for languages for which we do not know the plural rule
Severity: Minor
Found in src/Validation/Validators/GettextPluralValidator.php - About 25 mins 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 getMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getMessage( $key, $code, $flags = IDBAccessObject::READ_LATEST ) {
        if ( $this->isSourceLanguage( $code ) ) {
            $stuff = $this->load( $code );

            $title = Title::newFromText( $key );
Severity: Minor
Found in messagegroups/WikiPageMessageGroup.php - About 25 mins 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 processGettextPluralMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function processGettextPluralMessage( ?int $pluralCount, string $section ): string {
        $actualForms = [];

        for ( $i = 0; $i < $pluralCount; $i++ ) {
            $match = $this->expectKeyword( "msgstr\\[$i\\]", $section );
Severity: Minor
Found in src/FileFormatSupport/GettextFormat.php - About 25 mins 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 doGettextHeader has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function doGettextHeader( MessageCollection $collection, array $template ): string {
        global $wgSitename;

        $code = $collection->code;
        $name = Utilities::getLanguageName( $code );
Severity: Minor
Found in src/FileFormatSupport/GettextFormat.php - About 25 mins 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 isContentEqual has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function isContentEqual( ?string $a, ?string $b ): bool {
        if ( $a === $b ) {
            return true;
        }

Severity: Minor
Found in src/FileFormatSupport/GettextFormat.php - About 25 mins 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