application/modules/mod_discount/models/discount_model_admin.php
File discount_model_admin.php
has 385 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
use Currency\Currency;
if (!defined('BASEPATH')) {
- Create a ticketCreate a ticket
Method moduleInstall
has 121 lines of code (exceeds 25 allowed). Consider refactoring. Open
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);';
- Create a ticketCreate a ticket
Discount_model_admin
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class Discount_model_admin extends CI_Model
{
public function __construct() {
parent::__construct();
- Create a ticketCreate a ticket
Function checkRangeForCumulativeDiscount
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
public function checkRangeForCumulativeDiscount($data = FALSE, $id = null) {
if (!$data) {
return FALSE;
}
- Read upRead up
- Create a ticketCreate a ticket
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
Open
public function checkRangeForCumulativeDiscount($data = FALSE, $id = null) {
if (!$data) {
return FALSE;
}
- Create a ticketCreate a ticket
Function checkEntityExists
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
public function checkEntityExists($entity, $id) {
switch ($entity) {
case 'product':
return $this->db->where('id', $id)->get('shop_products')->num_rows();
- Read upRead up
- Create a ticketCreate a ticket
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
Open
return $this->db->where('id', $id)->get('shop_rbac_roles')->num_rows();
- Create a ticketCreate a ticket