Function initializeContent
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function initializeContent(App\Request $request)
{
$count = 0;
$recordModels = $fields = [];
$queryGenerator = Vtiger_Mass_Action::getQuery($request);
- 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 '21', column '14'). Open
throw new \App\Exceptions\NoPermitted('ERR_NOT_ACCESSIBLE', 406);
- 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\Language' in method 'getPageTitle'. Open
return \App\Language::translate('LBL_MERGE_RECORDS_IN', $moduleName) . ': ' . \App\Language::translate($moduleName, $moduleName);
- 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\Config' in method 'initializeContent'. Open
$dataReader = $query->limit(\App\Config::performance('MAX_MERGE_RECORDS'))->createCommand()->query();
- 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\Language' in method 'getPageTitle'. Open
return \App\Language::translate('LBL_MERGE_RECORDS_IN', $moduleName) . ': ' . \App\Language::translate($moduleName, $moduleName);
- 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\Privilege' in method 'checkPermission'. Open
if (!\App\Privilege::isPermitted($request->getModule(), 'Merge')) {
- 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 'Vtiger_Mass_Action' in method 'initializeContent'. Open
$queryGenerator = Vtiger_Mass_Action::getQuery($request);
- 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 assigning values to variables in if clauses and the like (line '76', column '8'). Open
public function postProcessAjax(App\Request $request)
{
$viewer = $this->getViewer($request);
if (($var = $viewer->getTemplateVars('RECORD_MODELS')) && \count($var) > 1) {
$viewer->assign('BTN_SUCCESS', 'LBL_MERGE');
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Call to method getModuleModel
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$moduleModel = $queryGenerator->getModuleModel();
- Exclude checks
Call to method getModuleFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
foreach ($queryGenerator->getModuleFields() as $field) {
- Exclude checks
Reference to undeclared property \Vtiger_MergeRecords_View->modalIcon
Open
$this->modalIcon = 'fa fa-code';
- Exclude checks
Reference to undeclared property \Vtiger_MergeRecords_View->dangerBtn
Open
$viewer->assign('BTN_DANGER', $this->dangerBtn);
- Exclude checks
Call to method setField
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setField('id');
- Exclude checks
Class extends undeclared class \App\Controller\Modal
Open
class Vtiger_MergeRecords_View extends \App\Controller\Modal
- Exclude checks
Call to undeclared method \Vtiger_MergeRecords_View::getViewer
Open
$viewer = $this->getViewer($request);
- Exclude checks
Reference to undeclared class \App\Controller\Modal
Open
parent::preProcessAjax($request);
- Exclude checks
Call to method createQuery
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$query = $queryGenerator->createQuery();
- Exclude checks
Call to undeclared method \Vtiger_MergeRecords_View::getViewer
Open
$viewer = $this->getViewer($request);
- Exclude checks
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setFields($fields);
- Exclude checks
Call to undeclared method \Vtiger_MergeRecords_View::getViewer
Open
$viewer = $this->getViewer($request);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Vtiger_MergeRecords_View extends \App\Controller\Modal
- Exclude checks
The class Vtiger_MergeRecords_View is not named in CamelCase. Open
class Vtiger_MergeRecords_View extends \App\Controller\Modal
{
/** {@inheritdoc} */
public function checkPermission(App\Request $request)
{
- 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
$queryGenerator = Vtiger_Mass_Action::getQuery($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModels[$row['id']] = $moduleModel->getRecordFromArray($row);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('COUNT', $count);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\App\Privilege::isPermitted($request->getModule(), 'Merge')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\NoPermitted('ERR_NOT_ACCESSIBLE', 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModels = $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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('BTN_DANGER', $this->dangerBtn);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function checkPermission(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = $queryGenerator->getModuleModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('FIELDS', $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
public function postProcessAjax(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('Modals/Footer.tpl', $request->getModule());
- 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->setFields($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
$viewer->assign('RECORD_MODELS', $recordModels);
- 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($field->isEditable()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = $query->limit(\App\Config::performance('MAX_MERGE_RECORDS'))->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- 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
$viewer = $this->getViewer($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->modalIcon = 'fa fa-code';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->initializeContent($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('MergeRecords.tpl', $request->getModule());
- 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::preProcessAjax($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($queryGenerator) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
return \App\Language::translate('LBL_MERGE_RECORDS_IN', $moduleName) . ': ' . \App\Language::translate($moduleName, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function preProcessAjax(App\Request $request)
- 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
/** {@inheritdoc} */
- 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
$viewer = $this->getViewer($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$count = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->setField('id');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = $queryGenerator->createQuery();
- 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
$moduleName = $request->getModule();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Language::translate('LBL_MERGE_RECORDS_IN', $moduleName) . ': ' . \App\Language::translate($moduleName, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $modalSize = 'modal-fullscreen';
- 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 process(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer = $this->getViewer($request);
- 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
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
public function initializeContent(App\Request $request)
- 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 ($queryGenerator->getModuleFields() as $field) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields[] = $field->getName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$count = $query->count();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (($var = $viewer->getTemplateVars('RECORD_MODELS')) && \count($var) > 1) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('BTN_SUCCESS', 'LBL_MERGE');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getPageTitle(App\Request $request)
- Exclude checks
Class name "Vtiger_MergeRecords_View" is not in camel caps format Open
class Vtiger_MergeRecords_View extends \App\Controller\Modal
- Exclude checks