imagecms/ImageCMS

View on GitHub
application/modules/mod_discount/discount_api.php

Summary

Maintainability
C
1 day
Test Coverage

discount_api has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class discount_api extends MY_Controller
{

    /**
     * __construct base object loaded
Severity: Minor
Found in application/modules/mod_discount/discount_api.php - About 2 hrs to fix

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

    public function getUserDiscount($option = []) {
        if (count($option) > 0) {
            BaseDiscount::prepareOption($option);
        }

Severity: Minor
Found in application/modules/mod_discount/discount_api.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 getDiscount has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDiscount($option = [], $typeReturn = null) {

        if (count($option) > 0) {
            BaseDiscount::prepareOption($option);
        }
Severity: Minor
Found in application/modules/mod_discount/discount_api.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 applyProductDiscount has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function applyProductDiscount() {

        $productVariants = $this->db
            ->select('shop_product_variants.id as var_id, shop_product_variants.price as price, shop_products.id as id, shop_products.brand_id as brand_id, shop_products.category_id as category_id')
            ->from('shop_products')
Severity: Minor
Found in application/modules/mod_discount/discount_api.php - About 1 hr to fix

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

    public function getDiscount($option = [], $typeReturn = null) {

        if (count($option) > 0) {
            BaseDiscount::prepareOption($option);
        }
Severity: Minor
Found in application/modules/mod_discount/discount_api.php - About 1 hr to fix

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

    public function getDiscountBy($key, $id) {

        $this->baseDiscount = BaseDiscount::create();
        foreach ($this->baseDiscount->allDiscount as $disc) {
            switch ($key) {
Severity: Minor
Found in application/modules/mod_discount/discount_api.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

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

    public function getDiscountProduct($product, $price = null) {
        if (BaseDiscount::checkModuleInstall()) {
            $DiscProdObj = Discount_product::create();
            if ($DiscProdObj->getProductDiscount($product, $price)) {
                $arr = assetManager::create()->discount;
Severity: Minor
Found in application/modules/mod_discount/discount_api.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

Function getGiftCertificate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getGiftCertificate($key = null, $totalPrice = null) {
        $cart = BaseCart::getInstance();
        $this->baseDiscount = BaseDiscount::create();
        if ($totalPrice === null) {
            $totalPrice = $cart->getTotalPrice();
Severity: Minor
Found in application/modules/mod_discount/discount_api.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