wikimedia/mediawiki-extensions-Translate

View on GitHub
src/Synchronization/ExternalMessageSourceStateComparator.php

Summary

Maintainability
D
2 days
Test Coverage

Function addMessageUpdateChanges has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    protected function addMessageUpdateChanges(
        FileBasedMessageGroup $group,
        string $language,
        MessageSourceChange $changes,
        int $reason,
Severity: Minor
Found in src/Synchronization/ExternalMessageSourceStateComparator.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

File ExternalMessageSourceStateComparator.php has 300 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare( strict_types = 1 );

namespace MediaWiki\Extension\Translate\Synchronization;

Severity: Minor
Found in src/Synchronization/ExternalMessageSourceStateComparator.php - About 3 hrs to fix

    Method addMessageUpdateChanges has 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function addMessageUpdateChanges(
            FileBasedMessageGroup $group,
            string $language,
            MessageSourceChange $changes,
            int $reason,
    Severity: Major
    Found in src/Synchronization/ExternalMessageSourceStateComparator.php - About 3 hrs to fix

      Method checkNonSourceAdditionsForRename has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function checkNonSourceAdditionsForRename(
              MessageSourceChange $changes,
              string $sourceLanguage,
              string $targetLanguage,
              MessageCollection $wiki,
      Severity: Minor
      Found in src/Synchronization/ExternalMessageSourceStateComparator.php - About 1 hr to fix

        Function checkNonSourceAdditionsForRename has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            private function checkNonSourceAdditionsForRename(
                MessageSourceChange $changes,
                string $sourceLanguage,
                string $targetLanguage,
                MessageCollection $wiki,
        Severity: Minor
        Found in src/Synchronization/ExternalMessageSourceStateComparator.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

        Method hasCacheEntry has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function hasCacheEntry(
                MessageGroupCache $cache,
                MessageCollection $collection,
                string $messageKey
            ): bool {
        Severity: Minor
        Found in src/Synchronization/ExternalMessageSourceStateComparator.php - About 1 hr to fix

          Method addNonSourceRenames has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  MessageSourceChange $changes,
                  string $key,
                  string $renameKey,
                  string $sourceContent,
                  string $wikiContent,
          Severity: Minor
          Found in src/Synchronization/ExternalMessageSourceStateComparator.php - About 45 mins to fix

            Function findAndMarkSourceRenames has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                private function findAndMarkSourceRenames( MessageSourceChange $changes, string $sourceLanguage ): void {
                    // Now check for renames. To identify renames we need to compare
                    // the contents of the added messages with the deleted ones and
                    // identify messages that match.
                    $deletions = $changes->getDeletions( $sourceLanguage );
            Severity: Minor
            Found in src/Synchronization/ExternalMessageSourceStateComparator.php - About 45 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

            Method checkNonSourceAdditionsForRename has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    MessageSourceChange $changes,
                    string $sourceLanguage,
                    string $targetLanguage,
                    MessageCollection $wiki,
                    array $wikiKeys
            Severity: Minor
            Found in src/Synchronization/ExternalMessageSourceStateComparator.php - About 35 mins to fix

              Method addMessageUpdateChanges has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      FileBasedMessageGroup $group,
                      string $language,
                      MessageSourceChange $changes,
                      int $reason,
                      MessageGroupCache $cache
              Severity: Minor
              Found in src/Synchronization/ExternalMessageSourceStateComparator.php - About 35 mins to fix

                There are no issues that match your filters.

                Category
                Status