Function getFields
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getFields(bool $editable = false)
{
$fields = [];
$sourceModule = $this->relationModel->getParentModuleModel();
if ('Occurrences' !== $sourceModule->getName()) {
- 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 '50', column '17'). Open
$field = new \Vtiger_Field_Model();
- 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
Missing class import via use statement (line '69', column '21'). Open
$subQuery = (new \App\QueryGenerator('ModComments'))->setFields(['id'])->setSourceRecord($parentId)->createQuery()->select((new \yii\db\Expression('COUNT(1)')))->andWhere(['parent_comments' => new yii\db\Expression('id')])->groupBy(['parent_comments']);
- 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
Missing class import via use statement (line '69', column '132'). Open
$subQuery = (new \App\QueryGenerator('ModComments'))->setFields(['id'])->setSourceRecord($parentId)->createQuery()->select((new \yii\db\Expression('COUNT(1)')))->andWhere(['parent_comments' => new yii\db\Expression('id')])->groupBy(['parent_comments']);
- 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
The method getFields has a boolean flag argument $editable, which is a certain sign of a Single Responsibility Principle violation. Open
public function getFields(bool $editable = false)
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '69', column '201'). Open
$subQuery = (new \App\QueryGenerator('ModComments'))->setFields(['id'])->setSourceRecord($parentId)->createQuery()->select((new \yii\db\Expression('COUNT(1)')))->andWhere(['parent_comments' => new yii\db\Expression('id')])->groupBy(['parent_comments']);
- 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
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$subQuery = (new \App\QueryGenerator('ModComments'))->setFields(['id'])->setSourceRecord($parentId)->createQuery()->select((new \yii\db\Expression('COUNT(1)')))->andWhere(['parent_comments' => new yii\db\Expression('id')])->groupBy(['parent_comments']);
- Exclude checks
Call to method __construct
from undeclared class \yii\db\Expression
Open
$subQuery = (new \App\QueryGenerator('ModComments'))->setFields(['id'])->setSourceRecord($parentId)->createQuery()->select((new \yii\db\Expression('COUNT(1)')))->andWhere(['parent_comments' => new yii\db\Expression('id')])->groupBy(['parent_comments']);
- Exclude checks
Call to method addCondition
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->addCondition('related_to', $parentId, 'eid');
- Exclude checks
Call to method setCustomColumn
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setCustomColumn([$fieldName => $subQuery]);
- Exclude checks
Call to method __construct
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$subQuery = (new \App\QueryGenerator('ModComments'))->setFields(['id'])->setSourceRecord($parentId)->createQuery()->select((new \yii\db\Expression('COUNT(1)')))->andWhere(['parent_comments' => new yii\db\Expression('id')])->groupBy(['parent_comments']);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class ModComments_GetRelatedRecord_Relation extends \App\Relation\RelationAbstraction
- Exclude checks
The class ModComments_GetRelatedRecord_Relation is not named in CamelCase. Open
class ModComments_GetRelatedRecord_Relation extends \App\Relation\RelationAbstraction
{
/**
* Field custom list.
*
- 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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$subQuery = (new \App\QueryGenerator('ModComments'))->setFields(['id'])->setSourceRecord($parentId)->createQuery()->select((new \yii\db\Expression('COUNT(1)')))->andWhere(['parent_comments' => new yii\db\Expression('id')])->groupBy(['parent_comments']);
- 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
$field = new \Vtiger_Field_Model();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Field custom list.
- 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->setCustomColumn([$fieldName => $subQuery]);
- 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
$sourceModule = $this->relationModel->getRelationModuleModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$editable || !$field->isEditableReadOnly()) {
- 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
$parentId = $this->relationModel->get('parentRecord')->getId();
- 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 getFields(bool $editable = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields[$fieldName] = $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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function delete(int $sourceRecordId, int $destinationRecordId): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- 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 $customFields = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'uitype' => 7,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fields;
- 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 false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceModule = $this->relationModel->getParentModuleModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->customFields as $fieldName => $data) {
- 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
$queryGenerator = $this->relationModel->getQueryGenerator();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('Occurrences' !== $sourceModule->getName()) {
- 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 getQuery()
- 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function transfer(int $relatedRecordId, int $fromRecordId, int $toRecordId): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'label' => 'LBL_CHILDREN_COUNT',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$field->set('name', $fieldName)->set('column', $fieldName)->set('table', 'vtiger_modcomments')->set('fromOutsideList', true)->setModule($sourceModule);
- 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 265 characters Open
$subQuery = (new \App\QueryGenerator('ModComments'))->setFields(['id'])->setSourceRecord($parentId)->createQuery()->select((new \yii\db\Expression('COUNT(1)')))->andWhere(['parent_comments' => new yii\db\Expression('id')])->groupBy(['parent_comments']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'children_count' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Vtiger_Relation_Model::RELATION_O2M;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $editable
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function create(int $sourceRecordId, int $destinationRecordId): bool
- 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 getRelationType(): int
- Exclude checks
Line exceeds 120 characters; contains 163 characters Open
$field->set('name', $fieldName)->set('column', $fieldName)->set('table', 'vtiger_modcomments')->set('fromOutsideList', true)->setModule($sourceModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->addCondition('related_to', $parentId, 'eid');
- 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
$field->set($key, $value);
- 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 (array_keys($this->customFields) as $fieldName) {
- 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
- 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Field list.
- 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
$fields = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($data as $key => $value) {
- 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
/** {@inheritdoc} */
- Exclude checks
Class name "ModComments_GetRelatedRecord_Relation" is not in camel caps format Open
class ModComments_GetRelatedRecord_Relation extends \App\Relation\RelationAbstraction
- Exclude checks