modxcms/revolution

View on GitHub
core/model/modx/transport/modtranslator.class.php

Summary

Maintainability
B
5 hrs
Test Coverage

Function translateSite has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public function translateSite($save = false,$toFile = false) {
        if (!empty($this->paths)) {
            $c = count($this->paths);
            for ($i=0;$i<$c;$i++) {
                $path = $this->paths[$i];
Severity: Minor
Found in core/model/modx/transport/modtranslator.class.php - About 3 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 getAllSubdirs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAllSubdirs($path) {
        if (file_exists($path) && is_dir($path)) {
            $handle = opendir($path);
            if ($handle) {
                while (($file = readdir($handle)) !== false) {
Severity: Minor
Found in core/model/modx/transport/modtranslator.class.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

Avoid deeply nested control flow statements.
Open

                        if ($filename != '.' && $filename != '..' && $filename != '.svn' && $filename != '.git' && in_array($extension,$this->patterns)) {
                            $file= $path . $filename;
                            if (!is_dir($file)) {
                                $this->files[]= $file;
                            }
Severity: Major
Found in core/model/modx/transport/modtranslator.class.php - About 45 mins to fix

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

        public function addPath() {
            $args = func_get_args();
            $c = count($args);
            for ($i=0;$i<$c;$i++) {
                $path = $args[$i];
    Severity: Minor
    Found in core/model/modx/transport/modtranslator.class.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