Showing 33 of 33 total issues
File TriggerCampaignController.php
has 463 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace MauticPlugin\LeuchtfeuerPrintmailingBundle\Controller;
use Doctrine\ORM\EntityNotFoundException;
File PrintmailingService.php
has 427 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace MauticPlugin\LeuchtfeuerPrintmailingBundle\Service;
use GuzzleHttp\Client;
Method buildForm
has 91 lines of code (exceeds 25 allowed). Consider refactoring. 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
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
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
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
class PrintmailingService
{
public const LOCALE = 'de';
public const SESSION_KEY = 'printmailing';
Method buildForm
has 57 lines of code (exceeds 25 allowed). Consider refactoring. 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
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
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
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function createVariableDefinitions(TriggerCampaign $triggerCampaign): void
{
$response = $this->client->request(
'POST',
sprintf('/post/advertising/print-mailing/automation/v1/mailings/%d/variabledefinitions', $triggerCampaign->getMailingId()),
- Read upRead up
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 118.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function updateCampaignVariable(TriggerCampaign $triggerCampaign): void
{
$response = $this->client->request(
'PUT',
sprintf('/post/advertising/print-mailing/automation/v1/mailings/%d/variabledefinitions', $triggerCampaign->getMailingId()),
- Read upRead up
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 118.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function addPrintmailingVariable
has 42 lines of code (exceeds 25 allowed). Consider refactoring. 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
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
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
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
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
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
public function editAction($objectId, $ignorePost = false, $clone = false)
{
$this->setSession();
$postActionVars = $this->getPostActionVars();