YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/Leads/models/Module.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using undefined variables such as '$selectedTabidsList' which will lead to PHP notices.
Open

                    'tabid' => $selectedTabidsList,

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

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

Avoid using undefined variables such as '$selectedTabidsList' which will lead to PHP notices.
Open

            $selectedTabidsList[] = \App\Module::getModuleId($this->getName());

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

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

Missing class import via use statement (line '49', column '23').
Open

            $dataReader = (new \App\Db\Query())->select(['fieldid'])

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method getFields has a boolean flag argument $blockInstance, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function getFields($blockInstance = false)

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

Avoid using static access to class 'Settings_Leads_Field_Model' in method 'getFields'.
Open

                $fieldModel = Settings_Leads_Field_Model::getInstance($fieldId, $this);

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 '\App\Module' in method 'getMappingSupportedFieldIdsList'.
Open

            $selectedTabidsList[] = \App\Module::getModuleId($this->getName());

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 unused parameters such as '$blockInstance'.
Open

    public function getFields($blockInstance = false)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Reference to undeclared property \Settings_Leads_Module_Model->supportedFieldIdsList
Open

        return $this->supportedFieldIdsList;

Call to undeclared method \App\Db\Query::select
Open

            $dataReader = (new \App\Db\Query())->select(['fieldid'])
Severity: Critical
Found in modules/Settings/Leads/models/Module.php by phan

Saw unextractable annotation for comment '* @return <array> list of field ids'</array>
Open

     * @return <Array> list of field ids

Reference to undeclared property \Settings_Leads_Module_Model->supportedFieldIdsList
Open

            $this->supportedFieldIdsList = [];

Saw unextractable annotation for comment '* @return <array> Restricted ui types'</array>
Open

     * @return <array> Restricted ui types

Reference to undeclared property \Settings_Leads_Module_Model->supportedFieldIdsList
Open

        if (empty($this->supportedFieldIdsList)) {

Argument 2 (module) is \Settings_Leads_Module_Model|\Vtiger_Module_Model|\vtlib\Module|\vtlib\ModuleBasic but \Settings_Leads_Field_Model::getInstance() takes false|string defined at /code/modules/Settings/Leads/models/Field.php:62
Open

                $fieldModel = Settings_Leads_Field_Model::getInstance($fieldId, $this);

Variable $selectedTabidsList was undeclared, but array fields are being added to it.
Open

            $selectedTabidsList[] = \App\Module::getModuleId($this->getName());

Reference to undeclared property \Settings_Leads_Module_Model->supportedFieldIdsList
Open

                $this->supportedFieldIdsList[] = $field;

Saw unextractable annotation for comment '* @return <array> list of field models <settings_leads_field_model>'</settings_leads_field_model></array>
Open

     * @return <Array> list of field models <Settings_Leads_Field_Model>

Saw unextractable annotation for comment '* @return <settings_leads_module_model>'</settings_leads_module_model>
Open

     * @return <Settings_Leads_Module_Model>

Returning type array<string>|array<string></string></string> but getFields() is declared to return \Vtiger_Field_Model[]
Open

        return $this->fields;

Avoid excessively long variable names like $selectedGeneratedTypes. Keep variable name length under 20.
Open

            $selectedGeneratedTypes = [1, 2];

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

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

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

class Settings_Leads_Module_Model extends Vtiger_Module_Model

The class Settings_Leads_Module_Model is not named in CamelCase.
Open

class Settings_Leads_Module_Model extends Vtiger_Module_Model
{
    /**
     * Function to get fields of this model.
     *

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

    /**

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

        if (!$this->fields) {

Line exceeds 120 characters; contains 125 characters
Open

                ->andWhere(['and', ['NOT IN', 'uitype', $restrictedUitypes], ['NOT IN', 'fieldname', $restrictedFieldNames]])

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

                ->createCommand()->query();

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

    public function getRestrictedUitypes()

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

    public function getFields($blockInstance = false)

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

        return $this->fields;

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

            $presense = [0, 2];

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

            $dataReader->close();

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

     *

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

        $moduleModel = parent::getInstance($moduleName);

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

        if (empty($this->supportedFieldIdsList)) {

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

     * Function to get the Restricted Ui Types.

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

        return $moduleModel;

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

                $fieldModel = Settings_Leads_Field_Model::getInstance($fieldId, $this);

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

    }

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

            $dataReader = (new \App\Db\Query())->select(['fieldid'])

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

        foreach ($objectProperties as $properName => $propertyValue) {

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

        }

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

            $fieldModelsList = [];

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

    public function getMappingSupportedFieldIdsList()

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

        return [4, 51, 52, 53, 57, 58, 69, 70];

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

    {

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

            $moduleModel->{$properName} = $propertyValue;

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 mixed $blockInstance

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

                ->where([

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

            $this->supportedFieldIdsList = [];

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

            while ($field = $dataReader->readColumn(0)) {

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

     * @return <array> Restricted ui types

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

        $moduleModel = new self();

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

     */

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

     * @return <Array> list of field ids

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

                    'tabid' => $selectedTabidsList,

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

                $this->supportedFieldIdsList[] = $field;

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

     * Function to get instance of module.

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

     * @return <Settings_Leads_Module_Model>

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

     */

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

            $selectedGeneratedTypes = [1, 2];

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

     *

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

                    'presence' => $presense,

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

     *

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

     * @return <Array> list of field models <Settings_Leads_Field_Model>

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

     * Function to get mapping supported field ids list.

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

            $restrictedUitypes = $this->getRestrictedUitypes();

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

    {

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

        $objectProperties = get_object_vars($moduleModel);

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

            $this->fields = $fieldModelsList;

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

        }

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

            $restrictedFieldNames = ['campaignrelstatus'];

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

                $fieldModelsList[$fieldModel->getFieldDataType()][$fieldId] = $fieldModel;

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

     * @param string $moduleName

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

            $fieldIds = $this->getMappingSupportedFieldIdsList();

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

            }

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

                ->andWhere(['and', ['NOT IN', 'uitype', $restrictedUitypes], ['NOT IN', 'fieldname', $restrictedFieldNames]])

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

        return $this->supportedFieldIdsList;

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

     */

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

     * Function to get fields of this model.

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

     */

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

                    'generatedtype' => $selectedGeneratedTypes,

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

            foreach ($fieldIds as $fieldId) {

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

    {

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

            $selectedTabidsList[] = \App\Module::getModuleId($this->getName());

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

                ->from('vtiger_field')

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 static function getInstance($moduleName)

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

    }

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

class Settings_Leads_Module_Model extends Vtiger_Module_Model

There are no issues that match your filters.

Category
Status