Avoid using static access to class 'Vtiger_Loader' in method 'getRecordModelFromRequest'. Open
$className = Vtiger_Loader::getComponentClassName('Action', 'Save', $request->getModule());
- Read upRead up
- Exclude checks
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());
- Read upRead up
- Exclude checks
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());
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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);
}
- Read upRead up
- Exclude checks
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
- Exclude checks
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)
{
- Read upRead up
- Exclude checks
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);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $recordModel;
- Exclude checks
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)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$className = Vtiger_Loader::getComponentClassName('Action', 'Save', $request->getModule());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getRecordModelFromRequest(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = (new $className())->getRecordModelFromRequest($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relRecord = Vtiger_Record_Model::getInstanceById($relId, $this->record->getModuleName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function saveRecord(App\Request $request)
- Exclude checks
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)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relRecord->set('activitystatus', 'PLL_POSTPONED');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relRecord->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::saveRecord($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$request->isEmpty('record') && !$request->has('field')) {
- Exclude checks
Class name "Calendar_SaveAjax_Action" is not in camel caps format Open
class Calendar_SaveAjax_Action extends Vtiger_SaveAjax_Action
- Exclude checks