wikimedia/mediawiki-extensions-Translate

View on GitHub
src/MessageSync/MessageSourceChange.php

Summary

Maintainability
D
1 day
Test Coverage

MessageSourceChange has 34 functions (exceeds 20 allowed). Consider refactoring.
Open

class MessageSourceChange {
    /**
     * @var array[][][]
     * @phpcs:ignore Generic.Files.LineLength
     * @phan-var array<string,array<string,array<string|int,array{key:string,content:string,similarity?:float,matched_to?:string,previous_state?:string}>>>
Severity: Minor
Found in src/MessageSync/MessageSourceChange.php - About 4 hrs to fix

    File MessageSourceChange.php has 282 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Contains a class to track changes to the messages when importing messages from remote source.
     * @author Abijeet Patro
     * @license GPL-2.0-or-later
    Severity: Minor
    Found in src/MessageSync/MessageSourceChange.php - About 2 hrs to fix

      Function findMessage has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function findMessage( $language, $key, $possibleStates = [], &$modificationType = null ) {
              $allChanges = [];
              $allChanges[self::ADDITION] = $this->getAdditions( $language );
              $allChanges[self::DELETION] = $this->getDeletions( $language );
              $allChanges[self::CHANGE] = $this->getChanges( $language );
      Severity: Minor
      Found in src/MessageSync/MessageSourceChange.php - About 2 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 breakRename has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function breakRename( $languageCode, $msgKey ) {
              $msg = $this->findMessage( $languageCode, $msgKey, [ self::RENAME ] );
              if ( $msg === null ) {
                  return null;
              }
      Severity: Minor
      Found in src/MessageSync/MessageSourceChange.php - About 1 hr to fix

        Method hasOnly has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function hasOnly( $language, $type ) {
                $deletions = $this->getDeletions( $language );
                $additions = $this->getAdditions( $language );
                $renames = $this->getRenames( $language );
                $changes = $this->getChanges( $language );
        Severity: Minor
        Found in src/MessageSync/MessageSourceChange.php - About 1 hr to fix

          Method findMessage has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function findMessage( $language, $key, $possibleStates = [], &$modificationType = null ) {
                  $allChanges = [];
                  $allChanges[self::ADDITION] = $this->getAdditions( $language );
                  $allChanges[self::DELETION] = $this->getDeletions( $language );
                  $allChanges[self::CHANGE] = $this->getChanges( $language );
          Severity: Minor
          Found in src/MessageSync/MessageSourceChange.php - About 1 hr to fix

            Function hasOnly has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function hasOnly( $language, $type ) {
                    $deletions = $this->getDeletions( $language );
                    $additions = $this->getAdditions( $language );
                    $renames = $this->getRenames( $language );
                    $changes = $this->getChanges( $language );
            Severity: Minor
            Found in src/MessageSync/MessageSourceChange.php - About 55 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 breakRename has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function breakRename( $languageCode, $msgKey ) {
                    $msg = $this->findMessage( $languageCode, $msgKey, [ self::RENAME ] );
                    if ( $msg === null ) {
                        return null;
                    }
            Severity: Minor
            Found in src/MessageSync/MessageSourceChange.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

            There are no issues that match your filters.

            Category
            Status