Function getConditionBuilderStructure
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function getConditionBuilderStructure(Vtiger_Module_Model $moduleModel, ?string $skipfield): array
{
$structure = [];
$blockModelList = $moduleModel->getBlocks();
foreach ($blockModelList as $blockLabel => $blockModel) {
- 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 getListFields
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getListFields(): array
{
if (!isset($this->listFieldModels)) {
foreach (parent::getListFields() as $fieldName => $fieldModel) {
if ('tabid' !== $fieldName) {
- 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
Missing class import via use statement (line '75', column '22'). Open
$dataReader = (new \App\Db\Query())->select(['vtiger_field.tabid', 'vtiger_tab.tablabel', 'name' => 'vtiger_tab.name'])->from('vtiger_field')
- Read upRead up
- Exclude checks
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
Define a constant instead of duplicating this literal "tabid" 5 times. Open
'tabid' => 'LBL_MODULE',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "vtiger_field.tabid" 3 times. Open
$dataReader = (new \App\Db\Query())->select(['vtiger_field.tabid', 'vtiger_tab.tablabel', 'name' => 'vtiger_tab.name'])->from('vtiger_field')
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Call to undeclared method \App\Db\Query::select
Open
$dataReader = (new \App\Db\Query())->select(['vtiger_field.tabid', 'vtiger_tab.tablabel', 'name' => 'vtiger_tab.name'])->from('vtiger_field')
- Exclude checks
Return type of getConditionBuilderStructure()
is undeclared type \voiarrayd
Open
public static function getConditionBuilderStructure(Vtiger_Module_Model $moduleModel, ?string $skipfield): array
- Exclude checks
Reference to undeclared property \Settings_PickListDependency_Module_Model->listFieldModels
Open
return $this->listFieldModels;
- Exclude checks
Doc-block of getConditionBuilderStructure
contains declared return type \voiarrayd
which is incompatible with the return type array
declared in the signature Open
* @return voiarrayd
- Exclude checks
Reference to undeclared property \Settings_PickListDependency_Module_Model->listFieldModels
Open
if (!isset($this->listFieldModels)) {
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_PickListDependency_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 13 and the first side effect is on line 11. Open
<?php
- Exclude checks
The class Settings_PickListDependency_Module_Model is not named in CamelCase. Open
class Settings_PickListDependency_Module_Model extends Settings_Vtiger_Module_Model
{
/** @var string Module name. */
public $name = 'PickListDependency';
/** @var string Module name. */
- Read upRead up
- Exclude checks
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
/** @var string Module name. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Module name. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $baseIndex = 'id';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $listFields = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getDefaultUrl()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'source_field' => 'LBL_SOURCE_FIELD'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Base table. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string - url
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tabId = $row['tabid'] = (int) $row['tabid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->editFields as $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string|null $skipfield
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $baseTable = 's_#__picklist_dependency';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Name fields. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (parent::getListFields() as $fieldName => $fieldModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $nameFields = ['name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getPicklistSupportedModules(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_tab', 'vtiger_field.tabid = vtiger_tab.tabid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->andWhere(['not', ['vtiger_field.block' => null]])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the url for default view of the module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'index.php?module=PickListDependency&parent=Settings&view=List';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$structure = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockModelList = $moduleModel->getBlocks();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $parent = 'Settings';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $editFields = ['tabid', 'source_field'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->having(['>', 'count(*)', 1])->distinct('vtiger_field.tabid')->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $structure;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Vtiger_Module_Model $moduleModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string - url
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->groupBy('vtiger_field.tabid, vtiger_tab.tablabel, vtiger_tab.name')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $name = 'PickListDependency';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tabid' => 'LBL_MODULE',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Name fields. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getCreateRecordUrl()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get picklist supported modules.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->andWhere(['<>', 'vtiger_field.tabid', 29])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
if ($fieldName !== $skipfield && \in_array($fieldModel->getUIType(), [15, 16]) && $fieldModel->isActiveField()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getListFields(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->set('sort', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['uitype' => [15, 16], 'vtiger_field.displaytype' => 1, 'vtiger_field.presence' => [0, 2]])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$structure[$fieldName] = $fieldModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return voiarrayd
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($blockModelList as $blockLabel => $blockModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($blockModel->getFields() as $fieldName => $fieldModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldName !== $skipfield && \in_array($fieldModel->getUIType(), [15, 16]) && $fieldModel->isActiveField()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Base index. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array List fields. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get structure fields.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getConditionBuilderStructure(Vtiger_Module_Model $moduleModel, ?string $skipfield): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'index.php?parent=Settings&module=PickListDependency&view=Edit';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('tabid' !== $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = (new \App\Db\Query())->select(['vtiger_field.tabid', 'vtiger_tab.tablabel', 'name' => 'vtiger_tab.name'])->from('vtiger_field')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = $recordModel->getFieldInstanceByName($fieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$structure[$blockLabel][$fieldName] = $fieldModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $structure;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$structure = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the url for Adding Dependency.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->listFieldModels)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getEditViewStructure($recordModel): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Settings_PickListDependency_Record_Model|null $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get condition builder structure.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 149 characters Open
$dataReader = (new \App\Db\Query())->select(['vtiger_field.tabid', 'vtiger_tab.tablabel', 'name' => 'vtiger_tab.name'])->from('vtiger_field')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->andWhere(['vtiger_tab.presence' => 0])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->listFieldModels;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules[$tabId] = $row;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $modules;
- Exclude checks
Class name "Settings_PickListDependency_Module_Model" is not in camel caps format Open
class Settings_PickListDependency_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks