YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
45 mins
Test Coverage
F
0%

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);
Severity: Minor
Found in modules/Vtiger/views/MergeRecords.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

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

            throw new \App\Exceptions\NoPermitted('ERR_NOT_ACCESSIBLE', 406);
Severity: Minor
Found in modules/Vtiger/views/MergeRecords.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\Language' in method 'getPageTitle'.
Open

        return \App\Language::translate('LBL_MERGE_RECORDS_IN', $moduleName) . ': ' . \App\Language::translate($moduleName, $moduleName);
Severity: Minor
Found in modules/Vtiger/views/MergeRecords.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\Config' in method 'initializeContent'.
Open

            $dataReader = $query->limit(\App\Config::performance('MAX_MERGE_RECORDS'))->createCommand()->query();
Severity: Minor
Found in modules/Vtiger/views/MergeRecords.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\Language' in method 'getPageTitle'.
Open

        return \App\Language::translate('LBL_MERGE_RECORDS_IN', $moduleName) . ': ' . \App\Language::translate($moduleName, $moduleName);
Severity: Minor
Found in modules/Vtiger/views/MergeRecords.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\Privilege' in method 'checkPermission'.
Open

        if (!\App\Privilege::isPermitted($request->getModule(), 'Merge')) {
Severity: Minor
Found in modules/Vtiger/views/MergeRecords.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 'Vtiger_Mass_Action' in method 'initializeContent'.
Open

        $queryGenerator = Vtiger_Mass_Action::getQuery($request);
Severity: Minor
Found in modules/Vtiger/views/MergeRecords.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 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');
Severity: Minor
Found in modules/Vtiger/views/MergeRecords.php by phpmd

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();
Severity: Critical
Found in modules/Vtiger/views/MergeRecords.php by phan

Call to method getModuleFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

            foreach ($queryGenerator->getModuleFields() as $field) {
Severity: Critical
Found in modules/Vtiger/views/MergeRecords.php by phan

Reference to undeclared property \Vtiger_MergeRecords_View->modalIcon
Open

        $this->modalIcon = 'fa fa-code';
Severity: Minor
Found in modules/Vtiger/views/MergeRecords.php by phan

Reference to undeclared property \Vtiger_MergeRecords_View->dangerBtn
Open

        $viewer->assign('BTN_DANGER', $this->dangerBtn);
Severity: Minor
Found in modules/Vtiger/views/MergeRecords.php by phan

Call to method setField from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

            $queryGenerator->setField('id');
Severity: Critical
Found in modules/Vtiger/views/MergeRecords.php by phan

Class extends undeclared class \App\Controller\Modal
Open

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

Call to undeclared method \Vtiger_MergeRecords_View::getViewer
Open

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

Reference to undeclared class \App\Controller\Modal
Open

        parent::preProcessAjax($request);
Severity: Critical
Found in modules/Vtiger/views/MergeRecords.php by phan

Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

            $query = $queryGenerator->createQuery();
Severity: Critical
Found in modules/Vtiger/views/MergeRecords.php by phan

Call to undeclared method \Vtiger_MergeRecords_View::getViewer
Open

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

Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

            $queryGenerator->setFields($fields);
Severity: Critical
Found in modules/Vtiger/views/MergeRecords.php by phan

Call to undeclared method \Vtiger_MergeRecords_View::getViewer
Open

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

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

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)
    {
Severity: Minor
Found in modules/Vtiger/views/MergeRecords.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

        $queryGenerator = Vtiger_Mass_Action::getQuery($request);

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

                $recordModels[$row['id']] = $moduleModel->getRecordFromArray($row);

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

        $viewer->assign('COUNT', $count);

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

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

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

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

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

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

    {

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

        $viewer->assign('BTN_DANGER', $this->dangerBtn);

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

            $moduleModel = $queryGenerator->getModuleModel();

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

        $viewer->assign('FIELDS', $fields);

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

    public function postProcessAjax(App\Request $request)

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

        $viewer->view('Modals/Footer.tpl', $request->getModule());

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

    {

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

            $queryGenerator->setFields($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

        $viewer->assign('RECORD_MODELS', $recordModels);

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

    /** {@inheritdoc} */

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

                if ($field->isEditable()) {

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

            $dataReader = $query->limit(\App\Config::performance('MAX_MERGE_RECORDS'))->createCommand()->query();

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

            $dataReader->close();

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

        $this->modalIcon = 'fa fa-code';

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

        $this->initializeContent($request);

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

        $viewer->view('MergeRecords.tpl', $request->getModule());

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

    /** {@inheritdoc} */

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

        parent::preProcessAjax($request);

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

        if ($queryGenerator) {

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

            }

Line exceeds 120 characters; contains 137 characters
Open

        return \App\Language::translate('LBL_MERGE_RECORDS_IN', $moduleName) . ': ' . \App\Language::translate($moduleName, $moduleName);

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

    public function preProcessAjax(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

    /** {@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

    /** {@inheritdoc} */

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

        $count = 0;

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

            $queryGenerator->setField('id');

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

            $query = $queryGenerator->createQuery();

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

        return \App\Language::translate('LBL_MERGE_RECORDS_IN', $moduleName) . ': ' . \App\Language::translate($moduleName, $moduleName);

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

    public $modalSize = 'modal-fullscreen';

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

    public function process(App\Request $request)

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

            while ($row = $dataReader->read()) {

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 initializeContent(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

            foreach ($queryGenerator->getModuleFields() as $field) {

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

                    $fields[] = $field->getName();

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

            $count = $query->count();

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

        if (($var = $viewer->getTemplateVars('RECORD_MODELS')) && \count($var) > 1) {

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

            $viewer->assign('BTN_SUCCESS', 'LBL_MERGE');

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

    public function getPageTitle(App\Request $request)

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

class Vtiger_MergeRecords_View extends \App\Controller\Modal

There are no issues that match your filters.

Category
Status