EaDesgin/magento2-pdf-generator2

View on GitHub

Showing 34 of 34 total issues

Method install has 157 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;

        $installer->startSetup();
Severity: Major
Found in Setup/InstallSchema.php - About 6 hrs to fix

    Method install has 104 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
        {
    
            $storeId = $this->storeManager->getStore()->getId();
    
    
    Severity: Major
    Found in Setup/InstallData.php - About 4 hrs to fix

      Method setUp has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function setUp()
          {
              $this->context = $this->getMockBuilder(Context::class)
                  ->disableOriginalConstructor()
                  ->getMock();
      Severity: Major
      Found in Test/Unit/Helper/PdfTest.php - About 3 hrs to fix

        Function performAfterLoad has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public function performAfterLoad($tableName, $linkField)
            {
                $linkedIds = $this->getColumnValues($linkField);
        
                if (!empty($linkedIds)) {
        Severity: Minor
        Found in Model/ResourceModel/Pdfgenerator/AbstractCollection.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 execute has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public function execute()
            {
                $data = $this->getRequest()->getPostValue();
                /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
                $resultRedirect = $this->resultRedirectFactory->create();
        Severity: Minor
        Found in Controller/Adminhtml/Templates/Save.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

        Method config has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function config($templateModel)
            {
                $ori = $templateModel->getTemplatePaperOri();
                $orientation = $this->templatePaperOrientation->getAvailable();
                $finalOri = $orientation[$ori][0];
        Severity: Minor
        Found in Helper/Pdf.php - About 1 hr to fix

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

              public function execute()
              {
                  $data = $this->getRequest()->getPostValue();
                  /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
                  $resultRedirect = $this->resultRedirectFactory->create();
          Severity: Minor
          Found in Controller/Adminhtml/Templates/Save.php - About 1 hr to fix

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

                    EntityFactoryInterface $entityFactory,
                    LoggerInterface $logger,
                    FetchStrategyInterface $fetchStrategy,
                    ManagerInterface $eventManager,
                    StoreManagerInterface $storeManager,
            Severity: Major
            Found in Model/ResourceModel/Pdfgenerator/Grid/Collection.php - About 1 hr to fix

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

              <?php
              /**
               * Copyright © EAdesign by Eco Active S.R.L.,All rights reserved.
               * See LICENSE for license details.
               */
              Severity: Major
              Found in Controller/Adminhtml/Templates/MassEnable.php and 1 other location - About 1 hr to fix
              Controller/Adminhtml/Templates/MassDisable.php on lines 1..38

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

              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

              <?php
              /**
               * Copyright © EAdesign by Eco Active S.R.L.,All rights reserved.
               * See LICENSE for license details.
               */
              Severity: Major
              Found in Controller/Adminhtml/Templates/MassDisable.php and 1 other location - About 1 hr to fix
              Controller/Adminhtml/Templates/MassEnable.php on lines 1..41

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

              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 execute has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function execute()
                  {
              
                      $template = $this->_initTemplate();
              
              
              Severity: Minor
              Found in Controller/Adminhtml/Variable/Template.php - About 1 hr to fix

                Method testTemplate2Pdf has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function testTemplate2Pdf()
                    {
                
                        $this->pdfGeneratorMock = $this->getMockBuilder(Pdfgenerator::class)
                            ->setMethods(['getTemplateCustomForm'])
                Severity: Minor
                Found in Test/Unit/Helper/PdfTest.php - About 1 hr to fix

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

                          Context $context,
                          Registry $coreRegistry,
                          Config $emailConfig,
                          JsonFactory $resultJsonFactory,
                          Pdf $helper,
                  Severity: Major
                  Found in Controller/Adminhtml/Order/Invoice/Printpdf.php - About 1 hr to fix

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

                        public function performAfterLoad($tableName, $linkField)
                        {
                            $linkedIds = $this->getColumnValues($linkField);
                    
                            if (!empty($linkedIds)) {
                    Severity: Minor
                    Found in Model/ResourceModel/Pdfgenerator/AbstractCollection.php - About 1 hr to fix

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

                          public function execute()
                          {
                      
                              $templateId = $this->getRequest()->getParam('template_id');
                      
                      
                      Severity: Minor
                      Found in Controller/Adminhtml/Order/Invoice/Printpdf.php - About 1 hr to fix

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

                                Context $context,
                                Renderer $addressRenderer,
                                PaymentHelper $paymentHelper,
                                InvoiceIdentity $identityContainer,
                                Processor $templateFactory,
                        Severity: Major
                        Found in Helper/Pdf.php - About 1 hr to fix

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

                              public function testGetTemplateStatus()
                              {
                          
                                  $invoiceMock = $this->getMockBuilder(Invoice::class)
                                      ->disableOriginalConstructor()
                          Severity: Minor
                          Found in Test/Unit/Helper/DataTest.php - About 1 hr to fix

                            Method setUp has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function setUp()
                                {
                                    $this->context = $this->getMockBuilder(Context::class)
                                        ->setMethods(['getScopeConfig'])
                                        ->disableOriginalConstructor()
                            Severity: Minor
                            Found in Test/Unit/Helper/DataTest.php - About 1 hr to fix

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

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

                                Method saveStoreRelation has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function saveStoreRelation(AbstractModel $template)
                                    {
                                        $oldStores = $this->lookupStoreIds($template->getId());
                                        $newStores = (array)$template->getStoreId();
                                        if (empty($newStores)) {
                                Severity: Minor
                                Found in Model/ResourceModel/Pdfgenerator.php - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language