YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/views/ExportRecords.php

Summary

Maintainability
A
25 mins
Test Coverage
F
0%

Function getRecordStructureModuleFields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getRecordStructureModuleFields(): array
    {
        $recordStructureModulesField = [];
        foreach ($this->moduleModel->getFieldsByReference() as $referenceField) {
            if (!$referenceField->isActiveField()) {
Severity: Minor
Found in modules/Vtiger/views/ExportRecords.php - About 25 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

Missing class import via use statement (line '31', column '14').
Open

            throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

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\Export\Records' in method 'process'.
Open

        $viewer->assign('EXPORT_TYPE', \App\Export\Records::getSupportedFileFormats($moduleName));

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(), 'QuickExportToExcel')) {

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_Module_Model' in method 'getRecordStructureModuleFields'.
Open

                $recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();

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_Module_Model' in method 'process'.
Open

        $this->moduleModel = Vtiger_Module_Model::getInstance($moduleName);

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

Reference to undeclared property \Vtiger_ExportRecords_View->moduleModel
Open

        foreach ($this->moduleModel->getFieldsByReference() as $referenceField) {
Severity: Minor
Found in modules/Vtiger/views/ExportRecords.php by phan

Call to undeclared method \Vtiger_ExportRecords_View::getViewer
Open

        $viewer = $this->getViewer($request);
Severity: Critical
Found in modules/Vtiger/views/ExportRecords.php by phan

Class extends undeclared class \App\Controller\Modal
Open

class Vtiger_ExportRecords_View extends \App\Controller\Modal
Severity: Critical
Found in modules/Vtiger/views/ExportRecords.php by phan

Reference to undeclared property \Vtiger_ExportRecords_View->moduleModel
Open

        $this->moduleModel = Vtiger_Module_Model::getInstance($moduleName);
Severity: Minor
Found in modules/Vtiger/views/ExportRecords.php by phan

Reference to undeclared property \Vtiger_ExportRecords_View->moduleModel
Open

        $viewer->assign('RECORD_STRUCTURE', Vtiger_RecordStructure_Model::getInstanceForModule($this->moduleModel)->getStructure());
Severity: Minor
Found in modules/Vtiger/views/ExportRecords.php by phan

Avoid excessively long variable names like $recordStructureModulesField. Keep variable name length under 20.
Open

        $recordStructureModulesField = [];

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Vtiger_ExportRecords_View extends \App\Controller\Modal

The class Vtiger_ExportRecords_View is not named in CamelCase.
Open

class Vtiger_ExportRecords_View extends \App\Controller\Modal
{
    /** {@inheritdoc} */
    public $pageTitle = 'LBL_QUICK_EXPORT';
    /** {@inheritdoc} */

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

    {

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

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

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

            if (!$referenceField->isActiveField()) {

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

    }

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

        $viewer->assign('EXPORT_TYPE', \App\Export\Records::getSupportedFileFormats($moduleName));

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

        $viewer->view('Modals/ExportRecords.tpl', $moduleName);

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

                $recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();

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

        if (!\App\Privilege::isPermitted($request->getModule(), 'QuickExportToExcel')) {

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

            throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

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->assign('RECORD_STRUCTURE', Vtiger_RecordStructure_Model::getInstanceForModule($this->moduleModel)->getStructure());

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

    public $successBtn = 'LBL_GENERATE';

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

    /**

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

     * Function get record structure for a module.

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

        $recordStructureModulesField = [];

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

        foreach ($this->moduleModel->getFieldsByReference() as $referenceField) {

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

     * Process function.

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

        $viewer->assign('RECORD_STRUCTURE_RELATED_MODULES', $this->getRecordStructureModuleFields());

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

     * @return array

Line exceeds 120 characters; contains 221 characters
Open

                $recordStructureModulesField[$relatedModuleName][$referenceField->getFieldName()] = Vtiger_RecordStructure_Model::getInstanceForModule(Vtiger_Module_Model::getInstance($relatedModuleName))->getStructure();

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

    public function checkPermission(App\Request $request)

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

    public $modalIcon = 'fas fa-file-export';

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

    public function process(App\Request $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

    {

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 = $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

    /** {@inheritdoc} */

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

            foreach ($referenceField->getReferenceList() as $relatedModuleName) {

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

    }

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

    /**

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

     *

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

    {

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

        return $recordStructureModulesField;

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

     * @param App\Request $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

    public function getRecordStructureModuleFields(): array

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

                continue;

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

    public $pageTitle = 'LBL_QUICK_EXPORT';

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

    public $successBtnIcon = 'fas fa-file-export';

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

        $this->moduleModel = Vtiger_Module_Model::getInstance($moduleName);

Line exceeds 120 characters; contains 132 characters
Open

        $viewer->assign('RECORD_STRUCTURE', Vtiger_RecordStructure_Model::getInstanceForModule($this->moduleModel)->getStructure());

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

            }

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

class Vtiger_ExportRecords_View extends \App\Controller\Modal

There are no issues that match your filters.

Category
Status