File VoidCmd.php
has 557 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*******************************************************************************
Copyright 2007 Whole Foods Co-op
Method voidupc
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function voidupc($upc, $json, $itemNum=-1)
{
$deliflag = false;
$quantity = 0;
Method voidid
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function voidid($itemNum, $json)
{
$row = $this->getLine($itemNum);
$upc = $row["upc"];
VoidCmd
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class VoidCmd extends Parser implements AdminLoginInterface
{
private $scaleprice = 0;
public function check($str)
Method findUpcLine
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function findUpcLine($upc, $scaleprice, $deliflag, $itemNum)
{
$dbc = Database::tDataConnect();
//----------------------Void Item------------------
$queryUPC = "SELECT
Consider simplifying this complex logical expression. Open
if (($this->session->get("isMember") != 1 && $row["discounttype"] == 2) ||
($this->session->get("isStaff") == 0 && $row["discounttype"] == 4)) {
$unitPrice = $row["regPrice"];
} elseif ((($this->session->get("isMember") == 1 && $row["discounttype"] == 2) ||
($this->session->get("isStaff") != 0 && $row["discounttype"] == 4)) &&
Function voidid
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function voidid($itemNum, $json)
{
$row = $this->getLine($itemNum);
$upc = $row["upc"];
- Read upRead up
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 voidupc
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function voidupc($upc, $json, $itemNum=-1)
{
$deliflag = false;
$quantity = 0;
- Read upRead up
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 checkUpcQuantities
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function checkUpcQuantities($voidable, $quantity, $scale, $row)
{
if ($voidable == 0 && $quantity == 1) {
throw new Exception(DisplayLib::boxMsg(
_("Item already voided"),
Method voiditem
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function voiditem($itemNum, $json)
{
if ($itemNum) {
$row = $this->getLine($itemNum);
Method parse
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse($str)
{
$ret = $this->default_json();
try {
Function voiditem
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function voiditem($itemNum, $json)
{
if ($itemNum) {
$row = $this->getLine($itemNum);
- Read upRead up
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 branchByVoided
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function branchByVoided($voided, $transID, $status, $ret)
{
/**
Voided values:
2 => "you saved" line
- Read upRead up
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 parse
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function parse($str)
{
$ret = $this->default_json();
try {
- Read upRead up
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 adjustUnitPrice
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function adjustUnitPrice($upc, $row)
{
$unitPrice = $row['unitPrice'];
/**
11Jun14 Andy
- Read upRead up
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 checkUpcQuantities
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function checkUpcQuantities($voidable, $quantity, $scale, $row)
{
if ($voidable == 0 && $quantity == 1) {
throw new Exception(DisplayLib::boxMsg(
_("Item already voided"),
- Read upRead up
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
} elseif ($voidable < $quantity) {
$message = _("Void request exceeds")."<br />"._("number of items rung in")."<p><b>".
sprintf(_("You can void up to %d"),$row['voidable'])."</b>";
throw new Exception(DisplayLib::boxMsg($message, '', false, DisplayLib::standardClearButton()));
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 96.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
} elseif ($voidable < $quantity && $scale == 1) {
$message = _("Void request exceeds")."<br />"._("weight of item rung in")."<p><b>".
sprintf(_("You can void up to %.2f lb"),$row['voidable'])."</b>";
throw new Exception(DisplayLib::boxMsg($message, '', false, DisplayLib::standardClearButton()));
} elseif ($voidable < $quantity) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 96.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76