Smile-SA/magento2-module-product-label

View on GitHub

Showing 29 of 29 total issues

ProductLabel has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class ProductLabel extends AbstractModel implements ProductLabelInterface
{
    public const CACHE_TAG = 'smile_productlabel';

    protected StoreManagerInterface $storeManager;
Severity: Minor
Found in Model/ProductLabel.php - About 3 hrs to fix

    Function getProductLabels has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getProductLabels(): array
        {
            $productLabels     = [];
            $productLabelList  = $this->getProductLabelsList();
            $attributesProduct = $this->getAttributesOfCurrentProduct();
    Severity: Minor
    Found in Block/ProductLabel/ProductLabel.php - About 2 hrs 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 _afterLoad has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function _afterLoad()
        {
            $linkedIds = $this->getColumnValues(ProductLabelInterface::PRODUCTLABEL_ID);
    
            if (count($linkedIds)) {
    Severity: Minor
    Found in Model/ResourceModel/ProductLabel/Collection.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 checkUnicity has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function checkUnicity(AbstractModel $object, array $stores): bool
        {
            $isDefaultStore = $this->storeManager->isSingleStoreMode()
                || array_search(Store::DEFAULT_STORE_ID, $stores) !== false;
    
    
    Severity: Minor
    Found in Model/ResourceModel/ProductLabel.php - About 1 hr to fix

      Method create has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function create(Product $product, string $imageId, ?array $attributes = null): ImageBlock
          {
              $viewImageConfig = $this->presentationConfig->getViewConfig()->getMediaAttributes(
                  'Magento_Catalog',
                  ImageHelper::MEDIA_TYPE_CONFIG_NODE,
      Severity: Minor
      Found in Block/Product/ImageFactory.php - About 1 hr to fix

        Method _renderFiltersBefore has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function _renderFiltersBefore()
            {
                parent::_renderFiltersBefore();
                $storeCondition = Store::DEFAULT_STORE_ID;
        
        
        Severity: Minor
        Found in Model/ResourceModel/ProductLabel/Grid/Collection.php - About 1 hr to fix

          Method execute has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function execute()
              {
                  /** @var ResultRedirect $resultRedirect */
                  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
                  $resultRedirect->setPath('*/*/');
          Severity: Minor
          Found in Controller/Adminhtml/ProductLabel/Save.php - About 1 hr to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                public function getAllOptionIds(): array
                {
                    $optionIdsSelect = clone $this->getSelect();
                    $optionIdsSelect->reset(Select::ORDER);
                    $optionIdsSelect->reset(Select::LIMIT_COUNT);
            Severity: Major
            Found in Model/ResourceModel/ProductLabel/Collection.php and 1 other location - About 1 hr to fix
            Model/ResourceModel/ProductLabel/Collection.php on lines 40..50

            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 105.

            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

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                public function getAllAttributeIds(): array
                {
                    $optionIdsSelect = clone $this->getSelect();
                    $optionIdsSelect->reset(Select::ORDER);
                    $optionIdsSelect->reset(Select::LIMIT_COUNT);
            Severity: Major
            Found in Model/ResourceModel/ProductLabel/Collection.php and 1 other location - About 1 hr to fix
            Model/ResourceModel/ProductLabel/Collection.php on lines 55..65

            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 105.

            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

            Further Reading

            Method __construct has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    EntityFactory          $entityFactory,
                    LoggerInterface        $logger,
                    FetchStrategyInterface $fetchStrategy,
                    ManagerInterface       $eventManager,
                    Config                 $eavConfig,
            Severity: Major
            Found in Model/ResourceModel/ProductLabel/Attributes/Collection.php - About 1 hr to fix

              Method __construct has 9 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      Context                         $context,
                      PageFactory                     $resultPageFactory,
                      Registry                        $coreRegistry,
                      DataPersistorInterface          $dataPersistor,
                      Filter                          $filter,
              Severity: Major
              Found in Controller/Adminhtml/ProductLabel/Reload.php - About 1 hr to fix

                Method __construct has 9 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        string $name,
                        string $primaryFieldName,
                        string $requestFieldName,
                        CollectionFactory $collectionFactory,
                        RequestInterface $request,
                Severity: Major
                Found in Ui/Component/ProductLabel/Form/DataProvider.php - About 1 hr to fix

                  Method prepareDataSource has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function prepareDataSource(array $dataSource): array
                      {
                          if (isset($dataSource['data']['items'])) {
                              foreach ($dataSource['data']['items'] as & $item) {
                                  if (isset($item['product_label_id'])) {
                  Severity: Minor
                  Found in Ui/Component/Listing/Column/AttributeActions.php - About 1 hr to fix

                    Method __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            Context               $context,
                            Registry              $registry,
                            StoreManagerInterface $storeManager,
                            Filesystem            $filesystem,
                            ImageUploader         $imageUploader,
                    Severity: Major
                    Found in Model/ProductLabel.php - About 1 hr to fix

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                              try {
                                  $this->objectResource->delete($object);
                      
                                  unset($this->cacheById[$object->getId()]);
                                  if ($this->identifierFieldName !== null) {
                      Severity: Minor
                      Found in Model/Repository/Manager.php and 1 other location - About 55 mins to fix
                      Model/Repository/Manager.php on lines 127..138

                      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 98.

                      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

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                              try {
                                  $this->objectResource->save($object);
                      
                                  unset($this->cacheById[$object->getId()]);
                                  if ($this->identifierFieldName !== null) {
                      Severity: Minor
                      Found in Model/Repository/Manager.php and 1 other location - About 55 mins to fix
                      Model/Repository/Manager.php on lines 150..161

                      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 98.

                      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

                      Further Reading

                      Method __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              Context $context,
                              Registry $coreRegistry,
                              ProductLabelFactory $modelFactory,
                              ProductLabelRepository $modelRepository,
                              DataPersistorInterface $dataPersistor,
                      Severity: Major
                      Found in Controller/Adminhtml/ProductLabel/Save.php - About 50 mins to fix

                        Method __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                Context $context,
                                Registry $registry,
                                Image $imageHelper,
                                ProductLabelCollectionFactory $productLabelCollectionFactory,
                                CacheInterface $cache,
                        Severity: Major
                        Found in Block/ProductLabel/ProductLabel.php - About 50 mins to fix

                          Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  Context $context,
                                  EntityManager $entityManager,
                                  MetadataPool $metadataPool,
                                  StoreManagerInterface $storeManager,
                                  Json $jsonSerializer,
                          Severity: Minor
                          Found in Model/ResourceModel/ProductLabel.php - About 45 mins to fix

                            Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    ContextInterface $context,
                                    UiComponentFactory $uiComponentFactory,
                                    Image $imageHelper,
                                    UrlInterface $urlBuilder,
                                    array $components = [],
                            Severity: Minor
                            Found in Ui/Component/Listing/Column/Thumbnail.php - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language