wikimedia/mediawiki-extensions-Translate

View on GitHub
src/MessageGroupProcessing/CsvTranslationImporter.php

Summary

Maintainability
D
1 day
Test Coverage

Function parseFile has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public function parseFile( string $csvFilePath ): Status {
        if ( !file_exists( $csvFilePath ) || !is_file( $csvFilePath ) ) {
            return Status::newFatal(
                "CSV file path '$csvFilePath' does not exist, is not readable or is not a file"
            );
Severity: Minor
Found in src/MessageGroupProcessing/CsvTranslationImporter.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

Method parseFile has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function parseFile( string $csvFilePath ): Status {
        if ( !file_exists( $csvFilePath ) || !is_file( $csvFilePath ) ) {
            return Status::newFatal(
                "CSV file path '$csvFilePath' does not exist, is not readable or is not a file"
            );
Severity: Major
Found in src/MessageGroupProcessing/CsvTranslationImporter.php - About 2 hrs to fix

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

        public function importData(
            array $messagesWithTranslations,
            Authority $authority,
            string $comment,
            ?callable $progressReporter = null
    Severity: Minor
    Found in src/MessageGroupProcessing/CsvTranslationImporter.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 importData has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function importData(
            array $messagesWithTranslations,
            Authority $authority,
            string $comment,
            ?callable $progressReporter = null
    Severity: Minor
    Found in src/MessageGroupProcessing/CsvTranslationImporter.php - About 1 hr to fix

      Method getLanguagesFromHeader has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function getLanguagesFromHeader( array $csvHeader ): Status {
              if ( count( $csvHeader ) < 2 ) {
                  return Status::newFatal(
                      'CSV has < 2 columns. Assuming that there are no languages to import'
                  );
      Severity: Minor
      Found in src/MessageGroupProcessing/CsvTranslationImporter.php - About 1 hr to fix

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

            private function getLanguagesFromHeader( array $csvHeader ): Status {
                if ( count( $csvHeader ) < 2 ) {
                    return Status::newFatal(
                        'CSV has < 2 columns. Assuming that there are no languages to import'
                    );
        Severity: Minor
        Found in src/MessageGroupProcessing/CsvTranslationImporter.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