imagecms/ImageCMS

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

Summary

Maintainability
F
1 wk
Test Coverage

File ProductsImport.php has 652 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace import_export\classes;

use CI_DB_active_record;
Severity: Major
Found in application/modules/import_export/classes/ProductsImport.php - About 1 day to fix

Function runProductVariantUpdateQuery has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    private function runProductVariantUpdateQuery(&$arg, &$productId, $EmptyFields) {
        /* START product variant insert query block */

        $prepareNames = $binds = $updateData = [];

Severity: Minor
Found in application/modules/import_export/classes/ProductsImport.php - About 5 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 runProductUpdateQuery has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    public function runProductUpdateQuery($productId, $arg, $EmptyFields) {
        $insertData = [];

        if ($arg['url'] != '') {
            $arg['url'] = $this->urlCheck($arg['url'], $productId);
Severity: Minor
Found in application/modules/import_export/classes/ProductsImport.php - About 5 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 runProductInsertQuery has 104 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function runProductInsertQuery($arg, $EmptyFields) {
        if ($arg['name'] == '') {
            Logger::create()
                ->set('Колонка имени товара пустая. NUM - ' . $arg['num'] . ' insert. - IMPORT');
            return;
Severity: Major
Found in application/modules/import_export/classes/ProductsImport.php - About 4 hrs to fix

Method runProductUpdateQuery has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function runProductUpdateQuery($productId, $arg, $EmptyFields) {
        $insertData = [];

        if ($arg['url'] != '') {
            $arg['url'] = $this->urlCheck($arg['url'], $productId);
Severity: Major
Found in application/modules/import_export/classes/ProductsImport.php - About 3 hrs to fix

Method runProductVariantUpdateQuery has 85 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function runProductVariantUpdateQuery(&$arg, &$productId, $EmptyFields) {
        /* START product variant insert query block */

        $prepareNames = $binds = $updateData = [];

Severity: Major
Found in application/modules/import_export/classes/ProductsImport.php - About 3 hrs to fix

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

    private function updateSProductsCategories(&$arg, $productId, $EmptyFields) {
        $shopCategoryIds = [];

        $updateAddCategories = isset($arg['addcats']) && ('' !== trim($arg['addcats']) || $EmptyFields);
        if ($updateAddCategories) {
Severity: Minor
Found in application/modules/import_export/classes/ProductsImport.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 runProductInsertQuery has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private function runProductInsertQuery($arg, $EmptyFields) {
        if ($arg['name'] == '') {
            Logger::create()
                ->set('Колонка имени товара пустая. NUM - ' . $arg['num'] . ' insert. - IMPORT');
            return;
Severity: Minor
Found in application/modules/import_export/classes/ProductsImport.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 updateSProductsCategories has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function updateSProductsCategories(&$arg, $productId, $EmptyFields) {
        $shopCategoryIds = [];

        $updateAddCategories = isset($arg['addcats']) && ('' !== trim($arg['addcats']) || $EmptyFields);
        if ($updateAddCategories) {
Severity: Major
Found in application/modules/import_export/classes/ProductsImport.php - About 2 hrs to fix

Method runProductVariantInsertQuery has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function runProductVariantInsertQuery(&$arg, &$productId) {
        if (isset($arg['prc'])) {
            $arg['prc'] = str_replace(',', '.', $arg['prc']);
        } else {
            $arg['prc'] = 0;
Severity: Major
Found in application/modules/import_export/classes/ProductsImport.php - About 2 hrs to fix

Function runAditionalImages has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function runAditionalImages($arg, $id) {
        $this->db->delete('shop_product_images', ['product_id' => $id]);

        $arg['imgs'] = explode('|', $arg['imgs']);

Severity: Minor
Found in application/modules/import_export/classes/ProductsImport.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 saveImgByUrl has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function saveImgByUrl($param, $type = false) {
        if (!$type) {
            Logger::create()
                ->set('$type is false. saveImgByUrl() ProductsImport.php. - IMPORT');
            return FALSE;
Severity: Minor
Found in application/modules/import_export/classes/ProductsImport.php - About 2 hrs to fix

Function runCopyImages has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function runCopyImages($result) {
        foreach ((array) $result as $item) {
            if (preg_match('/http\:\/\//i', $item['vimg']) || preg_match('/https\:\/\//i', $item['vimg'])) {
                $filename = $this->saveImgByUrl($item['vimg'], 'origin');
                if ($filename) {
Severity: Minor
Found in application/modules/import_export/classes/ProductsImport.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 runAditionalImages has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function runAditionalImages($arg, $id) {
        $this->db->delete('shop_product_images', ['product_id' => $id]);

        $arg['imgs'] = explode('|', $arg['imgs']);

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

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

    private function saveImgByUrl($param, $type = false) {
        if (!$type) {
            Logger::create()
                ->set('$type is false. saveImgByUrl() ProductsImport.php. - IMPORT');
            return FALSE;
Severity: Minor
Found in application/modules/import_export/classes/ProductsImport.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 processBrands has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processBrands() {
        $this->load->helper('translit');
        foreach (BaseImport::create()->content as $key => $node) {
            if (isset($node['brd']) && !empty($node['brd'])) {
                $result = $this->db->query(
Severity: Minor
Found in application/modules/import_export/classes/ProductsImport.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 runCopyImages has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function runCopyImages($result) {
        foreach ((array) $result as $item) {
            if (preg_match('/http\:\/\//i', $item['vimg']) || preg_match('/https\:\/\//i', $item['vimg'])) {
                $filename = $this->saveImgByUrl($item['vimg'], 'origin');
                if ($filename) {
Severity: Minor
Found in application/modules/import_export/classes/ProductsImport.php - About 1 hr to fix

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

    protected function processBrands() {
        $this->load->helper('translit');
        foreach (BaseImport::create()->content as $key => $node) {
            if (isset($node['brd']) && !empty($node['brd'])) {
                $result = $this->db->query(
Severity: Minor
Found in application/modules/import_export/classes/ProductsImport.php - About 1 hr to fix

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

    private function runProductVariantInsertQuery(&$arg, &$productId) {
        if (isset($arg['prc'])) {
            $arg['prc'] = str_replace(',', '.', $arg['prc']);
        } else {
            $arg['prc'] = 0;
Severity: Minor
Found in application/modules/import_export/classes/ProductsImport.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 $goodName . '.' . $format;
Severity: Major
Found in application/modules/import_export/classes/ProductsImport.php - About 30 mins to fix

There are no issues that match your filters.

Category
Status