Leuchtfeuer/mautic-deutschepost

View on GitHub
Controller/TriggerCampaignController.php

Summary

Maintainability
F
3 days
Test Coverage

File TriggerCampaignController.php has 463 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace MauticPlugin\LeuchtfeuerPrintmailingBundle\Controller;

use Doctrine\ORM\EntityNotFoundException;
Severity: Minor
Found in Controller/TriggerCampaignController.php - About 7 hrs to fix

    TriggerCampaignController has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TriggerCampaignController extends AbstractFormController
    {
        public const PERMISSIONS = [
            'create'  => 'printmailing:campaigns:create',
            'delete'  => 'printmailing:campaigns:delete',
    Severity: Minor
    Found in Controller/TriggerCampaignController.php - About 2 hrs to fix

      Method createTriggerCampaignModifyRequest has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function createTriggerCampaignModifyRequest(TriggerCampaign $triggerCampaign, array $postActionVars, $action, $ignorePost)
          {
              /** @var TriggerCampaignModel $triggerCampaignModel */
              $triggerCampaignModel = $this->getModel(TriggerCampaignModel::NAME);
      
      
      Severity: Major
      Found in Controller/TriggerCampaignController.php - About 2 hrs to fix

        Method newAction has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function newAction()
            {
                $this->setSession();
        
                if (!$this->get('mautic.security')->isGranted(self::PERMISSIONS['create'])) {
        Severity: Major
        Found in Controller/TriggerCampaignController.php - About 2 hrs to fix

          Function newAction has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              public function newAction()
              {
                  $this->setSession();
          
                  if (!$this->get('mautic.security')->isGranted(self::PERMISSIONS['create'])) {
          Severity: Minor
          Found in Controller/TriggerCampaignController.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 indexAction has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function indexAction($page = 1)
              {
                  //set some permissions
                  $permissions = $this->getPermissions();
                  if (!$permissions[self::PERMISSIONS['view']]) {
          Severity: Minor
          Found in Controller/TriggerCampaignController.php - About 1 hr to fix

            Function createTriggerCampaignModifyRequest has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function createTriggerCampaignModifyRequest(TriggerCampaign $triggerCampaign, array $postActionVars, $action, $ignorePost)
                {
                    /** @var TriggerCampaignModel $triggerCampaignModel */
                    $triggerCampaignModel = $this->getModel(TriggerCampaignModel::NAME);
            
            
            Severity: Minor
            Found in Controller/TriggerCampaignController.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 deleteMultipleCampaigns has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function deleteMultipleCampaigns($postActionVars, &$flashes)
                {
                    /** @var TriggerCampaignModel $triggerCampaignModel */
                    $triggerCampaignModel = $this->getModel(TriggerCampaignModel::NAME);
                    $triggerCampaignIds   = json_decode($this->request->query->get('ids', '{}'));
            Severity: Minor
            Found in Controller/TriggerCampaignController.php - About 1 hr to fix

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

                  public function editAction($objectId, $ignorePost = false, $clone = false)
                  {
                      $this->setSession();
                      $postActionVars = $this->getPostActionVars();
              
              
              Severity: Minor
              Found in Controller/TriggerCampaignController.php - About 1 hr to fix

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

                    public function deleteAction($objectId, $batch = false)
                    {
                        $this->setSession();
                        $page           = $this->session->get(self::SESSION_VARS['page'], 1);
                        $viewParameters = ['page' => $page];
                Severity: Minor
                Found in Controller/TriggerCampaignController.php - About 1 hr to fix

                  Method getTriggerCampaigns has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      protected function getTriggerCampaigns($filter, $start, $limit, $orderBy, $orderByDir)
                  Severity: Minor
                  Found in Controller/TriggerCampaignController.php - About 35 mins to fix

                    Function deleteAction has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function deleteAction($objectId, $batch = false)
                        {
                            $this->setSession();
                            $page           = $this->session->get(self::SESSION_VARS['page'], 1);
                            $viewParameters = ['page' => $page];
                    Severity: Minor
                    Found in Controller/TriggerCampaignController.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 deleteMultipleCampaigns has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function deleteMultipleCampaigns($postActionVars, &$flashes)
                        {
                            /** @var TriggerCampaignModel $triggerCampaignModel */
                            $triggerCampaignModel = $this->getModel(TriggerCampaignModel::NAME);
                            $triggerCampaignIds   = json_decode($this->request->query->get('ids', '{}'));
                    Severity: Minor
                    Found in Controller/TriggerCampaignController.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 $this->delegateView([
                                'viewParameters' => [
                                    'form'          => $this->setFormTheme($form, self::TEMPLATES['form'], self::THEMES['variables']),
                                    'currentListId' => $triggerCampaign->getId(),
                                ],
                    Severity: Major
                    Found in Controller/TriggerCampaignController.php - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status