YetiForceCompany/YetiForceCRM

View on GitHub
modules/OSSMailScanner/scanneractions/BindCampaigns.php

Summary

Maintainability
A
35 mins
Test Coverage
F
0%

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

    public function process(OSSMail_Mail_Model $mail)
    {
        $this->mail = $mail;
        $campaignIds = $this->findAndBind();
        if (0 == $mail->get('type') && false !== $campaignIds && 0 != $campaignIds) {
Severity: Minor
Found in modules/OSSMailScanner/scanneractions/BindCampaigns.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 using static access to class 'OSSMailScanner_Record_Model' in method 'process'.
Open

            $crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsCcaddress);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'OSSMailScanner_Record_Model' in method 'process'.
Open

            $crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsBccaddress);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'OSSMailScanner_Record_Model' in method 'process'.
Open

            $crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsToaddress);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Call to method mergeArray from undeclared class \OSSMailScanner_Record_Model
Open

            $crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsBccaddress);

Call to method mergeArray from undeclared class \OSSMailScanner_Record_Model
Open

            $crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsCcaddress);

Call to method mergeArray from undeclared class \OSSMailScanner_Record_Model
Open

            $crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsToaddress);

Call to undeclared method \App\Db::createCommand
Open

            $dbCommand = \App\Db::getInstance()->createCommand();

Avoid excessively long class names like OSSMailScanner_BindCampaigns_ScannerAction. Keep class name length under 40.
Open

class OSSMailScanner_BindCampaigns_ScannerAction extends OSSMailScanner_PrefixScannerAction_Model
{
    /**
     * Module name.
     *

LongClassName

Since: 2.9

Detects when classes or interfaces are declared with excessively long names.

Example

class ATooLongClassNameThatHintsAtADesignProblem {

}

interface ATooLongInterfaceNameThatHintsAtADesignProblem {

}

Source https://phpmd.org/rules/naming.html#longclassname

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class OSSMailScanner_BindCampaigns_ScannerAction extends OSSMailScanner_PrefixScannerAction_Model

The class OSSMailScanner_BindCampaigns_ScannerAction is not named in CamelCase.
Open

class OSSMailScanner_BindCampaigns_ScannerAction extends OSSMailScanner_PrefixScannerAction_Model
{
    /**
     * Module name.
     *

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Spaces must be used to indent lines; tabs are not allowed
Open

    public $tableColumn = 'campaign_no';

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * Table column.

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

                }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var string

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

            $crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsToaddress);

Spaces must be used to indent lines; tabs are not allowed
Open

    public $moduleName = 'Campaigns';

Spaces must be used to indent lines; tabs are not allowed
Open

        $campaignIds = $this->findAndBind();

Spaces must be used to indent lines; tabs are not allowed
Open

            $crmIds = [];

Spaces must be used to indent lines; tabs are not allowed
Open

            $dbCommand = \App\Db::getInstance()->createCommand();

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        if (0 == $mail->get('type') && false !== $campaignIds && 0 != $campaignIds) {

Spaces must be used to indent lines; tabs are not allowed
Open

            $crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsBccaddress);

Line exceeds 120 characters; contains 160 characters
Open

                    $dbCommand->update('vtiger_campaign_records', ['campaignrelstatusid' => 1], ['campaignid' => $campaignId, 'crmid' => $recordId])->execute();

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param OSSMail_Mail_Model $mail

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return array

Spaces must be used to indent lines; tabs are not allowed
Open

                foreach ($crmIds as $recordId) {

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

    public function process(OSSMail_Mail_Model $mail)

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var string

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->mail = $mail;

Spaces must be used to indent lines; tabs are not allowed
Open

            $crmidsToaddress = $mail->findEmailAddress('to_email', false, true);

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Module name.

Spaces must be used to indent lines; tabs are not allowed
Open

     * Table name.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

                    $dbCommand->update('vtiger_campaign_records', ['campaignrelstatusid' => 1], ['campaignid' => $campaignId, 'crmid' => $recordId])->execute();

Spaces must be used to indent lines; tabs are not allowed
Open

        return $campaignIds;

Spaces must be used to indent lines; tabs are not allowed
Open

            $crmidsCcaddress = $mail->findEmailAddress('cc_email', false, true);

Spaces must be used to indent lines; tabs are not allowed
Open

            $crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsCcaddress);

Spaces must be used to indent lines; tabs are not allowed
Open

    public $tableName = 'vtiger_campaign';

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var string

Spaces must be used to indent lines; tabs are not allowed
Open

            $crmidsBccaddress = $mail->findEmailAddress('bcc_email', false, true);

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     * Process.

Spaces must be used to indent lines; tabs are not allowed
Open

            foreach ($campaignIds as $campaignId) {

Class name "OSSMailScanner_BindCampaigns_ScannerAction" is not in camel caps format
Open

class OSSMailScanner_BindCampaigns_ScannerAction extends OSSMailScanner_PrefixScannerAction_Model

There are no issues that match your filters.

Category
Status