oc-shopaholic/oc-shopaholic-plugin

View on GitHub

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;
Severity: Minor
Found in models/Offer.php - About 4 hrs to fix

    OfferItem has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class OfferItem extends ElementItem
    {
        use PriceHelperTrait;
    
        const MODEL_CLASS = Offer::class;
    Severity: Minor
    Found in classes/item/OfferItem.php - About 3 hrs to fix

      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',
      Severity: Major
      Found in Plugin.php - About 2 hrs to fix

        Offer has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Offer extends ImportModel
        {
            use Validation;
            use SoftDelete;
            use Purgeable;
        Severity: Minor
        Found in models/Offer.php - About 2 hrs to fix

          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',
          Severity: Minor
          Found in classes/event/offer/ExtendOfferFieldsHandler.php - About 1 hr to fix

            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) {
            Severity: Minor
            Found in classes/item/CategoryItem.php - About 1 hr to fix

            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) {
            Severity: Minor
            Found in classes/item/CategoryItem.php - About 1 hr to fix

              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'),
              Severity: Minor
              Found in classes/import/ImportOfferModelFromXML.php - About 1 hr to fix

                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;
                Severity: Minor
                Found in classes/helper/CommonMenuType.php - About 1 hr to fix

                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;
                Severity: Minor
                Found in classes/item/CategoryItem.php - About 55 mins to fix

                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);
                
                
                Severity: Minor
                Found in classes/console/ImportFromXML.php - About 55 mins to fix

                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;
                Severity: Minor
                Found in components/CategoryPage.php - About 45 mins to fix

                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 [];
                Severity: Minor
                Found in classes/store/product/SortingListStore.php - About 35 mins to fix

                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 [];
                Severity: Minor
                Found in classes/store/promoblock/SortingListStore.php - About 35 mins to fix

                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) {
                Severity: Minor
                Found in classes/store/product/SortingListStore.php - About 35 mins to fix

                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']);
                Severity: Minor
                Found in classes/console/CheckTableIntegrity.php - About 35 mins to fix

                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();
                Severity: Minor
                Found in classes/store/promoblock/SortingListStore.php - About 35 mins to fix

                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 [];
                Severity: Minor
                Found in classes/store/offer/SortingListStore.php - About 35 mins to fix

                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) {
                Severity: Minor
                Found in classes/store/offer/SortingListStore.php - About 35 mins to fix

                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;
                Severity: Major
                Found in components/CategoryPage.php - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language