YetiForceCompany/YetiForceCRM

View on GitHub
modules/RecycleBin/views/List.php

Summary

Maintainability
A
2 hrs
Test Coverage
F
0%

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');
Severity: Major
Found in modules/RecycleBin/views/List.php - About 2 hrs to fix

    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');
    Severity: Minor
    Found in modules/RecycleBin/views/List.php - About 45 mins to fix

    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)
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phpmd

    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)
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phpmd

    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();
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phpmd

    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')) {
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phpmd

    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);
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phpmd

    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);
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phpmd

    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);
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phpmd

    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);
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phpmd

    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);
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('ADVANCED_CONDITIONS', []);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Assigning int|null|string to property but \RecycleBin_List_View->listViewCount is false
    Open

                    $this->listViewCount = $this->listViewModel->getListViewCount();
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('HEADER_LINKS', ['LIST_VIEW_HEADER' => []]);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('MODULE', $moduleName);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('LISTVIEW_LINKS', $this->listViewLinks);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('PAGE_COUNT', $pagingModel->getPageCount());
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('LISTVIEW_COUNT', $totalCount);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Assigning \Vtiger_Field_Model[] to property but \RecycleBin_List_View->listViewHeaders is false
    Open

                $this->listViewHeaders = $listViewModel->getListViewHeaders();
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phan

    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);
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('VIEW_MODEL', $this->listViewModel);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('IS_MODULE_DELETABLE', false);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('LISTVIEW_MASSACTIONS', $linkModels['LISTVIEWMASSACTION'] ?? []);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('SEARCH_PARAMS', []);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Argument 1 (var) is false but \count() takes \Countable|array
    Open

            $noOfEntries = \count($this->listViewEntries);
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('COLUMN_NAME', $orderBy);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('PAGE_NUMBER', $pageNumber);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('ORDER_BY', $orderBy);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('SOURCE_MODULE', $sourceModule);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('LOCKED_EMPTY_FIELDS', []);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('MODULE_LIST', $moduleModel->getAllModuleList());
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('PAGING_MODEL', $pagingModel);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('IS_MODULE_EDITABLE', false);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('START_PAGIN_FROM', $pagingModel->getStartPagingFrom());
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
    Severity: Critical
    Found in modules/RecycleBin/views/List.php by phan

    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

    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)
        {
    Severity: Minor
    Found in modules/RecycleBin/views/List.php by phpmd

    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')) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('LOCKED_EMPTY_FIELDS', []);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $pagingModel->set('page', $pageNumber);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                if (!$this->listViewCount) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('MODULE', $moduleName);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('LISTVIEW_MASSACTIONS', $linkModels['LISTVIEWMASSACTION'] ?? []);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return array_merge(parent::getFooterScripts($request), $this->checkAndConvertJsScripts([

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer = $this->getViewer($request);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $listViewModel->set('orderby', $orderBy);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $totalCount = (int) $this->listViewCount;

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('COLUMN_NAME', $orderBy);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $linkModels = $listViewModel->getListViewMassActions($linkParams);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $moduleModel = RecycleBin_Module_Model::getInstance($moduleName);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('MODULE_LIST', $moduleModel->getAllModuleList());

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function initializeListViewContents(App\Request $request, Vtiger_Viewer $viewer)

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (!empty($orderBy)) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('PAGE_NUMBER', $pageNumber);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('ORDER_BY', $orderBy);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('IS_MODULE_DELETABLE', false);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $this->preProcessDisplay($request);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $moduleModel = RecycleBin_Module_Model::getInstance($moduleName);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $orderBy = \App\CustomView::getSortBy($sourceModule);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $this->listViewLinks = $listViewModel->getListViewLinks($linkParams);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $this->listViewCount = $this->listViewModel->getListViewCount();

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $moduleName = $request->getModule();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->view('ListViewPostProcess.tpl', $moduleName);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $moduleName = $request->getModule();

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $sourceModule = current($moduleModel->getAllModuleList())['name'];

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $totalCount = false;

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('PAGING_MODEL', $pagingModel);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                "modules.{$request->getModule()}.resources.List",

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('VIEW_MODEL', $this->listViewModel);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('SEARCH_PARAMS', []);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('ADVANCED_CONDITIONS', []);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer = $this->getViewer($request);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            ]));

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (empty($orderBy)) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $listViewModel = RecycleBin_ListView_Model::getInstance($moduleName, $sourceModule);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function postProcess(App\Request $request, $display = true)

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('HEADER_LINKS', ['LIST_VIEW_HEADER' => []]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function preProcessTplName(App\Request $request)

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (!$this->listViewLinks) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $orderBy = $request->getArray('orderby', \App\Purifier::STANDARD, [], \App\Purifier::SQL);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (empty($sourceModule)) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $pagingModel->set('totalCount', (int) $this->listViewCount);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('PAGE_COUNT', $pagingModel->getPageCount());

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('START_PAGIN_FROM', $pagingModel->getStartPagingFrom());

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('SOURCE_MODULE', $sourceModule);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used to indent lines; tabs are not allowed
    Open

            parent::preProcess($request, false);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $sourceModule = $request->getByType('sourceModule', 2);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $pagingModel = new Vtiger_Paging_Model();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $this->listViewHeaders = $listViewModel->getListViewHeaders();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $noOfEntries = \count($this->listViewEntries);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('IS_MODULE_EDITABLE', false);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return 'ListViewPreProcess.tpl';

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $pageNumber = $request->isEmpty('page', true) ? 1 : $request->getInteger('page');

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $linkParams = ['MODULE' => $moduleName, 'ACTION' => $request->getByType('view', 1)];

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('LISTVIEW_LINKS', $this->listViewLinks);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $viewer->assign('LISTVIEW_COUNT', $totalCount);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function preProcess(App\Request $request, $display = true)

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $moduleName = $request->getModule();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (!$this->listViewHeaders) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            parent::postProcess($request);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function getFooterScripts(App\Request $request)

    Class name "RecycleBin_List_View" is not in camel caps format
    Open

    class RecycleBin_List_View extends Vtiger_List_View

    There are no issues that match your filters.

    Category
    Status