File AdvancedItemSearch.php
has 848 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*******************************************************************************
Copyright 2013 Whole Foods Community Co-op
AdvancedItemSearch
has 44 functions (exceeds 20 allowed). Consider refactoring. Open
class AdvancedItemSearch extends FannieRESTfulPage
{
protected $header = 'Advanced Search';
protected $title = 'Advanced Search';
Function filterSales
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
private function filterSales($items, $form)
{
if ($form->onsale !== '') {
$where = '1=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 get_view
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_view()
{
$dbc = $this->connection;
$dbc->selectDB($this->config->get('OP_DB'));
Method filterSales
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function filterSales($items, $form)
{
if ($form->onsale !== '') {
$where = '1=1';
Function get_view
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function get_view()
{
$dbc = $this->connection;
$dbc->selectDB($this->config->get('OP_DB'));
- 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 runSearchMethods
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function runSearchMethods($form)
{
$search = new stdClass();
$search->from = 'products AS p
LEFT JOIN departments AS d ON p.department=d.dept_no
Method streamOutput
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function streamOutput($data)
{
$ret = '';
$ret .= '<table class="table search-table table-striped">';
$ret .= '<thead><tr>
Method searchUPCs
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function searchUPCs($search, $form)
{
if ($form->upcs !== '') {
$upcs = explode("\n", $form->upcs);
$upcs = array_map(function($i) {
Method filterSavedItems
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function filterSavedItems($items, $form)
{
$savedItems = $form->u;
if (is_array($savedItems) && count($savedItems) > 0) {
$savedQ = '
Method unitTest
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function unitTest($phpunit)
{
$get = $this->get_view();
$phpunit->assertNotEquals(0, strlen($get));
Function filterSavedItems
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function filterSavedItems($items, $form)
{
$savedItems = $form->u;
if (is_array($savedItems) && count($savedItems) > 0) {
$savedQ = '
- 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 searchLikeCode
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function searchLikeCode($search, $form)
{
if ($form->likeCode !== '') {
if (!strstr($search->from, 'upcLike')) {
$search->from .= ' LEFT JOIN upcLike AS u ON p.upc=u.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
Method filterMovement
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function filterMovement($items, $form)
{
if ($form->soldOp !== '') {
list($days, $store) = explode(':', $form->soldOp);
$movementStart = date('Y-m-d', mktime(0, 0, 0, date('n'), date('j')-$days-1, date('Y')));
Function runSearchMethods
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function runSearchMethods($form)
{
$search = new stdClass();
$search->from = 'products AS p
LEFT JOIN departments AS d ON p.department=d.dept_no
- 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 searchBrand
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function searchBrand($search, $form)
{
try {
if ($form->brand !== '') {
if (is_numeric($form->brand)) {
- 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 searchDiscountable
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function searchDiscountable($search, $form)
{
if ($form->discountable !== '') {
$search->where .= ' AND p.discount=? ';
if ($form->discountable == 1 || $form->discountable == 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 searchSuperDepartment
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function searchSuperDepartment($search, $form)
{
if ($form->superID !== '') {
/**
Unroll superdepartment into a list of department
- 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
$upcs = array_map(function($i){ return BarcodeLib::padUPC(trim($i)); }, $upcs);
Avoid too many return
statements within this method. Open
return $search;
Function filterMovement
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function filterMovement($items, $form)
{
if ($form->soldOp !== '') {
list($days, $store) = explode(':', $form->soldOp);
$movementStart = date('Y-m-d', mktime(0, 0, 0, date('n'), date('j')-$days-1, date('Y')));
- 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 searchSignage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function searchSignage($search, $form)
{
if ($form->signinfo !== '') {
if (!strstr($search->from, 'productUser')) {
$search->from .= ' LEFT JOIN productUser AS s ON p.upc=s.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 searchUPCs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function searchUPCs($search, $form)
{
if ($form->upcs !== '') {
$upcs = explode("\n", $form->upcs);
$upcs = array_map(function($i) {
- 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 searchVendor
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function searchVendor($search, $form)
{
if ($form->vendor === '0') {
$search->where .= ' AND p.default_vendor_id=0 ';
} elseif ($form->vendor !== '') {
- 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"