Missing class import via use statement (line '76', column '19'). Open
$response = 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 '41', column '21'). Open
$configFile = new \App\ConfigFile('component', 'InterestsConflict');
- 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 '50', column '19'). Open
$response = 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 '73', column '21'). Open
$configFile = new \App\ConfigFile('component', 'InterestsConflict');
- 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 assigning values to variables in if clauses and the like (line '38', column '8'). Open
public function config(App\Request $request): void
{
$confirmationTimeInterval = $request->getInteger('confirmationTimeInterval');
if (($list = $request->getByType('confirmationTimeIntervalList', 'Standard')) && '-' !== $list) {
$confirmationTimeInterval .= ' ' . $list;
- 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\Purifier' in method 'modules'. Open
$data[\App\Purifier::purifyByType($jsonKey, 'Alnum')] = \App\Purifier::purifyByType($jsonValue, 'AlnumExtended');
- 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\Json' in method 'modules'. Open
foreach (\App\Json::decode($module) as $jsonKey => $jsonValue) {
- 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\Purifier' in method 'modules'. Open
$data[\App\Purifier::purifyByType($jsonKey, 'Alnum')] = \App\Purifier::purifyByType($jsonValue, 'AlnumExtended');
- 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 "modules" 3 times. Open
$this->exposeMethod('modules');
- 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.
Avoid excessively long variable names like $confirmationTimeInterval. Keep variable name length under 20. Open
$confirmationTimeInterval = $request->getInteger('confirmationTimeInterval');
- 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_InterestsConflict_Save_Action extends \App\Controller\Action
- Exclude checks
The class Settings_InterestsConflict_Save_Action is not named in CamelCase. Open
class Settings_InterestsConflict_Save_Action extends \App\Controller\Action
{
use \App\Controller\ExposeMethod, \App\Controller\Traits\SettingsPermission;
/** {@inheritdoc} */
- 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
$this->exposeMethod('config');
- 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
* Save config data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param App\Request $request
- 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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile = new \App\ConfigFile('component', 'InterestsConflict');
- 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
foreach ($request->getArray('modules') as $key => $module) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'key' => $key
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data[\App\Purifier::purifyByType($jsonKey, 'Alnum')] = \App\Purifier::purifyByType($jsonValue, 'AlnumExtended');
- 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
$config[$data['related']][] = $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('modules');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('sendMailAccessRequest', $request->getBoolean('sendMailAccessRequest'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('unlockUsersAccess', $request->getArray('unlockUsersAccess', 'Integer'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- 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
$confirmationTimeInterval .= ' ' . $list;
- 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
use \App\Controller\ExposeMethod, \App\Controller\Traits\SettingsPermission;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Save modules configuration.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('sendMailAccessResponse', $request->getBoolean('sendMailAccessResponse'));
- 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function config(App\Request $request): void
- 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
$confirmationTimeInterval = $request->getInteger('confirmationTimeInterval');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile = new \App\ConfigFile('component', 'InterestsConflict');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('confirmationTimeInterval', $confirmationTimeInterval);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('confirmUsersAccess', $request->getArray('confirmUsersAccess', 'Integer'));
- 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
$configFile->set('notificationsEmails', $request->getByType('notificationsEmails', 'Text'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('modules', $config);
- 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
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (($list = $request->getByType('confirmationTimeIntervalList', 'Standard')) && '-' !== $list) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (\App\Json::decode($module) as $jsonKey => $jsonValue) {
- 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
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('isActive', $request->getBoolean('isActive'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function modules(App\Request $request): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
$data[\App\Purifier::purifyByType($jsonKey, 'Alnum')] = \App\Purifier::purifyByType($jsonValue, 'AlnumExtended');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = new Vtiger_Response();
- 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
$config = [];
- Exclude checks
Class name "Settings_InterestsConflict_Save_Action" is not in camel caps format Open
class Settings_InterestsConflict_Save_Action extends \App\Controller\Action
- Exclude checks