imagecms/ImageCMS

View on GitHub
application/modules/exchange/classes/Products.php

Summary

Maintainability
F
1 wk
Test Coverage

File Products.php has 716 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace exchange\classes;

use CI;
Severity: Major
Found in application/modules/exchange/classes/Products.php - About 1 day to fix

Function processProducts1 has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processProducts1() {

        $propertiesDataUpdate = [];
        $productPropDTDel = [];

Severity: Minor
Found in application/modules/exchange/classes/Products.php - About 1 day 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 processProducts1 has 132 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function processProducts1() {

        $propertiesDataUpdate = [];
        $productPropDTDel = [];

Severity: Major
Found in application/modules/exchange/classes/Products.php - About 5 hrs to fix

Function pass1Helper_getPropertiesData has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    protected function pass1Helper_getPropertiesData(SimpleXMLElement $product, $categoryId) {

        $brandIdentif = Properties::getInstance()->getBrandIdentif();
        $brandId = '';

Severity: Minor
Found in application/modules/exchange/classes/Products.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 processProducts23_Insert23 has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processProducts23_Insert23() {

        // process 2 (adding product_id to tables data)
        $products = &$this->insertCollector->getData('shop_products');
        $productsI18n = &$this->insertCollector->getData('shop_products_i18n');
Severity: Minor
Found in application/modules/exchange/classes/Products.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 pass1Helper_getImagesData has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function pass1Helper_getImagesData(SimpleXMLElement $product, $exId) {

        $additionalImages = NULL;
        $mainImage = NULL;

Severity: Minor
Found in application/modules/exchange/classes/Products.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

Products has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class Products extends ExchangeBase
{

    /**
     *
Severity: Minor
Found in application/modules/exchange/classes/Products.php - About 2 hrs to fix

Method processProducts23_Insert23 has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function processProducts23_Insert23() {

        // process 2 (adding product_id to tables data)
        $products = &$this->insertCollector->getData('shop_products');
        $productsI18n = &$this->insertCollector->getData('shop_products_i18n');
Severity: Major
Found in application/modules/exchange/classes/Products.php - About 2 hrs to fix

Function insert1 has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    protected function insert1() {

        $this->insertProducts($this->insertCollector->getData('shop_products'));
        $this->dataLoad->getNewData('products');

Severity: Minor
Found in application/modules/exchange/classes/Products.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 pass1Helper_getPropertiesData has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function pass1Helper_getPropertiesData(SimpleXMLElement $product, $categoryId) {

        $brandIdentif = Properties::getInstance()->getBrandIdentif();
        $brandId = '';

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

Method pass1Helper_getProductData has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function pass1Helper_getProductData(SimpleXMLElement $product, $exId) {

        $products = [
                     'external_id' => $exId,
                     'active'      => (string) $product->Статус == 'Удален' ? 0 : 1,
Severity: Minor
Found in application/modules/exchange/classes/Products.php - About 1 hr to fix

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

    protected function pass1Helper_getProductData(SimpleXMLElement $product, $exId) {

        $products = [
                     'external_id' => $exId,
                     'active'      => (string) $product->Статус == 'Удален' ? 0 : 1,
Severity: Minor
Found in application/modules/exchange/classes/Products.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 pass1Helper_getImagesData has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function pass1Helper_getImagesData(SimpleXMLElement $product, $exId) {

        $additionalImages = NULL;
        $mainImage = NULL;

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

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

    protected function getCompareData($type = NULL) {

        foreach ($this->products as $product) {
            // external ids of products
            if (!empty($product['external_id']) & ($type == NULL || (int) $type == 1)) {
Severity: Minor
Found in application/modules/exchange/classes/Products.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 rebuildAdditionalParentsCats has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function rebuildAdditionalParentsCats() {

        $ids = [];

        foreach ($this->products as $products) {
Severity: Minor
Found in application/modules/exchange/classes/Products.php - About 1 hr to fix

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

    public function rebuildAdditionalParentsCats() {

        $ids = [];

        foreach ($this->products as $products) {
Severity: Minor
Found in application/modules/exchange/classes/Products.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 insertProducts has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function insertProducts($data) {
        if (FALSE == (count($data) > 0)) {
            return;
        }

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

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

    protected function pass1Helper_getVariantData(SimpleXMLElement $product, $isNew = true) {

        $variant = [
                    'external_id' => (string) $product->Ид,
                    'number'      => (string) $product->Артикул,
Severity: Minor
Found in application/modules/exchange/classes/Products.php - About 1 hr to fix

Function rebuildProductProperties has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    protected function rebuildProductProperties() {

        $productTableProperties = $this->db->select('shop_product_properties_data.property_id, shop_product_property_value_i18n.value, shop_product_property_value_i18n.locale')
            ->from('shop_product_properties_data')
            ->join('shop_product_property_value', 'shop_product_properties_data.value_id = shop_product_property_value.id')
Severity: Minor
Found in application/modules/exchange/classes/Products.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 rebuildProductProperties has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function rebuildProductProperties() {

        $productTableProperties = $this->db->select('shop_product_properties_data.property_id, shop_product_property_value_i18n.value, shop_product_property_value_i18n.locale')
            ->from('shop_product_properties_data')
            ->join('shop_product_property_value', 'shop_product_properties_data.value_id = shop_product_property_value.id')
Severity: Minor
Found in application/modules/exchange/classes/Products.php - About 1 hr to fix

Method update has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function update() {

        // update has only two "passes" - as we already got product_id
        $this->updateFromCollector('shop_products', 'id');
        $this->updateFromCollector('shop_product_categories', 'product_id');
Severity: Minor
Found in application/modules/exchange/classes/Products.php - About 1 hr to fix

Function addProductsToUpperCategories has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function addProductsToUpperCategories() {

        $products = $this->db->select('shop_products.id, shop_category.full_path_ids')
            ->join('shop_category', 'shop_category.id = shop_products.category_id')
            ->get('shop_products')
Severity: Minor
Found in application/modules/exchange/classes/Products.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