imagecms/ImageCMS

View on GitHub
application/modules/mod_discount/models/discount_model_admin.php

Summary

Maintainability
D
1 day
Test Coverage

File discount_model_admin.php has 385 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use Currency\Currency;

if (!defined('BASEPATH')) {
Severity: Minor
Found in application/modules/mod_discount/models/discount_model_admin.php - About 5 hrs to fix

Method moduleInstall has 121 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function moduleInstall() {

        $column = $this->db->query("SHOW COLUMNS FROM `shop_orders` where `Field` = 'discount'")->num_rows();
        if (!$column) {
            $sql = 'ALTER TABLE shop_orders ADD discount float(10,2);';
Severity: Major
Found in application/modules/mod_discount/models/discount_model_admin.php - About 4 hrs to fix

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

class Discount_model_admin extends CI_Model
{

    public function __construct() {
        parent::__construct();
Severity: Minor
Found in application/modules/mod_discount/models/discount_model_admin.php - About 2 hrs to fix

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

    public function checkRangeForCumulativeDiscount($data = FALSE, $id = null) {
        if (!$data) {
            return FALSE;
        }

Severity: Minor
Found in application/modules/mod_discount/models/discount_model_admin.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 checkRangeForCumulativeDiscount has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function checkRangeForCumulativeDiscount($data = FALSE, $id = null) {
        if (!$data) {
            return FALSE;
        }

Severity: Minor
Found in application/modules/mod_discount/models/discount_model_admin.php - About 1 hr to fix

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

    public function checkEntityExists($entity, $id) {

        switch ($entity) {
            case 'product':
                return $this->db->where('id', $id)->get('shop_products')->num_rows();
Severity: Minor
Found in application/modules/mod_discount/models/discount_model_admin.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

Avoid too many return statements within this method.
Open

                return $this->db->where('id', $id)->get('shop_rbac_roles')->num_rows();
Severity: Major
Found in application/modules/mod_discount/models/discount_model_admin.php - About 30 mins to fix

There are no issues that match your filters.

Category
Status