Function getQuery
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getQuery()
{
$moduleName = $this->relationModel->getParentModuleModel()->getName();
$fields = $this->relationModel->getRelationModuleModel()->getReferenceFieldsForModule($moduleName);
if (!$fields) {
- 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 '24', column '14'). Open
throw new \App\Exceptions\AppException('ERR_ILLEGAL_VALUE');
- 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
Avoid using static access to class '\App\Log' in method 'getQuery'. Open
\App\Log::error('No relation field | Relation name:' . $this->relationModel->get('name') . ' | Relation id:' . $this->relationModel->getId(), __METHOD__);
- Read upRead up
- Exclude checks
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 'Calendar_Module_Model' in method 'getQuery'. Open
$queryGenerator->addCondition('activitystatus', implode('##', Calendar_Module_Model::getComponentActivityStateLabel('history')), 'e');
- Read upRead up
- Exclude checks
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\Request' in method 'getQuery'. Open
switch (\App\Request::_get('time')) {
- Read upRead up
- Exclude checks
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 'Calendar_Module_Model' in method 'getQuery'. Open
$queryGenerator->addCondition('activitystatus', implode('##', Calendar_Module_Model::getComponentActivityStateLabel('current')), 'e');
- Read upRead up
- Exclude checks
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 addCondition
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->addCondition('activitystatus', implode('##', Calendar_Module_Model::getComponentActivityStateLabel('history')), 'e');
- Exclude checks
Call to method error
from undeclared class \App\Log
Open
\App\Log::error('No relation field | Relation name:' . $this->relationModel->get('name') . ' | Relation id:' . $this->relationModel->getId(), __METHOD__);
- Exclude checks
Call to method addCondition
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->addCondition('activitystatus', implode('##', Calendar_Module_Model::getComponentActivityStateLabel('current')), 'e');
- Exclude checks
Call to method addNativeCondition
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->addNativeCondition($conditions);
- Exclude checks
Argument 1 (moduleName)
is false
but \Vtiger_Module_Model::getReferenceFieldsForModule()
takes string
defined at /code/modules/Vtiger/models/Module.php:557
Open
$fields = $this->relationModel->getRelationModuleModel()->getReferenceFieldsForModule($moduleName);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Calendar_GetActivities_Relation extends Vtiger_GetDependentsList_Relation
- Exclude checks
The class Calendar_GetActivities_Relation is not named in CamelCase. Open
class Calendar_GetActivities_Relation extends Vtiger_GetDependentsList_Relation
{
/** {@inheritdoc} */
public function getQuery()
{
- 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
$moduleName = $this->relationModel->getParentModuleModel()->getName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$conditions = ['or'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->addCondition('activitystatus', implode('##', Calendar_Module_Model::getComponentActivityStateLabel('current')), 'e');
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
$queryGenerator->addCondition('activitystatus', implode('##', Calendar_Module_Model::getComponentActivityStateLabel('history')), 'e');
- Exclude checks
Line exceeds 120 characters; contains 166 characters Open
\App\Log::error('No relation field | Relation name:' . $this->relationModel->get('name') . ' | Relation id:' . $this->relationModel->getId(), __METHOD__);
- 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
$queryGenerator->addNativeCondition($conditions);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch (\App\Request::_get('time')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'current':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'history':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
$queryGenerator->addCondition('activitystatus', implode('##', Calendar_Module_Model::getComponentActivityStateLabel('current')), 'e');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('ERR_ILLEGAL_VALUE');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$fields) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::error('No relation field | Relation name:' . $this->relationModel->get('name') . ' | Relation id:' . $this->relationModel->getId(), __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$conditions[] = ["{$fieldModel->getTableName()}.{$fieldModel->getColumnName()}" => $this->relationModel->get('parentRecord')->getId()];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Line exceeds 120 characters; contains 147 characters Open
$conditions[] = ["{$fieldModel->getTableName()}.{$fieldModel->getColumnName()}" => $this->relationModel->get('parentRecord')->getId()];
- 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 getQuery()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fields as $fieldModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->addCondition('activitystatus', implode('##', Calendar_Module_Model::getComponentActivityStateLabel('history')), 'e');
- 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
$fields = $this->relationModel->getRelationModuleModel()->getReferenceFieldsForModule($moduleName);
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Class name "Calendar_GetActivities_Relation" is not in camel caps format Open
class Calendar_GetActivities_Relation extends Vtiger_GetDependentsList_Relation
- Exclude checks