YetiForceCompany/YetiForceCRM

View on GitHub
modules/ModComments/actions/MassSaveAjax.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

            throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 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

Missing class import via use statement (line '26', 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

Missing class import via use statement (line '48', column '19').
Open

        $response = new Vtiger_Response();

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

        $relationModel = Vtiger_Relation_Model::getInstance(Vtiger_Module_Model::getInstance($request->getByType('source_module', 2)), Vtiger_Module_Model::getInstance($request->getModule()));

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\Utils\Completions' in method 'getRecordModelsFromRequest'.
Open

            $recordModel->set('commentcontent', \App\Utils\Completions::encodeAll(\App\Purifier::decodeHtml($request->getForHtml('commentcontent'))));

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

        $relationModel = Vtiger_Relation_Model::getInstance(Vtiger_Module_Model::getInstance($request->getByType('source_module', 2)), Vtiger_Module_Model::getInstance($request->getModule()));

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\User' in method 'getRecordModelsFromRequest'.
Open

        $userId = \App\User::getCurrentUserRealId();

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 'Users_Privileges_Model' in method 'checkPermission'.
Open

        $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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_Record_Model' in method 'getRecordModelsFromRequest'.
Open

            $recordModel = Vtiger_Record_Model::getCleanInstance($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 'Vtiger_Relation_Model' in method 'process'.
Open

        $relationModel = Vtiger_Relation_Model::getInstance(Vtiger_Module_Model::getInstance($request->getByType('source_module', 2)), Vtiger_Module_Model::getInstance($request->getModule()));

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 'checkPermission'.
Open

        $moduleModel = Vtiger_Module_Model::getInstance($sourceModule);

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\Purifier' in method 'getRecordModelsFromRequest'.
Open

            $recordModel->set('commentcontent', \App\Utils\Completions::encodeAll(\App\Purifier::decodeHtml($request->getForHtml('commentcontent'))));

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

Call to method getCurrentUserRealId from undeclared class \App\User (Did you mean class \Tests\App\User)
Open

        $userId = \App\User::getCurrentUserRealId();

Returning type array<int>|array{}</int> but getRecordModelsFromRequest() is declared to return \Vtiger_Record_Model
Open

        return $recordModels;

Class \Vtiger_Record_Model was passed to foreach, but it does not extend Traversable. This may be intentional, because some of that class's declared properties are accessible from this context. (This check excludes dynamic properties)
Open

        foreach ($recordModels as $relatedRecordId => &$recordModel) {

Call to method encodeAll from undeclared class \App\Utils\Completions
Open

            $recordModel->set('commentcontent', \App\Utils\Completions::encodeAll(\App\Purifier::decodeHtml($request->getForHtml('commentcontent'))));

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

class ModComments_MassSaveAjax_Action extends Vtiger_Mass_Action

The class ModComments_MassSaveAjax_Action is not named in CamelCase.
Open

class ModComments_MassSaveAjax_Action extends Vtiger_Mass_Action
{
    /**
     * Function to check permission.
     *

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

    public function process(App\Request $request)

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

            $recordModel->save();

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

        $response = new Vtiger_Response();

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

    /**

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

     * @throws \App\Exceptions\NoPermittedToRecord

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

     * Function to get the record model based on the request parameters.

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

        $recordModels = [];

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

        if (!$userPrivilegesModel->hasModuleActionPermission($request->getModule(), 'CreateView')) {

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 (!$moduleModel->isCommentEnabled() || !$userPrivilegesModel->hasModuleActionPermission($sourceModule, 'MassAddComment')) {

Line exceeds 120 characters; contains 192 characters
Open

        $relationModel = Vtiger_Relation_Model::getInstance(Vtiger_Module_Model::getInstance($request->getByType('source_module', 2)), Vtiger_Module_Model::getInstance($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

            $recordModel->set('assigned_user_id', $userId);

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

        $moduleModel = Vtiger_Module_Model::getInstance($sourceModule);

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

        foreach ($recordModels as $relatedRecordId => &$recordModel) {

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

        $response->emit();

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

     * @return Vtiger_Record_Model or Module specific Record Model instance

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

     * @throws \App\Exceptions\NoPermitted

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

     */

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

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

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

        }

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

     * Main process.

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

            $recordModel->set('commentcontent', \App\Utils\Completions::encodeAll(\App\Purifier::decodeHtml($request->getForHtml('commentcontent'))));

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

            $recordModel = Vtiger_Record_Model::getCleanInstance($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

        $recordModels = $this->getRecordModelsFromRequest($request);

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

        $relationModel = Vtiger_Relation_Model::getInstance(Vtiger_Module_Model::getInstance($request->getByType('source_module', 2)), Vtiger_Module_Model::getInstance($request->getModule()));

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

        $response->setResult(true);

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

        $recordIds = self::getRecordsListFromRequest($request);

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

        $userId = \App\User::getCurrentUserRealId();

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

        return $recordModels;

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

    {

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

    /**

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

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

    private function getRecordModelsFromRequest(App\Request $request)

Line exceeds 120 characters; contains 150 characters
Open

            $recordModel->set('commentcontent', \App\Utils\Completions::encodeAll(\App\Purifier::decodeHtml($request->getForHtml('commentcontent'))));

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

     * Function to check permission.

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

            throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 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

    {

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

            $recordModels[$recordId] = $recordModel;

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

        }

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

        $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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

        foreach ($recordIds as $recordId) {

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

            $relationModel->addRelation($relatedRecordId, $recordModel->getId());

Line exceeds 120 characters; contains 133 characters
Open

        if (!$moduleModel->isCommentEnabled() || !$userPrivilegesModel->hasModuleActionPermission($sourceModule, 'MassAddComment')) {

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

        $moduleName = $request->getModule();

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

            $recordModel->set('related_to', $recordId);

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

    }

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

class ModComments_MassSaveAjax_Action extends Vtiger_Mass_Action

There are no issues that match your filters.

Category
Status