wikimedia/mediawiki-extensions-Translate

View on GitHub
src/Validation/ValidationRunner.php

Summary

Maintainability
C
1 day
Test Coverage

File ValidationRunner.php has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Message validation framework.
 *
 * @file
Severity: Minor
Found in src/Validation/ValidationRunner.php - About 2 hrs to fix

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

        public static function reloadIgnorePatterns(): void {
            $validationExclusionFile = Services::getInstance()->getConfigHelper()->getValidationExclusionFile();
    
            if ( $validationExclusionFile === false ) {
                self::$ignorePatterns = [];
    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

    Method addValidator has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function addValidator( array $validatorConfig ): void {
            $validatorId = $validatorConfig['id'] ?? null;
            $className = $validatorConfig['class'] ?? null;
    
            if ( $validatorId !== null ) {
    Severity: Minor
    Found in src/Validation/ValidationRunner.php - About 1 hr to fix

      Method reloadIgnorePatterns has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function reloadIgnorePatterns(): void {
              $validationExclusionFile = Services::getInstance()->getConfigHelper()->getValidationExclusionFile();
      
              if ( $validationExclusionFile === false ) {
                  self::$ignorePatterns = [];
      Severity: Minor
      Found in src/Validation/ValidationRunner.php - About 1 hr to fix

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

                array $validatorData,
                Message $message,
                string $targetLanguage,
                ValidationIssues $errors,
                ValidationIssues $warnings,
        Severity: Minor
        Found in src/Validation/ValidationRunner.php - About 45 mins to fix

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

                  string $messageKey,
                  ValidationIssue $issue,
                  string $messageGroupId,
                  string $targetLanguage,
                  array $pattern
          Severity: Minor
          Found in src/Validation/ValidationRunner.php - About 35 mins to fix

            Function filterValidations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                private function filterValidations(
                    string $messageKey,
                    ValidationIssues $issues,
                    string $targetLanguage
                ): ValidationIssues {
            Severity: Minor
            Found in src/Validation/ValidationRunner.php - About 35 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 runValidation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                private function runValidation(
                    array $validatorData,
                    Message $message,
                    string $targetLanguage,
                    ValidationIssues $errors,
            Severity: Minor
            Found in src/Validation/ValidationRunner.php - About 35 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