YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
35 mins
Test Coverage
F
0%

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

    public function getFieldDataType()
    {
        $fieldDataType = '';
        $uitype = $this->get('uitype');
        if ('9' == $uitype) {
Severity: Minor
Found in modules/Settings/Leads/models/Field.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

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

    public static function getInstance($value, $module = 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

Saw unextractable annotation for comment '* @param <string> $value'</string>
Open

     * @param <String/Integer> $value

Saw unextractable annotation for comment '* @return <settings_leads_field_model> field model'</settings_leads_field_model>
Open

     * @return <Settings_Leads_Field_Model> field model

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

     * @return <Settings_Leads_Field_Model>

Default value for string $module can't be false
Open

    public static function getInstance($value, $module = false)

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

class Settings_Leads_Field_Model extends Vtiger_Field_Model

The class Settings_Leads_Field_Model is not named in CamelCase.
Open

class Settings_Leads_Field_Model extends Vtiger_Field_Model
{
    /**
     * Function to get field data type.
     *

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

                case 'multipicklist':

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

     * @param string           $module

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

    public static function getInstance($value, $module = false)

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

        $objectProperties = get_object_vars($fieldModel);

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

            switch ($fieldDataType) {

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

            $fieldModel->{$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

        if ('9' == $uitype) {

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

        return new self();

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

    public static function getCleanInstance()

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

        $uitype = $this->get('uitype');

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

     * @return <Settings_Leads_Field_Model> 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

        if (!$fieldDataType) {

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

            $fieldDataType = parent::getFieldDataType();

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

                case 'text':

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

                    break;

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

        return $fieldModel;

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

        $fieldModel = parent::getInstance($value, $module);

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

                    $fieldDataType = 'textArea';

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

     * Function to get clean instance.

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

        $fieldModel = new self();

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

     * @return string data type

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

            $fieldDataType = 'percent';

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

                    break;

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

                    break;

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

    public function getFieldDataType()

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

                    $fieldDataType = 'multiSelectCombo';

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

                default:

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

     * @return <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

                case 'boolean':

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

                    break;

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

        return $fieldDataType;

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

     * Function to get instance.

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 field data type.

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 <String/Integer> $value

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

        $fieldDataType = '';

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

                    $fieldDataType = 'checkBox';

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

class Settings_Leads_Field_Model extends Vtiger_Field_Model

There are no issues that match your filters.

Category
Status