Missing class import via use statement (line '30', column '25'). Open
$attemptsLogin = (new \App\Db\Query())->from('vtiger_loginhistory')
- 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\Fields\DateTime' in method 'process'. Open
$time = \App\Fields\DateTime::formatToDisplay($data['login_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 '\App\Language' in method 'process'. Open
$html .= '<hr><table border="1" cellspacing="0" style="width:100%"><tr style="font-weight: bold;"><td>' . \App\Language::translate('SINGLE_Users', 'Users') . '</td><td>' . \App\Language::translate('LBL_DATE') . '</td><td>' . \App\Language::translate('LBL_STATUS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_BROWSERS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_USER_AGENT', 'Settings:BruteForce') . '</td></tr>';
- 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\Language' in method 'process'. Open
$status = \App\Language::translate($data['status'], 'Users');
- 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\Language' in method 'process'. Open
$html .= '<hr><table border="1" cellspacing="0" style="width:100%"><tr style="font-weight: bold;"><td>' . \App\Language::translate('SINGLE_Users', 'Users') . '</td><td>' . \App\Language::translate('LBL_DATE') . '</td><td>' . \App\Language::translate('LBL_STATUS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_BROWSERS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_USER_AGENT', 'Settings:BruteForce') . '</td></tr>';
- 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\Language' in method 'process'. Open
$html .= '<hr><table border="1" cellspacing="0" style="width:100%"><tr style="font-weight: bold;"><td>' . \App\Language::translate('SINGLE_Users', 'Users') . '</td><td>' . \App\Language::translate('LBL_DATE') . '</td><td>' . \App\Language::translate('LBL_STATUS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_BROWSERS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_USER_AGENT', 'Settings:BruteForce') . '</td></tr>';
- 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\Language' in method 'process'. Open
$html .= '<hr><table border="1" cellspacing="0" style="width:100%"><tr style="font-weight: bold;"><td>' . \App\Language::translate('SINGLE_Users', 'Users') . '</td><td>' . \App\Language::translate('LBL_DATE') . '</td><td>' . \App\Language::translate('LBL_STATUS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_BROWSERS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_USER_AGENT', 'Settings:BruteForce') . '</td></tr>';
- 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\Language' in method 'process'. Open
$html .= '<hr><table border="1" cellspacing="0" style="width:100%"><tr style="font-weight: bold;"><td>' . \App\Language::translate('SINGLE_Users', 'Users') . '</td><td>' . \App\Language::translate('LBL_DATE') . '</td><td>' . \App\Language::translate('LBL_STATUS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_BROWSERS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_USER_AGENT', 'Settings:BruteForce') . '</td></tr>';
- 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\Language' in method 'process'. Open
$html = \App\Language::translate('LBL_BLOCKED_IP', 'Settings::BruteForce') . ': ' . $this->displayIpAddress($this->textParser->getParam('ip'));
- 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 "<td>" 4 times.</td> Open
$html .= '<hr><table border="1" cellspacing="0" style="width:100%"><tr style="font-weight: bold;"><td>' . \App\Language::translate('SINGLE_Users', 'Users') . '</td><td>' . \App\Language::translate('LBL_DATE') . '</td><td>' . \App\Language::translate('LBL_STATUS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_BROWSERS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_USER_AGENT', 'Settings:BruteForce') . '</td></tr>';
- 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 "login_time" 3 times. Open
['>=', 'login_time', $this->textParser->getParam('time')],
- 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 "Settings:BruteForce" 3 times. Open
$html .= '<hr><table border="1" cellspacing="0" style="width:100%"><tr style="font-weight: bold;"><td>' . \App\Language::translate('SINGLE_Users', 'Users') . '</td><td>' . \App\Language::translate('LBL_DATE') . '</td><td>' . \App\Language::translate('LBL_STATUS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_BROWSERS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_USER_AGENT', 'Settings:BruteForce') . '</td></tr>';
- 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\Query::from
Open
$attemptsLogin = (new \App\Db\Query())->from('vtiger_loginhistory')
- Exclude checks
Call to method getParam
from undeclared class \App\TextParser
(Did you mean class \Tests\App\TextParser) Open
['user_ip' => $this->textParser->getParam('ip')],
- Exclude checks
Call to method getParam
from undeclared class \App\TextParser
(Did you mean class \Tests\App\TextParser) Open
$html = \App\Language::translate('LBL_BLOCKED_IP', 'Settings::BruteForce') . ': ' . $this->displayIpAddress($this->textParser->getParam('ip'));
- Exclude checks
Call to method getParam
from undeclared class \App\TextParser
(Did you mean class \Tests\App\TextParser) Open
['>=', 'login_time', $this->textParser->getParam('time')],
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Users_Bruteforce_Textparser extends \App\TextParser\Base
- Exclude checks
The class Users_Bruteforce_Textparser is not named in CamelCase. Open
class Users_Bruteforce_Textparser extends \App\TextParser\Base
{
/** @var string Class name */
public $name = 'LBL_BRUTAL_FORCE';
- 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
Avoid variables with short names like $ip. Configured minimum length is 3. Open
private function displayIpAddress($ip)
- 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
Spaces must be used to indent lines; tabs are not allowed Open
'and',
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
$html .= "<tr><td>{$data['user_name']}</td><td>{$time}</td><td>{$status}</td><td>{$data['browser']}</td><td>{$data['agent']}</td></tr>";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])->orderBy(['login_time' => SORT_DESC])->all();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ipAddress = explode('.', $ip);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$attemptsLogin = (new \App\Db\Query())->from('vtiger_loginhistory')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$status = \App\Language::translate($data['status'], 'Users');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html .= "<tr><td>{$data['user_name']}</td><td>{$time}</td><td>{$status}</td><td>{$data['browser']}</td><td>{$data['agent']}</td></tr>";
- 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 string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $html . '</table>';
- 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 $type = 'mail';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Class name */
- 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
$time = \App\Fields\DateTime::formatToDisplay($data['login_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
public function process()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where([
- 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
/** @var mixed Parser type */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html = \App\Language::translate('LBL_BLOCKED_IP', 'Settings::BruteForce') . ': ' . $this->displayIpAddress($this->textParser->getParam('ip'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html .= '<hr><table border="1" cellspacing="0" style="width:100%"><tr style="font-weight: bold;"><td>' . \App\Language::translate('SINGLE_Users', 'Users') . '</td><td>' . \App\Language::translate('LBL_DATE') . '</td><td>' . \App\Language::translate('LBL_STATUS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_BROWSERS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_USER_AGENT', 'Settings:BruteForce') . '</td></tr>';
- Exclude checks
Line exceeds 120 characters; contains 472 characters Open
$html .= '<hr><table border="1" cellspacing="0" style="width:100%"><tr style="font-weight: bold;"><td>' . \App\Language::translate('SINGLE_Users', 'Users') . '</td><td>' . \App\Language::translate('LBL_DATE') . '</td><td>' . \App\Language::translate('LBL_STATUS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_BROWSERS', 'Settings:BruteForce') . '</td><td>' . \App\Language::translate('LBL_USER_AGENT', 'Settings:BruteForce') . '</td></tr>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['>=', 'login_time', $this->textParser->getParam('time')],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($attemptsLogin as $data) {
- 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
unset($ipAddress[\count($ipAddress) - 1]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to display ip address.
- 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
* @param string $ip
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
$html = \App\Language::translate('LBL_BLOCKED_IP', 'Settings::BruteForce') . ': ' . $this->displayIpAddress($this->textParser->getParam('ip'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return implode('.', $ipAddress) . '.xxx';
- 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 $name = 'LBL_BRUTAL_FORCE';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Process.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['user_ip' => $this->textParser->getParam('ip')],
- 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
private function displayIpAddress($ip)
- Exclude checks
Class name "Users_Bruteforce_Textparser" is not in camel caps format Open
class Users_Bruteforce_Textparser extends \App\TextParser\Base
- Exclude checks