imagecms/ImageCMS

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

Summary

Maintainability
D
2 days
Test Coverage

Function findLangs has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

    public function findLangs($dir = '') {

        if (!in_array($dir, self::$PARSED_PATHS)) {
            $baseDir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
            foreach ($baseDir as $file) {
Severity: Minor
Found in application/modules/translator/classes/FilesParser.php - About 1 day 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 getParsedPathsLangs has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function getParsedPathsLangs($baseUrl, $paths = []) {

        if ($paths) {
            $result = [];
            if ($paths) {
Severity: Minor
Found in application/modules/translator/classes/FilesParser.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 findLangs has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function findLangs($dir = '') {

        if (!in_array($dir, self::$PARSED_PATHS)) {
            $baseDir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
            foreach ($baseDir as $file) {
Severity: Minor
Found in application/modules/translator/classes/FilesParser.php - About 1 hr to fix

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

    public function parseTemplates() {

        try {
            if (!is_dir(self::$TEMPLATES_PATH)) {
                return [];
Severity: Minor
Found in application/modules/translator/classes/FilesParser.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 parseModules has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function parseModules() {

        try {
            $modules = getModulesPaths();
            foreach ($modules as $moduleName => $modulePath) {
Severity: Minor
Found in application/modules/translator/classes/FilesParser.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 parseModules has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function parseModules() {

        try {
            $modules = getModulesPaths();
            foreach ($modules as $moduleName => $modulePath) {
Severity: Minor
Found in application/modules/translator/classes/FilesParser.php - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

                                    if ($lang) {
                                        $lang = mb_ereg_search_getregs(); //get first result
                                        do {
                                            $origin = mb_ereg_replace('!\s+!', ' ', $lang[1]);

Severity: Major
Found in application/modules/translator/classes/FilesParser.php - About 45 mins to fix

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

    public function parseMain() {

        try {
            if (!is_dir(self::$MAIN_PATH)) {
                return [];
Severity: Minor
Found in application/modules/translator/classes/FilesParser.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