imagecms/ImageCMS

View on GitHub
application/modules/template_manager/classes/TemplateManager.php

Summary

Maintainability
D
2 days
Test Coverage

File TemplateManager.php has 308 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace template_manager\classes;

use CMSFactory\Events;
Severity: Minor
Found in application/modules/template_manager/classes/TemplateManager.php - About 3 hrs to fix

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

    private function updateImageSizes($imageSizes) {
        $sizes = [];
        foreach ($imageSizes->size as $size) {
            if (isset($size['name']) && isset($size['width']) && isset($size['height'])) {
                if (is_numeric((string) $size['width']) && is_numeric((string) $size['height'])) {
Severity: Minor
Found in application/modules/template_manager/classes/TemplateManager.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 copyUploads has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    private function copyUploads($templateName) {
        $templateUploadsFolder = "./templates/{$templateName}/uploads";

        if (is_dir($templateUploadsFolder)) {
            foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($templateUploadsFolder)) as $entity) {
Severity: Minor
Found in application/modules/template_manager/classes/TemplateManager.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

Method installDemoArchive has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function installDemoArchive($template_name) {
        try {
            Events::create()->raiseEvent(['templateName' => $template_name], self::EVENT_DEMODATA_PRE_INSTALLED);

            $demodata_atchive = realpath('templates/' . $template_name . '/demodata/uploads.zip');
Severity: Minor
Found in application/modules/template_manager/classes/TemplateManager.php - About 1 hr to fix

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

    public function installDemoArchive($template_name) {
        try {
            Events::create()->raiseEvent(['templateName' => $template_name], self::EVENT_DEMODATA_PRE_INSTALLED);

            $demodata_atchive = realpath('templates/' . $template_name . '/demodata/uploads.zip');
Severity: Minor
Found in application/modules/template_manager/classes/TemplateManager.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 setTemplate has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function setTemplate(Template $template, $installDemodata = FALSE, $installDemoArchive = FALSE) {
        if ($this->currentTemplate->name == $template->name) {
            throw new Exception(lang('Current installed template can not be installed again', 'template_manager'));
        }

Severity: Minor
Found in application/modules/template_manager/classes/TemplateManager.php - About 1 hr to fix

Function getTemplateToPay has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getTemplateToPay() {
        if (MAINSITE) {

            preg_match('/\/var\/www\/[a-zA-Z\d]+\/data\/www\/([a-zA-Z\d\.\-]+)\//', \CI::$APP->input->server('SCRIPT_FILENAME'), $matches);
            $dirToPay = MAINSITE . '/application/config/' . $matches[1] . '/payments/template';
Severity: Minor
Found in application/modules/template_manager/classes/TemplateManager.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 setTemplate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function setTemplate(Template $template, $installDemodata = FALSE, $installDemoArchive = FALSE) {
        if ($this->currentTemplate->name == $template->name) {
            throw new Exception(lang('Current installed template can not be installed again', 'template_manager'));
        }

Severity: Minor
Found in application/modules/template_manager/classes/TemplateManager.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 updateImageSizes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function updateImageSizes($imageSizes) {
        $sizes = [];
        foreach ($imageSizes->size as $size) {
            if (isset($size['name']) && isset($size['width']) && isset($size['height'])) {
                if (is_numeric((string) $size['width']) && is_numeric((string) $size['height'])) {
Severity: Minor
Found in application/modules/template_manager/classes/TemplateManager.php - About 1 hr to fix

Function listRemote has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function listRemote($sourceUrl = '') {
        if (!$sourceUrl) {
            $sourceUrl = self::$ImageCMSRepositoryURL;
        }

Severity: Minor
Found in application/modules/template_manager/classes/TemplateManager.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 loadDefaultComponents has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function loadDefaultComponents(array $except = []) {
        if (count($this->defaultComponents) > 0) {
            return;
        }
        $componentsPath = __DIR__ . '/../components/';
Severity: Minor
Found in application/modules/template_manager/classes/TemplateManager.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 query_from_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function query_from_file($sqlString) {

        $allowedTables = \CI::$APP->load
            ->module('template_manager')
            ->config
Severity: Minor
Found in application/modules/template_manager/classes/TemplateManager.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