YetiForceCompany/YetiForceCRM

View on GitHub
modules/Calendar/actions/SaveAjax.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using static access to class 'Vtiger_Loader' in method 'getRecordModelFromRequest'.
Open

            $className = Vtiger_Loader::getComponentClassName('Action', 'Save', $request->getModule());
Severity: Minor
Found in modules/Calendar/actions/SaveAjax.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_Record_Model' in method 'saveRecord'.
Open

            $relRecord = Vtiger_Record_Model::getInstanceById($relId, $this->record->getModuleName());
Severity: Minor
Found in modules/Calendar/actions/SaveAjax.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 '18', column '45').
Open

    public function saveRecord(App\Request $request)
    {
        parent::saveRecord($request);
        if ($request->getBoolean('postponed') && ($relId = $this->record->get('followup')) && \App\Privilege::isPermitted($this->record->getModuleName(), 'ActivityPostponed', $relId)) {
            $relRecord = Vtiger_Record_Model::getInstanceById($relId, $this->record->getModuleName());
Severity: Minor
Found in modules/Calendar/actions/SaveAjax.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

Avoid using static access to class '\App\Privilege' in method 'saveRecord'.
Open

        if ($request->getBoolean('postponed') && ($relId = $this->record->get('followup')) && \App\Privilege::isPermitted($this->record->getModuleName(), 'ActivityPostponed', $relId)) {
Severity: Minor
Found in modules/Calendar/actions/SaveAjax.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

The method getRecordModelFromRequest uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $recordModel = parent::getRecordModelFromRequest($request);
        }
Severity: Minor
Found in modules/Calendar/actions/SaveAjax.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

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

class Calendar_SaveAjax_Action extends Vtiger_SaveAjax_Action

The class Calendar_SaveAjax_Action is not named in CamelCase.
Open

class Calendar_SaveAjax_Action extends Vtiger_SaveAjax_Action
{
    /** {@inheritdoc} */
    public function saveRecord(App\Request $request)
    {
Severity: Minor
Found in modules/Calendar/actions/SaveAjax.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

            $recordModel = parent::getRecordModelFromRequest($request);

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

        return $recordModel;

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

        if ($request->getBoolean('postponed') && ($relId = $this->record->get('followup')) && \App\Privilege::isPermitted($this->record->getModuleName(), 'ActivityPostponed', $relId)) {

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

            $className = Vtiger_Loader::getComponentClassName('Action', 'Save', $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

        }

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

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

            $recordModel = (new $className())->getRecordModelFromRequest($request);

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

            $relRecord = Vtiger_Record_Model::getInstanceById($relId, $this->record->getModuleName());

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

    public function saveRecord(App\Request $request)

Line exceeds 120 characters; contains 185 characters
Open

        if ($request->getBoolean('postponed') && ($relId = $this->record->get('followup')) && \App\Privilege::isPermitted($this->record->getModuleName(), 'ActivityPostponed', $relId)) {

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

            $relRecord->set('activitystatus', 'PLL_POSTPONED');

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

    {

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

            $relRecord->save();

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

    }

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

        } else {

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

        parent::saveRecord($request);

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

        if (!$request->isEmpty('record') && !$request->has('field')) {

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

class Calendar_SaveAjax_Action extends Vtiger_SaveAjax_Action

There are no issues that match your filters.

Category
Status