wikimedia/mediawiki-extensions-Translate

View on GitHub
src/PageTranslation/TranslatablePageMarker.php

Summary

Maintainability
D
2 days
Test Coverage

File TranslatablePageMarker.php has 408 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare( strict_types = 1 );

namespace MediaWiki\Extension\Translate\PageTranslation;

Severity: Minor
Found in src/PageTranslation/TranslatablePageMarker.php - About 5 hrs to fix

    Method markForTranslation has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function markForTranslation(
            TranslatablePageMarkOperation $operation,
            TranslatablePageSettings $pageSettings,
            User $user
        ): int {
    Severity: Major
    Found in src/PageTranslation/TranslatablePageMarker.php - About 2 hrs to fix

      Function validateUnitNames has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          private function validateUnitNames(
              TranslatablePage $page,
              array $units,
              bool $includePageDisplayTitle
          ): Status {
      Severity: Minor
      Found in src/PageTranslation/TranslatablePageMarker.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 __construct has 15 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              IConnectionProvider $dbProvider,
              JobQueueGroup $jobQueueGroup,
              LinkRenderer $linkRenderer,
              MessageGroups $messageGroups,
              MessageIndex $messageIndex,
      Severity: Major
      Found in src/PageTranslation/TranslatablePageMarker.php - About 1 hr to fix

        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

        Method getMarkOperation has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getMarkOperation(
                PageRecord $page,
                ?int $revision,
                bool $validateUnitTitle
            ): TranslatablePageMarkOperation {
        Severity: Minor
        Found in src/PageTranslation/TranslatablePageMarker.php - About 1 hr to fix

          Method handlePriorityLanguages has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function handlePriorityLanguages(
                  TranslatablePage $page,
                  TranslatablePageSettings $pageSettings,
                  UserIdentity $user
              ): void {
          Severity: Minor
          Found in src/PageTranslation/TranslatablePageMarker.php - About 1 hr to fix

            Method validateUnitNames has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function validateUnitNames(
                    TranslatablePage $page,
                    array $units,
                    bool $includePageDisplayTitle
                ): Status {
            Severity: Minor
            Found in src/PageTranslation/TranslatablePageMarker.php - About 1 hr to fix

              Method prepareTranslationUnits has 34 lines of code (exceeds 25 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

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

                    private function handlePriorityLanguages(
                        TranslatablePage $page,
                        TranslatablePageSettings $pageSettings,
                        UserIdentity $user
                    ): void {
                Severity: Minor
                Found in src/PageTranslation/TranslatablePageMarker.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

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

                    public function markForTranslation(
                        TranslatablePageMarkOperation $operation,
                        TranslatablePageSettings $pageSettings,
                        User $user
                    ): int {
                Severity: Minor
                Found in src/PageTranslation/TranslatablePageMarker.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

                There are no issues that match your filters.

                Category
                Status