Method save
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save(App\Request $request)
{
Settings_Vtiger_Tracker_Model::lockTracking(false);
Settings_Vtiger_Tracker_Model::addBasic('save');
$qualifiedModuleName = $request->getModule(false);
Avoid using undefined variables such as '$prevDetail' which will lead to PHP notices. Open
$prevDetail['userId'] = implode(',', $oldValues);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$prevDetail' which will lead to PHP notices. Open
Settings_Vtiger_Tracker_Model::addDetail($prevDetail, $newDetail);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$newDetail' which will lead to PHP notices. Open
Settings_Vtiger_Tracker_Model::addDetail($prevDetail, $newDetail);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$newDetail' which will lead to PHP notices. Open
$newDetail['userId'] = implode(',', $newValues);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Missing class import via use statement (line '45', column '25'). Open
$responceToEmit = new Vtiger_Response();
- Read upRead up
- Exclude checks
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 '65', column '25'). Open
$responceToEmit = new Vtiger_Response();
- Read upRead up
- Exclude checks
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 'Settings_RecordAllocation_Module_Model' in method 'save'. Open
$oldValues = Settings_RecordAllocation_Module_Model::getRecordAllocationByModule($data['type'], $data['module']);
- 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 'Settings_Vtiger_Tracker_Model' in method '__construct'. Open
Settings_Vtiger_Tracker_Model::lockTracking();
- 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 'Settings_RecordAllocation_Module_Model' in method 'save'. Open
$newValues = Settings_RecordAllocation_Module_Model::getRecordAllocationByModule($data['type'], $data['module']);
- 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 'Settings_Vtiger_Tracker_Model' in method 'removePanel'. Open
Settings_Vtiger_Tracker_Model::lockTracking(false);
- 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 'Settings_Vtiger_Tracker_Model' in method 'save'. Open
Settings_Vtiger_Tracker_Model::addBasic('save');
- 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 'Settings_Vtiger_Tracker_Model' in method 'removePanel'. Open
Settings_Vtiger_Tracker_Model::addBasic('delete');
- 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 'Settings_Vtiger_Module_Model' in method 'save'. Open
$moduleInstance = Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName);
- 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 'Settings_Vtiger_Module_Model' in method 'removePanel'. Open
$moduleInstance = Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName);
- 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 'Settings_Vtiger_Tracker_Model' in method 'save'. Open
Settings_Vtiger_Tracker_Model::lockTracking(false);
- 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 'Settings_Vtiger_Tracker_Model' in method 'save'. Open
Settings_Vtiger_Tracker_Model::addDetail($prevDetail, $newDetail);
- 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 'Settings_RecordAllocation_Module_Model' in method 'save'. Open
Settings_RecordAllocation_Module_Model::resetDataVariable();
- 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
Define a constant instead of duplicating this literal "Integer" 3 times. Open
'userid' => 'Integer',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "groups" 3 times. Open
'groups' => ['Integer'],
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "userid" 5 times. Open
'userid' => 'Integer',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "users" 3 times. Open
'users' => ['Integer'],
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Alnum" 4 times. Open
'module' => 'Alnum',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "module" 5 times. Open
'module' => 'Alnum',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Variable $newDetail
was undeclared, but array fields are being added to it. Open
$newDetail['userId'] = implode(',', $newValues);
- Exclude checks
Variable $prevDetail
was undeclared, but array fields are being added to it. Open
$prevDetail['userId'] = implode(',', $oldValues);
- Exclude checks
Call to undeclared method \Settings_Vtiger_Module_Model::save
Open
$moduleInstance->save(array_filter($data));
- Exclude checks
Avoid excessively long class names like Settings_RecordAllocation_SaveAjax_Action. Keep class name length under 40. Open
class Settings_RecordAllocation_SaveAjax_Action extends Settings_Vtiger_Save_Action
{
public function __construct()
{
Settings_Vtiger_Tracker_Model::lockTracking();
- Read upRead up
- Exclude checks
LongClassName
Since: 2.9
Detects when classes or interfaces are declared with excessively long names.
Example
class ATooLongClassNameThatHintsAtADesignProblem {
}
interface ATooLongInterfaceNameThatHintsAtADesignProblem {
}
Source https://phpmd.org/rules/naming.html#longclassname
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_RecordAllocation_SaveAjax_Action extends Settings_Vtiger_Save_Action
- Exclude checks
The class Settings_RecordAllocation_SaveAjax_Action is not named in CamelCase. Open
class Settings_RecordAllocation_SaveAjax_Action extends Settings_Vtiger_Save_Action
{
public function __construct()
{
Settings_Vtiger_Tracker_Model::lockTracking();
- 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
$oldValues = Settings_RecordAllocation_Module_Model::getRecordAllocationByModule($data['type'], $data['module']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::__construct();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'groups' => ['Integer'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$newValues = Settings_RecordAllocation_Module_Model::getRecordAllocationByModule($data['type'], $data['module']);
- 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
$newDetail['userId'] = implode(',', $newValues);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$responceToEmit->setResult(true);
- 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
$responceToEmit->setResult(true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $request->getMultiDimensionArray('param', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'module' => 'Alnum',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleInstance->set('type', $data['type']);
- 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
$moduleInstance = Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Settings_Vtiger_Tracker_Model::addDetail($prevDetail, $newDetail);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Settings_Vtiger_Tracker_Model::addBasic('delete');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $data['module'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleInstance = Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName);
- 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
Settings_Vtiger_Tracker_Model::lockTracking(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ids' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$oldValues = array_merge((array) ($oldValues[$data['userid']]['users'] ?? []), (array) ($oldValues[$data['userid']]['groups'] ?? []));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$newValues = Settings_RecordAllocation_Module_Model::getRecordAllocationByModule($data['type'], $data['module']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'module' => 'Alnum',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleInstance->set('type', $data['type']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'type' => 'Alnum',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'users' => ['Integer'],
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$oldValues = Settings_RecordAllocation_Module_Model::getRecordAllocationByModule($data['type'], $data['module']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function removePanel(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$responceToEmit->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('save');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Settings_RecordAllocation_Module_Model::resetDataVariable();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$responceToEmit = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Settings_Vtiger_Tracker_Model::lockTracking(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('removePanel');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$qualifiedModuleName = $request->getModule(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'userid' => 'Integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$prevDetail['userId'] = implode(',', $oldValues);
- 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
Settings_Vtiger_Tracker_Model::lockTracking();
- Exclude checks
Line exceeds 120 characters; contains 142 characters Open
$oldValues = array_merge((array) ($oldValues[$data['userid']]['users'] ?? []), (array) ($oldValues[$data['userid']]['groups'] ?? []));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $request->getMultiDimensionArray('param', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$newValues = array_merge((array) ($newValues[$data['userid']]['users'] ?? []), (array) ($newValues[$data['userid']]['groups'] ?? []));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct()
- 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
'type' => 'Alnum',
- Exclude checks
Line exceeds 120 characters; contains 142 characters Open
$newValues = array_merge((array) ($newValues[$data['userid']]['users'] ?? []), (array) ($newValues[$data['userid']]['groups'] ?? []));
- 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 save(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Settings_Vtiger_Tracker_Model::addBasic('save');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleInstance->save(array_filter($data));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$responceToEmit->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$qualifiedModuleName = $request->getModule(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleInstance->remove($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$responceToEmit = new Vtiger_Response();
- Exclude checks
Class name "Settings_RecordAllocation_SaveAjax_Action" is not in camel caps format Open
class Settings_RecordAllocation_SaveAjax_Action extends Settings_Vtiger_Save_Action
- Exclude checks