File FannieSignage.php
has 1134 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*******************************************************************************
Copyright 2014 Whole Foods Co-op, Duluth, MN
Function loadItems
has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring. Open
public function loadItems()
{
if ($this->source == 'provided') {
return $this->items;
}
- 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
FannieSignage
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
class FannieSignage
{
protected $items = array();
protected $source = '';
protected $source_id = 0;
Method loadItems
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadItems()
{
if ($this->source == 'provided') {
return $this->items;
}
Method listItems
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function listItems()
{
// preserve values from re-posting form
$overrides = array();
$upc = FormLib::get('update_upc', array());
Method listFromBatches
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function listFromBatches($dbc)
{
if (!is_array($this->source_id)) {
$this->source_id = array($this->source_id);
}
Method listFromUpcomingSale
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function listFromUpcomingSale($dbc)
{
$ids = '';
$args = array();
$s_def = $dbc->tableDefinition('SignProperties');
Function formatPrice
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function formatPrice($price, $multiplier=1, $regPrice=0)
{
if ($multiplier > 1) {
// if the multiplier results in a nearly round number, just use the round number
// otherwise use two decimal places.
- 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 listFromCurrentSale
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function listFromCurrentSale($dbc)
{
$ids = '';
$args = array();
$s_def = $dbc->tableDefinition('SignProperties');
Function listFromBatches
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function listFromBatches($dbc)
{
if (!is_array($this->source_id)) {
$this->source_id = array($this->source_id);
}
- 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 listFromUpcomingRetail
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function listFromUpcomingRetail($dbc)
{
$ids = '';
$args = array();
$s_def = $dbc->tableDefinition('SignProperties');
Method listFromCurrentRetail
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function listFromCurrentRetail($dbc)
{
$ids = '';
$args = array();
$s_def = $dbc->tableDefinition('SignProperties');
Function drawBarcode
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function drawBarcode($upc, $pdf, $x, $y, $args=array())
{
$height = isset($args['height']) ? $args['height'] : 16;
$width = isset($args['width']) ? $args['width'] : 0.35;
$align = isset($args['align']) ? $args['align'] : 'C';
- 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 listItems
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function listItems()
{
// preserve values from re-posting form
$overrides = array();
$upc = FormLib::get('update_upc', 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 drawBarcode
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function drawBarcode($upc, $pdf, $x, $y, $args=array())
{
$height = isset($args['height']) ? $args['height'] : 16;
$width = isset($args['width']) ? $args['width'] : 0.35;
$align = isset($args['align']) ? $args['align'] : 'C';
Method sortProductsByPhysicalLocation
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
static function sortProductsByPhysicalLocation($dbc, $data, $storeID)
{
$upcs = array();
foreach ($data as $k => $row) {
Function fitText
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function fitText($pdf, $font_size, $text, $spacing)
{
$font_shrink = 0;
$effective_width = $this->width - $this->left;
$column = $spacing[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 formatPrice
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function formatPrice($price, $multiplier=1, $regPrice=0)
{
if ($multiplier > 1) {
// if the multiplier results in a nearly round number, just use the round number
// otherwise use two decimal places.
Method listFromBatchBarcodes
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function listFromBatchBarcodes()
{
if (!is_array($this->source_id)) {
$this->source_id = array($this->source_id);
}
Method listFromShelftags
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function listFromShelftags()
{
$query = 'SELECT s.upc,
s.description,
s.description AS posDescription,
Method unrollLikeCode
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function unrollLikeCode($dbc, $code, $item)
{
$likeP = $dbc->prepare('
SELECT u.upc,
' . ItemText::longBrandSQL('s', 'p') . ',
Method fitText
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function fitText($pdf, $font_size, $text, $spacing)
{
$font_shrink = 0;
$effective_width = $this->width - $this->left;
$column = $spacing[0];
Function printablePrice
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function printablePrice($item)
{
$price = $item['normal_price'];
if ($item['scale'] && isset($item['signMultiplier']) && $item['signMultiplier'] < 0) {
$price = $this->formatScalePrice($item['normal_price'], $item['signMultiplier'], $item['nonSalePrice']);
- 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 formatOffString
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected static function formatOffString($price, $multiplier, $regPrice)
{
if ($regPrice == 0 || $multiplier == -4) {
return sprintf('$%.2f', $price);
} elseif ($multiplier == -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
Method drawBarcode
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function drawBarcode($upc, $pdf, $x, $y, $args=array())
Avoid too many return
statements within this method. Open
return '4/$' . $ttl;
Avoid too many return
statements within this method. Open
return $price;
Avoid too many return
statements within this method. Open
return sprintf('$%.2f', $price);
Avoid too many return
statements within this method. Open
return '5/$' . $ttl;
Avoid too many return
statements within this method. Open
return sprintf('%d/$%d', $mult, round($mult*$price));
Avoid too many return
statements within this method. Open
return '2/$' . $ttl;
Avoid too many return
statements within this method. Open
return '5/$5';
Avoid too many return
statements within this method. Open
return _('BUY ONE GET ONE FREE');
Avoid too many return
statements within this method. Open
return $price;
Avoid too many return
statements within this method. Open
return substr(sprintf('%.2f', $price),-2) . chr(0xA2);
Function formatSize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function formatSize($size, $item)
{
$plu = ltrim($item['upc'], '0');
if (strlen($plu) < 5 && strlen($plu) > 0 && $item['scale']) {
return 'PLU# ' . ltrim($item['upc'], '0'); // show PLU #s on by-weight
- 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 function sortProductsByPhysicalLocation($dbc, $data, $storeID)
{
$upcs = array();
foreach ($data as $k => $row) {
- 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 275.
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
protected function listFromUpcomingSale($dbc)
{
$ids = '';
$args = array();
$s_def = $dbc->tableDefinition('SignProperties');
- 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 262.
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
protected function listFromUpcomingRetail($dbc)
{
$ids = '';
$args = array();
$s_def = $dbc->tableDefinition('SignProperties');
- 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 262.
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