Method initializeListViewContents
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function initializeListViewContents(App\Request $request, Vtiger_Viewer $viewer)
{
$moduleName = $request->getModule();
$sourceModule = $request->getByType('sourceModule', 2);
$pageNumber = $request->isEmpty('page', true) ? 1 : $request->getInteger('page');
Function initializeListViewContents
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function initializeListViewContents(App\Request $request, Vtiger_Viewer $viewer)
{
$moduleName = $request->getModule();
$sourceModule = $request->getByType('sourceModule', 2);
$pageNumber = $request->isEmpty('page', true) ? 1 : $request->getInteger('page');
- 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
The method postProcess has a boolean flag argument $display, which is a certain sign of a Single Responsibility Principle violation. Open
public function postProcess(App\Request $request, $display = true)
- 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
The method preProcess has a boolean flag argument $display, which is a certain sign of a Single Responsibility Principle violation. Open
public function preProcess(App\Request $request, $display = true)
- 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 '53', column '22'). Open
$pagingModel = new Vtiger_Paging_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
Avoid using static access to class 'App\Config' in method 'initializeListViewContents'. Open
if (App\Config::performance('LISTVIEW_COMPUTE_PAGE_COUNT')) {
- 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\CustomView' in method 'initializeListViewContents'. Open
$orderBy = \App\CustomView::getSortBy($sourceModule);
- 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 'RecycleBin_ListView_Model' in method 'initializeListViewContents'. Open
$listViewModel = RecycleBin_ListView_Model::getInstance($moduleName, $sourceModule);
- 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 'RecycleBin_Module_Model' in method 'initializeListViewContents'. Open
$moduleModel = RecycleBin_Module_Model::getInstance($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 'RecycleBin_Module_Model' in method 'preProcess'. Open
$moduleModel = RecycleBin_Module_Model::getInstance($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
Assigning \Vtiger_Record_Model[]
to property but \RecycleBin_List_View->listViewEntries
is false
Open
$this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('ADVANCED_CONDITIONS', []);
- Exclude checks
Assigning int|null|string
to property but \RecycleBin_List_View->listViewCount
is false
Open
$this->listViewCount = $this->listViewModel->getListViewCount();
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('HEADER_LINKS', ['LIST_VIEW_HEADER' => []]);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('MODULE', $moduleName);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('LISTVIEW_LINKS', $this->listViewLinks);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('PAGE_COUNT', $pagingModel->getPageCount());
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('LISTVIEW_COUNT', $totalCount);
- Exclude checks
Assigning \Vtiger_Field_Model[]
to property but \RecycleBin_List_View->listViewHeaders
is false
Open
$this->listViewHeaders = $listViewModel->getListViewHeaders();
- Exclude checks
Assigning array<int>[]|array{LISTVIEW:array<int>}|array{LISTVIEWBASIC:array<int>}|array{LISTVIEWBASIC:array{}}</int></int></int>
to property but \RecycleBin_List_View->listViewLinks
is false
Open
$this->listViewLinks = $listViewModel->getListViewLinks($linkParams);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('VIEW_MODEL', $this->listViewModel);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('IS_MODULE_DELETABLE', false);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('LISTVIEW_MASSACTIONS', $linkModels['LISTVIEWMASSACTION'] ?? []);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('SEARCH_PARAMS', []);
- Exclude checks
Argument 1 (var)
is false
but \count()
takes \Countable|array
Open
$noOfEntries = \count($this->listViewEntries);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('COLUMN_NAME', $orderBy);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('PAGE_NUMBER', $pageNumber);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('ORDER_BY', $orderBy);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('SOURCE_MODULE', $sourceModule);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('LOCKED_EMPTY_FIELDS', []);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('MODULE_LIST', $moduleModel->getAllModuleList());
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('PAGING_MODEL', $pagingModel);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('IS_MODULE_EDITABLE', false);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('START_PAGIN_FROM', $pagingModel->getStartPagingFrom());
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class RecycleBin_List_View extends Vtiger_List_View
- Exclude checks
The class RecycleBin_List_View is not named in CamelCase. Open
class RecycleBin_List_View extends Vtiger_List_View
{
/** {@inheritdoc} */
public function preProcess(App\Request $request, $display = true)
{
- 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
if (App\Config::performance('LISTVIEW_COMPUTE_PAGE_COUNT')) {
- 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('LOCKED_EMPTY_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
$pagingModel->set('page', $pageNumber);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->listViewCount) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('MODULE', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('LISTVIEW_MASSACTIONS', $linkModels['LISTVIEWMASSACTION'] ?? []);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return array_merge(parent::getFooterScripts($request), $this->checkAndConvertJsScripts([
- 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
$listViewModel->set('orderby', $orderBy);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$totalCount = (int) $this->listViewCount;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('COLUMN_NAME', $orderBy);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$linkModels = $listViewModel->getListViewMassActions($linkParams);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
- 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
$moduleModel = RecycleBin_Module_Model::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('MODULE_LIST', $moduleModel->getAllModuleList());
- 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 initializeListViewContents(App\Request $request, Vtiger_Viewer $viewer)
- 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
if (!empty($orderBy)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('PAGE_NUMBER', $pageNumber);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('ORDER_BY', $orderBy);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('IS_MODULE_DELETABLE', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->preProcessDisplay($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
$moduleModel = RecycleBin_Module_Model::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$orderBy = \App\CustomView::getSortBy($sourceModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->listViewLinks = $listViewModel->getListViewLinks($linkParams);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->listViewCount = $this->listViewModel->getListViewCount();
- 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
$viewer->view('ListViewPostProcess.tpl', $moduleName);
- 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
$sourceModule = current($moduleModel->getAllModuleList())['name'];
- 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
$totalCount = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('PAGING_MODEL', $pagingModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
"modules.{$request->getModule()}.resources.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
$viewer->assign('VIEW_MODEL', $this->listViewModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('SEARCH_PARAMS', []);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('ADVANCED_CONDITIONS', []);
- 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
if (empty($orderBy)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$listViewModel = RecycleBin_ListView_Model::getInstance($moduleName, $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
$viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function postProcess(App\Request $request, $display = true)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('HEADER_LINKS', ['LIST_VIEW_HEADER' => []]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function preProcessTplName(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->listViewLinks) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$orderBy = $request->getArray('orderby', \App\Purifier::STANDARD, [], \App\Purifier::SQL);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($sourceModule)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$pagingModel->set('totalCount', (int) $this->listViewCount);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('PAGE_COUNT', $pagingModel->getPageCount());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('START_PAGIN_FROM', $pagingModel->getStartPagingFrom());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('SOURCE_MODULE', $sourceModule);
- 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::preProcess($request, false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceModule = $request->getByType('sourceModule', 2);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$pagingModel = new Vtiger_Paging_Model();
- 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
$this->listViewHeaders = $listViewModel->getListViewHeaders();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$noOfEntries = \count($this->listViewEntries);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('IS_MODULE_EDITABLE', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'ListViewPreProcess.tpl';
- 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
$pageNumber = $request->isEmpty('page', true) ? 1 : $request->getInteger('page');
- 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
$linkParams = ['MODULE' => $moduleName, 'ACTION' => $request->getByType('view', 1)];
- 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('LISTVIEW_LINKS', $this->listViewLinks);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('LISTVIEW_COUNT', $totalCount);
- 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 preProcess(App\Request $request, $display = true)
- 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
if (!$this->listViewHeaders) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::postProcess($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFooterScripts(App\Request $request)
- Exclude checks
Class name "RecycleBin_List_View" is not in camel caps format Open
class RecycleBin_List_View extends Vtiger_List_View
- Exclude checks