edde-framework/edde-framework

View on GitHub
src/Edde/Common/File/FileUtils.php

Summary

Maintainability
B
6 hrs
Test Coverage

Function delete has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

        static public function delete($path) {
            for ($i = 0; $i < 3; $i++) {
                try {
                    if (is_file($path) || is_link($path)) {
                        $func = DIRECTORY_SEPARATOR === '\\' && is_dir($path) ? 'rmdir' : 'unlink';
Severity: Minor
Found in src/Edde/Common/File/FileUtils.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 mime has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        static public function mime(string $file) {
            if (is_file($file) === false) {
                throw new FileException(sprintf('The given file [%s] is not a file.', $file));
            }
            $url = Url::create($file);
Severity: Minor
Found in src/Edde/Common/File/FileUtils.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 copyDirectory has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        static public function copyDirectory(string $source, string $destination, callable $filter = null) {
            $source = self::normalize($source);
            $destination = self::normalize($destination);
            /** @var $item \SplFileInfo */
            foreach (new \RecursiveIteratorIterator($iterator = new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
Severity: Minor
Found in src/Edde/Common/File/FileUtils.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 rename has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        static public function rename(string $name, string $rename, bool $overwrite = true) {
            if ($overwrite === false && file_exists($rename)) {
                throw new FileException("File or directory [$rename] already exists.");
            } else if (file_exists($name) === false) {
                throw new FileException("File or directory [$name] not found.");
Severity: Minor
Found in src/Edde/Common/File/FileUtils.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