Showing 31 of 33 total issues
File TriggerCampaignController.php
has 463 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
namespace MauticPlugin\LeuchtfeuerPrintmailingBundle\Controller;
use Doctrine\ORM\EntityNotFoundException;
File PrintmailingService.php
has 427 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
namespace MauticPlugin\LeuchtfeuerPrintmailingBundle\Service;
use GuzzleHttp\Client;
Method buildForm
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventSubscriber(new CleanFormSubscriber(['description' => 'html']));
$builder->addEventSubscriber(new FormExitSubscriber(TriggerCampaignModel::NAME, $options));
TriggerCampaignController
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class TriggerCampaignController extends AbstractFormController
{
public const PERMISSIONS = [
'create' => 'printmailing:campaigns:create',
'delete' => 'printmailing:campaigns:delete',
Method createTriggerCampaignModifyRequest
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function createTriggerCampaignModifyRequest(TriggerCampaign $triggerCampaign, array $postActionVars, $action, $ignorePost)
{
/** @var TriggerCampaignModel $triggerCampaignModel */
$triggerCampaignModel = $this->getModel(TriggerCampaignModel::NAME);
TriggerCampaign
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class TriggerCampaign extends FormEntity
{
public const ALLOWED_TYPES = [
'string' => 'plugin.printmailing.form.types.string',
'integer' => 'plugin.printmailing.form.types.integer',
PrintmailingService
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class PrintmailingService
{
public const LOCALE = 'de';
public const SESSION_KEY = 'printmailing';
Method buildForm
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('printmailing_masId', IntegerType::class, [
'label' => 'plugin.printmailing.form.masId',
'label_attr' => [
Method newAction
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function newAction()
{
$this->setSession();
if (!$this->get('mautic.security')->isGranted(self::PERMISSIONS['create'])) {
Function printmailingOnLoad
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Mautic.printmailingOnLoad = function (container) {
var prefix = 'trigger_campaign';
var parent = mQuery('.dynamic-content-variable, .dwc-variable');
if (parent.length) {
prefix = parent.attr('id');
Function newAction
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
public function newAction()
{
$this->setSession();
if (!$this->get('mautic.security')->isGranted(self::PERMISSIONS['create'])) {
- 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 addPrintmailingVariable
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Mautic.addPrintmailingVariable = function (elId, elObj) {
var variableId = '#available_' + elObj + '_' + elId,
variableOption = mQuery(variableId),
label = variableOption.text(),
variableNum = parseInt(mQuery('.available-variables').data('index')),
Method indexAction
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function indexAction($page = 1)
{
//set some permissions
$permissions = $this->getPermissions();
if (!$permissions[self::PERMISSIONS['view']]) {
Function createTriggerCampaignModifyRequest
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function createTriggerCampaignModifyRequest(TriggerCampaign $triggerCampaign, array $postActionVars, $action, $ignorePost)
{
/** @var TriggerCampaignModel $triggerCampaignModel */
$triggerCampaignModel = $this->getModel(TriggerCampaignModel::NAME);
- 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 reorderTriggerCampaignVariables
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Mautic.reorderTriggerCampaignVariables = function () {
// Update the filter numbers sot that they are ordered correctly when processed and grouped server side
var counter = 0,
prefix = 'trigger_campaign',
parent = mQuery('.dynamic-content-variable, .dwc-variable');
Method deleteMultipleCampaigns
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function deleteMultipleCampaigns($postActionVars, &$flashes)
{
/** @var TriggerCampaignModel $triggerCampaignModel */
$triggerCampaignModel = $this->getModel(TriggerCampaignModel::NAME);
$triggerCampaignIds = json_decode($this->request->query->get('ids', '{}'));
Method onPluginUpdate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function onPluginUpdate(Plugin $plugin, MauticFactory $factory, $metadata = null, Schema $installedSchema = null)
{
$database = $factory->getDatabase();
$platform = $database->getDatabasePlatform()->getName();
$queries = [];
Method editAction
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function editAction($objectId, $ignorePost = false, $clone = false)
{
$this->setSession();
$postActionVars = $this->getPostActionVars();
Method onCampaignTriggerAction
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function onCampaignTriggerAction(CampaignExecutionEvent $event)
{
if (false === $event->checkContext('plugin.printmailing.campaign')) {
return;
}
Method dispatchEvent
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function dispatchEvent($action, &$entity, $isNew = false, Event $event = null)
{
if (!$entity instanceof TriggerCampaign) {
throw new MethodNotAllowedHttpException(['TriggerCampaign']);
}