imagecms/ImageCMS

View on GitHub
application/libraries/cache.php

Summary

Maintainability
D
2 days
Test Coverage

Function delete_all has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    public function delete_all() {
        $n = 0;

        $cache_store_dir = $this->_Config['store'] . '/';
        if (is_dir($cache_store_dir) and ( $root_dir_handle = opendir($cache_store_dir))) {
Severity: Minor
Found in application/libraries/cache.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

Function cache_file has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    public function cache_file() {
        $n = 0;

        $cache_store_dir = $this->_Config['store'] . '/';
        if (is_dir($cache_store_dir) and ( $root_dir_handle = opendir($cache_store_dir))) {
Severity: Minor
Found in application/libraries/cache.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

File cache.php has 288 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
Severity: Minor
Found in application/libraries/cache.php - About 2 hrs to fix

Function Clean has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function Clean() {
        if (!($dh = opendir($this->_Config['store']))) {
            $this->log_cache_error('Clean :: Error Opening Store ' . $this->_Config['store']);
            return false;
        }
Severity: Minor
Found in application/libraries/cache.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 clearCacheFolder has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function clearCacheFolder($folder = NULL) {

        if ($folder !== NULL) {
            if ($files_all = opendir('./system/cache/' . $folder . '/')) {
                while (false !== ($fileT = readdir($files_all))) {
Severity: Minor
Found in application/libraries/cache.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 delete_all has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function delete_all() {
        $n = 0;

        $cache_store_dir = $this->_Config['store'] . '/';
        if (is_dir($cache_store_dir) and ( $root_dir_handle = opendir($cache_store_dir))) {
Severity: Minor
Found in application/libraries/cache.php - About 1 hr to fix

Method Clean has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function Clean() {
        if (!($dh = opendir($this->_Config['store']))) {
            $this->log_cache_error('Clean :: Error Opening Store ' . $this->_Config['store']);
            return false;
        }
Severity: Minor
Found in application/libraries/cache.php - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

                if (substr($file, 0, 6) != 'cache_' && $file != 'hooks.php' && $file != '.' && $file != '..' && $file != '/' && strstr($file, '.') != TRUE && (time() - $stat['mtime']) > $this->_Config['auto_clean_life']) {

                    $files_all = opendir('./system/cache/' . $file);
                    while (false !== ($fileT = readdir($files_all))) {
                        $stat = stat($this->_Config['store']);
Severity: Major
Found in application/libraries/cache.php - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

                        if ($fileT != '.' && $fileT != '..' && $fileT != '/' && (time() - @$stat['mtime']) > $this->_Config['auto_clean_life']) {
                            @unlink('./system/cache/' . $file . '/' . $fileT);
                            $n++;
                        }
Severity: Major
Found in application/libraries/cache.php - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        while (false !== ($fileT = readdir($sub_dir_handle))) {

                            if ($fileT != '.' && $fileT != '..' && $fileT != '/' && strstr($fileT, '~') != TRUE) {
                                $n++;
                            }
Severity: Major
Found in application/libraries/cache.php - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        while (FALSE !== ($fileT = readdir($sub_dir_handle))) {

                            if ($fileT != '.' && $fileT != '..' && $fileT != '/') {

                                $n++;
Severity: Major
Found in application/libraries/cache.php - About 45 mins to fix

There are no issues that match your filters.

Category
Status