Missing class import via use statement (line '24', column '22'). Open
$dataReader = (new App\Db\Query())->from('vtiger_profile2globalpermissions')
- 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 '\App\UserPrivilegesFile' in method 'recalculate'. Open
\App\UserPrivilegesFile::createUserPrivilegesfile($userId);
- 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 '\App\Privilege' in method 'save'. Open
\App\Privilege::setAllUpdater();
- 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 'App\Db' in method 'save'. Open
$db = App\Db::getInstance();
- 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 '\App\Config' in method 'recalculate'. Open
$php_max_execution_time = \App\Config::main('php_max_execution_time');
- 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_Profiles_Record_Model' in method 'recalculate'. Open
$userIdsList = Settings_Profiles_Record_Model::getUsersList();
- 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 "vtiger_profile2globalpermissions" 3 times. Open
$dataReader = (new App\Db\Query())->from('vtiger_profile2globalpermissions')
- 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 "profileid" 3 times. Open
$profileid = $row['profileid'];
- 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 "globalactionid" 3 times. Open
$actionId = $row['globalactionid'];
- 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.
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('vtiger_profile2globalpermissions', ['profileid' => $profileID, 'globalactionid' => $globalactionid])->execute();
- Exclude checks
Method \Settings_GlobalPermission_Record_Model::getId
is declared to return int
but has no return value Open
public function getId()
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert('vtiger_profile2globalpermissions', [
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$dataReader = (new App\Db\Query())->from('vtiger_profile2globalpermissions')
- Exclude checks
Method \Settings_GlobalPermission_Record_Model::getName
is declared to return string
but has no return value Open
public function getName()
- Exclude checks
Avoid excessively long variable names like $php_max_execution_time. Keep variable name length under 20. Open
$php_max_execution_time = \App\Config::main('php_max_execution_time');
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_GlobalPermission_Record_Model extends Settings_Vtiger_Record_Model
- Exclude checks
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = App\Db::getInstance();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The class Settings_GlobalPermission_Record_Model is not named in CamelCase. Open
class Settings_GlobalPermission_Record_Model extends Settings_Vtiger_Record_Model
{
const GLOBAL_ACTION_VIEW = 1;
const GLOBAL_ACTION_EDIT = 2;
- 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
$profileid = $row['profileid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Privilege::setAllUpdater();
- 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
$globalPermissions[$profileid]['description'] = $description;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function recalculate()
- 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
return $globalPermissions;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$permissionId = $row['globalactionpermission'];
- 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
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete('vtiger_profile2globalpermissions', ['profileid' => $profileID, 'globalactionid' => $globalactionid])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'globalactionpermission' => $checked,
- 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
$php_max_execution_time = \App\Config::main('php_max_execution_time');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($userIdsList) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\UserPrivilegesFile::createUserPrivilegesfile($userId);
- 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 getId()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$globalPermissions[$profileid]['profilename'] = $profilename;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getGlobalPermissions()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$description = $row['description'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const GLOBAL_ACTION_VIEW = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function save($profileID, $globalactionid, $checked)
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
$db->createCommand()->delete('vtiger_profile2globalpermissions', ['profileid' => $profileID, 'globalactionid' => $globalactionid])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'globalactionid' => $globalactionid,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
set_time_limit($php_max_execution_time);
- 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
$globalPermissions = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$globalPermissions[$profileid]['gp_' . $actionId] = $permissionId;
- 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
$db->createCommand()->insert('vtiger_profile2globalpermissions', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::recalculate();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($userIdsList as $userId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->leftJoin('vtiger_profile', 'vtiger_profile.profileid = vtiger_profile2globalpermissions.profileid')
- 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
$actionId = $row['globalactionid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$profilename = $row['profilename'];
- 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
if (1 == $globalactionid) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getName()
- 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
->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'profileid' => $profileID,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userIdsList = Settings_Profiles_Record_Model::getUsersList();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const GLOBAL_ACTION_EDIT = 2;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = (new App\Db\Query())->from('vtiger_profile2globalpermissions')
- 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
$db = App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Class name "Settings_GlobalPermission_Record_Model" is not in camel caps format Open
class Settings_GlobalPermission_Record_Model extends Settings_Vtiger_Record_Model
- Exclude checks
The variable $php_max_execution_time is not named in camelCase. Open
public static function recalculate()
{
$php_max_execution_time = \App\Config::main('php_max_execution_time');
set_time_limit($php_max_execution_time);
$userIdsList = Settings_Profiles_Record_Model::getUsersList();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $php_max_execution_time is not named in camelCase. Open
public static function recalculate()
{
$php_max_execution_time = \App\Config::main('php_max_execution_time');
set_time_limit($php_max_execution_time);
$userIdsList = Settings_Profiles_Record_Model::getUsersList();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}