imagecms/ImageCMS

View on GitHub
application/modules/translator/classes/LangReplacer.php

Summary

Maintainability
C
1 day
Test Coverage

LangReplacer has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class LangReplacer
{

    public static $domainTranslations = [];

Severity: Minor
Found in application/modules/translator/classes/LangReplacer.php - About 2 hrs to fix

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

    private static function updateKeysInMoPoFiles($translated, $module) {

        $languages = self::getModuleLanguages($module);
        foreach ($languages as $language) {
            $translationsAllLocales[$language] = self::getDomainTranslations($module, $language);
Severity: Minor
Found in application/modules/translator/classes/LangReplacer.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

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

    private static function changeKeysInFile($file, $data) {
        $translated = [];
        if (is_writable($file)) {
            $content = $newContent = file_get_contents($file);
            foreach ($data as $signature => $data) {
Severity: Minor
Found in application/modules/translator/classes/LangReplacer.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 parseDir has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static function parseDir($dir) {
        $dirIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
        $results = [];
        /** @var \SplFileInfo $item */
        foreach ($dirIterator as $item) {
Severity: Minor
Found in application/modules/translator/classes/LangReplacer.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 changeKeysInFile has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function changeKeysInFile($file, $data) {
        $translated = [];
        if (is_writable($file)) {
            $content = $newContent = file_get_contents($file);
            foreach ($data as $signature => $data) {
Severity: Minor
Found in application/modules/translator/classes/LangReplacer.php - About 1 hr to fix

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

    public static function findCyrillicKeys($module) {
        if ($module == 'main') {
            $langStrings = self::parseMain();
        } else {
            $langStrings = self::parseModule($module);
Severity: Minor
Found in application/modules/translator/classes/LangReplacer.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 savePoMo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function savePoMo($saveDomain) {
        foreach (self::$domainTranslations as $domain => $langs) {
            if ($domain == $saveDomain) {

                foreach ($langs as $lang => $translation) {
Severity: Minor
Found in application/modules/translator/classes/LangReplacer.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