File ReceiptLib.php
has 927 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*******************************************************************************
Copyright 2001, 2004 Wedge Community Co-op
Function printReceipt
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
static public function printReceipt($arg1, $ref, $second=False, $email=False)
{
if($second) $email = False; // store copy always prints
if($arg1 != "full") $email = False;
$reprint = $arg1 == 'reprint' ? true : false;
- 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
ReceiptLib
has 46 functions (exceeds 20 allowed). Consider refactoring. Open
class ReceiptLib
{
static private $PRINT;
static private $EMAIL = 'COREPOS\\pos\\lib\\PrintHandlers\EmailPrintHandler';
Method printReceipt
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function printReceipt($arg1, $ref, $second=False, $email=False)
{
if($second) $email = False; // store copy always prints
if($arg1 != "full") $email = False;
$reprint = $arg1 == 'reprint' ? true : false;
Function receiptDetail
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
static public function receiptDetail($reprint=false, $transNum='')
{
// put into its own function to make it easier to follow, and slightly
// modified for wider-spread use of joe's "new" receipt format --- apbw 7/3/2007
if (CoreLocal::get("newReceipt") == 2) {
- 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 memReceiptMessages
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
static public function memReceiptMessages($cardNo)
{
$dbc = Database::pDataConnect();
$memQ = 'SELECT msg_text,modifier_module
FROM custReceiptMessage
- 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 receiptDetail
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function receiptDetail($reprint=false, $transNum='')
{
// put into its own function to make it easier to follow, and slightly
// modified for wider-spread use of joe's "new" receipt format --- apbw 7/3/2007
if (CoreLocal::get("newReceipt") == 2) {
Function messageModFooters
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
static private function messageModFooters($receipt, $where, $ref, $reprint, $nth)
{
// check if message mods have data
// and add them to the receipt
$dbc = Database::tDataConnect();
- 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 printReceiptHeader
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
static public function printReceiptHeader($dateTimeStamp, $ref)
{
self::initDriver();
$receipt = self::$PRINT->TextStyle(True);
$imgCache = CoreLocal::get('ImageCache');
- 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 setupReprint
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
static private function setupReprint($where)
{
// lookup trans information
$dbc = Database::tDataConnect();
$queryHeader = "
Method printReceiptHeader
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function printReceiptHeader($dateTimeStamp, $ref)
{
self::initDriver();
$receipt = self::$PRINT->TextStyle(True);
$imgCache = CoreLocal::get('ImageCache');
Method memReceiptMessages
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function memReceiptMessages($cardNo)
{
$dbc = Database::pDataConnect();
$memQ = 'SELECT msg_text,modifier_module
FROM custReceiptMessage
Method receiptFromBuilders
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function receiptFromBuilders($transNum='')
{
$empNo=0;$laneNo=0;$transNo=0;
list($empNo, $laneNo, $transNo) = self::parseRef($transNum);
self::initDriver();
Method chargeBalance
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function chargeBalance($receipt, $program="charge", $transNum='')
{
\COREPOS\pos\lib\MemberLib::chargeOk();
$labels = array();
Method printChargeFooterStore
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function printChargeFooterStore($dateTimeStamp, $ref, $program="charge")
{
$chgName = \COREPOS\pos\lib\MemberLib::getChgName(); // added by apbw 2/14/05 SCR
$date = self::build_time($dateTimeStamp);
Method messageModFooters
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
static private function messageModFooters($receipt, $where, $ref, $reprint, $nth)
{
// check if message mods have data
// and add them to the receipt
$dbc = Database::tDataConnect();
Method printCabCoupon
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function printCabCoupon($dateTimeStamp, $ref)
{
$receipt = "\n";
$receipt .= self::biggerFont(self::centerBig("WHOLE FOODS COMMUNITY CO-OP"))."\n\n";
Method twoColumns
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function twoColumns($col1, $col2) {
// init
$max = 56;
$text = "";
// find longest string in each column, ignoring font change strings
Function receiptFromBuilders
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static public function receiptFromBuilders($transNum='')
{
$empNo=0;$laneNo=0;$transNo=0;
list($empNo, $laneNo, $transNo) = self::parseRef($transNum);
self::initDriver();
- 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 twoColumns
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static public function twoColumns($col1, $col2) {
// init
$max = 56;
$text = "";
// find longest string in each column, ignoring font change strings
- 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 getTypeMap
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static private function getTypeMap()
{
$typeMap = array();
foreach(self::messageMods(true) as $class){
if (in_array($class, self::$msgMods)) {
- 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 chargeBalance
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static public function chargeBalance($receipt, $program="charge", $transNum='')
{
\COREPOS\pos\lib\MemberLib::chargeOk();
$labels = array();
- 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 messageModFooters
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
static private function messageModFooters($receipt, $where, $ref, $reprint, $nth)
Function messageMods
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static private function messageMods($nth)
{
$messageMods = CoreLocal::get('ReceiptMessageMods');
if (!is_array($messageMods)) $messageMods = array();
if ($nth) {
- 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
Avoid too many return
statements within this method. Open
return false;
Function nthReceipt
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static private function nthReceipt()
{
if (CoreLocal::get('lotterySpin') !== false && CoreLocal::get('lotterySpin') !== '') {
return CoreLocal::get('lotterySpin') < CoreLocal::get('nthReceipt');
} elseif (CoreLocal::get('nthReceipt') > 0 && CoreLocal::get('nthReceipt') < 1) {
- 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 simpleReceipt
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static private function simpleReceipt($receipt, $arg1, $where)
{
/***** jqh 09/29/05 if receipt isn't full, then display receipt in old style *****/
$query="select linetoprint from rp_receipt WHERE " . $where . ' ORDER BY trans_id';
if ($arg1 == 'partial') {
- 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 cutReceipt
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static public function cutReceipt($receipt, $second)
{
if (is_array($receipt)){
if ($second){
// second always prints
- 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
static public function code39($barcode, $forcePaper=false)
{
if (!is_object(self::$PRINT)) {
self::$PRINT= PrintHandler::factory(CoreLocal::get('ReceiptDriver'));
}
- 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 151.
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
static public function code128($barcode, $forcePaper=false)
{
if (!is_object(self::$PRINT)) {
self::$PRINT= PrintHandler::factory(CoreLocal::get('ReceiptDriver'));
}
- 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 151.
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