imagecms/ImageCMS

View on GitHub
application/modules/import_export/classes/BaseImport.php

Summary

Maintainability
F
3 days
Test Coverage

Function runProperties has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

    public function runProperties() {
        if (ImportBootstrap::hasErrors()) {
            return FALSE;
        }
        $properties = $this->db->query('SELECT `id`, `csv_name` FROM `shop_product_properties`')->result();
Severity: Minor
Found in application/modules/import_export/classes/BaseImport.php - About 7 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 BaseImport.php has 387 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace import_export\classes;

use CI_DB_active_record;
Severity: Minor
Found in application/modules/import_export/classes/BaseImport.php - About 5 hrs to fix

Function parseFile has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function parseFile($offers, $limit, $file = false) {
        if (!$file) {
            $file = @fopen($this->CSVsource, 'r');
        }
        if ($offers > 0) {
Severity: Minor
Found in application/modules/import_export/classes/BaseImport.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 runProperties has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function runProperties() {
        if (ImportBootstrap::hasErrors()) {
            return FALSE;
        }
        $properties = $this->db->query('SELECT `id`, `csv_name` FROM `shop_product_properties`')->result();
Severity: Major
Found in application/modules/import_export/classes/BaseImport.php - About 2 hrs to fix

Method content has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function content($node, $key) {

        $parts = $this->parseCategoryName($node['cat']);
        $pathIds = $pathNames = [];
        $parentId = $line = 0;
Severity: Major
Found in application/modules/import_export/classes/BaseImport.php - About 2 hrs to fix

Function content has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private function content($node, $key) {

        $parts = $this->parseCategoryName($node['cat']);
        $pathIds = $pathNames = [];
        $parentId = $line = 0;
Severity: Minor
Found in application/modules/import_export/classes/BaseImport.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 makeAttributesList has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function makeAttributesList() {
        if (!count($this->possibleAttributes)) {
            $this->possibleAttributes = [
                                         'skip'    => lang('Skip column', 'import_export'),
                                         'name'    => lang('Product Name', 'import_export'),
Severity: Minor
Found in application/modules/import_export/classes/BaseImport.php - About 1 hr to fix

Method parseFile has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function parseFile($offers, $limit, $file = false) {
        if (!$file) {
            $file = @fopen($this->CSVsource, 'r');
        }
        if ($offers > 0) {
Severity: Minor
Found in application/modules/import_export/classes/BaseImport.php - About 1 hr to fix

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

    public function loadCategories() {
        if (ImportBootstrap::hasErrors()) {
            return FALSE;
        }
        $this->load->helper('translit');
Severity: Minor
Found in application/modules/import_export/classes/BaseImport.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 validateFile has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function validateFile($offers, $limit) {

        if (substr(sprintf('%o', fileperms(ImportBootstrap::getUploadDir())), -4) != '0777') {
            ImportBootstrap::addMessage(Factor::ErrorFolderPermission);
            return FALSE;
Severity: Minor
Found in application/modules/import_export/classes/BaseImport.php - About 1 hr to fix

Function validateFile has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function validateFile($offers, $limit) {

        if (substr(sprintf('%o', fileperms(ImportBootstrap::getUploadDir())), -4) != '0777') {
            ImportBootstrap::addMessage(Factor::ErrorFolderPermission);
            return FALSE;
Severity: Minor
Found in application/modules/import_export/classes/BaseImport.php - About 55 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

Avoid too many return statements within this method.
Open

            return FALSE;
Severity: Major
Found in application/modules/import_export/classes/BaseImport.php - About 30 mins to fix

There are no issues that match your filters.

Category
Status