Showing 28 of 402 total issues
File Offer.php
has 333 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php namespace Lovata\Shopaholic\Models;
use Backend\Models\ImportModel;
use October\Rain\Database\Traits\Sortable;
OfferItem
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class OfferItem extends ElementItem
{
use PriceHelperTrait;
const MODEL_CLASS = Offer::class;
Method registerSettings
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function registerSettings()
{
return [
'shopaholic-menu-main-settings' => [
'label' => 'lovata.shopaholic::lang.menu.main_settings',
Offer
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class Offer extends ImportModel
{
use Validation;
use SoftDelete;
use Purgeable;
Method extendFields
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function extendFields($obWidget)
{
$arAdditionFields = [
'measure' => [
'label' => 'lovata.shopaholic::lang.field.measure',
Function getPageParamList
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getPageParamList($sPageCode, $arRemoveParamList = []) : array
{
$arResult = [];
if (!empty($arRemoveParamList)) {
foreach ($arRemoveParamList as $sParamName) {
- 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 getPageParamList
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getPageParamList($sPageCode, $arRemoveParamList = []) : array
{
$arResult = [];
if (!empty($arRemoveParamList)) {
foreach ($arRemoveParamList as $sParamName) {
Method getFields
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getFields() : array
{
$this->arFieldList = [
'external_id' => Lang::get('lovata.toolbox::lang.field.external_id'),
'product_id' => Lang::get('lovata.shopaholic::lang.field.product_id'),
Function filterPageList
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function filterPageList($obPageList)
{
$arCmsPageList = [];
if (empty($obPageList) || $obPageList->isEmpty()) {
return $arCmsPageList;
- 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 getProductCountAttribute
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function getProductCountAttribute()
{
$iProductCount = $this->getAttribute('product_count');
if ($iProductCount !== null) {
return $iProductCount;
- 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 handle
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function handle()
{
$arImportList = explode(',', $this->option('import'));
$arImportList = array_filter($arImportList);
- 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 getElementByWildcard
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function getElementByWildcard($sElementSlug)
{
$arSlugList = explode('/', $sElementSlug);
if (empty($arSlugList)) {
return null;
- 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 getCustomSortingList
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function getCustomSortingList() : array
{
$arEventResult = Event::fire('shopaholic.sorting.get.list', [$this->sValue]);
if (empty($arEventResult)) {
return [];
- 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 getCustomSortingList
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function getCustomSortingList() : array
{
$arEventResult = Event::fire('shopaholic.promo_block.sorting.get.list', [$this->sValue]);
if (empty($arEventResult)) {
return [];
- 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 getIDListFromDB
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function getIDListFromDB() : array
{
if ($this->sValue == ProductListStore::SORT_PRICE_ASC) {
$arElementIDList = $this->getByPriceASC();
} elseif ($this->sValue == ProductListStore::SORT_PRICE_DESC) {
- 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 handle
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function handle()
{
foreach ($this->arMigrationList as $arMigrationData) {
$sClassName = $arMigrationData['class'];
$sFilePath = base_path($arMigrationData['path']);
- 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 getIDListFromDB
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function getIDListFromDB() : array
{
switch ($this->sValue) {
case PromoBlockListStore::SORT_DATE_BEGIN_ASC:
$arElementIDList = $this->getByDateBeginASC();
- 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 getCustomSortingList
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function getCustomSortingList() : array
{
$arEventResult = Event::fire('shopaholic.sorting.offer.get.list', [$this->sValue]);
if (empty($arEventResult)) {
return [];
- 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 getIDListFromDB
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function getIDListFromDB() : array
{
if ($this->sValue == OfferListStore::SORT_PRICE_ASC) {
$arElementIDList = $this->getByPriceASC();
} elseif ($this->sValue == OfferListStore::SORT_PRICE_DESC) {
- 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 null;