Missing class import via use statement (line '13', column '17'). Open
$item = new ELearn_Topic();
- 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 '44', column '19'). Open
throw new Pluf_Exception(__('Part name must not be new, find'));
- 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 '55', column '15'). Open
throw new Pluf_Exception(sprintf(__('Part with the same name exist (name: %s'), $name));
- 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 '84', column '15'). Open
throw new Pluf_Exception_DoesNotExist("Part not found (Part name:" . $name . ")");
- 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 '10', column '14'). Open
$q = new Pluf_SQL('title=%s', array(
- 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 '67', column '14'). Open
$q = new Pluf_SQL('name=%s', array(
- 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 '46', column '14'). Open
$q = new Pluf_SQL('name=%s', array(
- 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 '70', column '17'). Open
$item = new ELearn_Part();
- 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 'Pluf_Log' in method 'ELearn_Shortcuts_GetPartByNameOr404'. Open
Pluf_Log::error(
sprintf(
'more than one Part exist with the name $s', $name));
- 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 "filter" 4 times. Open
'filter' => $q->gen()
- 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.
Add curly braces around the nested statement(s). Open
if ($count > 30)
- Read upRead up
- Exclude checks
While not technically incorrect, the omission of curly braces can be misleading, and may lead to the introduction of errors during maintenance.
Noncompliant Code Example
if (condition) // Noncompliant executeSomething();
Compliant Solution
if (condition) { executeSomething(); }
See
- MISRA C:2004, 14.8 - The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement
- MISRA C:2004, 14.9 - An if (expression) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement
- MISRA C++:2008, 6-3-1 - The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement
- MISRA C++:2008, 6-4-1 - An if (condition) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement
- MISRA C:2012, 15.6 - The body of an iteration-statement or a selection-statement shall be a compound-statement
- CERT, EXP19-C. - Use braces for the body of an if, for, or while statement
- CERT, EXP52-J. - Use braces for the body of an if, for, or while statement
Call to method __construct
from undeclared class \Pluf_Exception
Open
throw new Pluf_Exception(sprintf(__('Part with the same name exist (name: %s'), $name));
- Exclude checks
Call to method error
from undeclared class \Pluf_Log
Open
Pluf_Log::error(
- Exclude checks
Reference to instance property REQUEST
from undeclared class \Pluf_HTTP_Request
Open
$count = array_key_exists('_px_c', $request->REQUEST) ? intval($request->REQUEST['_px_c']) : 30;
- Exclude checks
Call to method gen
from undeclared class \Pluf_SQL
Open
'filter' => $q->gen()
- Exclude checks
Call to method __construct
from undeclared class \Pluf_SQL
Open
$q = new Pluf_SQL('name=%s', array(
- Exclude checks
Call to method gen
from undeclared class \Pluf_SQL
Open
'filter' => $q->gen()
- Exclude checks
Call to undeclared function \__()
(Did you mean _()) Open
throw new Pluf_Exception(sprintf(__('Part with the same name exist (name: %s'), $name));
- Exclude checks
@throws type of ELearn_Shortcuts_GetPartByNameOr404
has undeclared type \CMS_Exception_ObjectNotFound
Open
function ELearn_Shortcuts_GetPartByNameOr404 ($name)
- Exclude checks
Call to method __construct
from undeclared class \Pluf_SQL
Open
$q = new Pluf_SQL('name=%s', array(
- Exclude checks
Call to method getList
from undeclared class \Pluf_Model
Open
$items = $model->getList(
- Exclude checks
Call to undeclared function \__()
(Did you mean _()) Open
throw new Pluf_Exception(__('Part name must not be new, find'));
- Exclude checks
@throws type of ELearn_Shortcuts_CleanName
has undeclared type \Pluf_Exception
Open
function ELearn_Shortcuts_CleanName($name)
- Exclude checks
Parameter $model
has undeclared type \Pluf_Model
Open
function ELearn_Shortcuts_FindAll($model, $filter, $sort){
- Exclude checks
Call to method factory
from undeclared class \Pluf
Open
$items = Pluf::factory('ELearn_Part')->getList(array(
- Exclude checks
Call to method __construct
from undeclared class \Pluf_SQL
Open
$q = new Pluf_SQL('title=%s', array(
- Exclude checks
Call to method __construct
from undeclared class \Pluf_Exception
Open
throw new Pluf_Exception(__('Part name must not be new, find'));
- Exclude checks
Call to method __construct
from undeclared class \Pluf_Exception_DoesNotExist
Open
throw new Pluf_Exception_DoesNotExist("Part not found (Part name:" . $name . ")");
- Exclude checks
Call to undeclared method \ELearn_Topic::getList
Open
$item = $item->getList(array(
- Exclude checks
Call to method gen
from undeclared class \Pluf_SQL
Open
'filter' => $q->gen()
- Exclude checks
Call to undeclared method \ELearn_Part::getList
Open
$item = $item->getList(
- Exclude checks
Call to method count
on non-class type null
Open
if ($item->count() > 1) {
- Exclude checks
Avoid variables with short names like $q. Configured minimum length is 3. Open
$q = new Pluf_SQL('name=%s', array(
- 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
Avoid variables with short names like $q. Configured minimum length is 3. Open
$q = new Pluf_SQL('name=%s', array(
- 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
Avoid variables with short names like $q. Configured minimum length is 3. Open
$q = new Pluf_SQL('title=%s', array(
- 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
Expected 0 spaces before opening parenthesis; 1 found Open
function ELearn_Shortcuts_GetPartByNameOr404 ($name)
- Exclude checks
Expected "function abc(...)"; found "function abc (...)" Open
function ELearn_Shortcuts_GetPartByNameOr404 ($name)
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
'more than one Part exist with the name $s', $name));
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
'more than one Part exist with the name $s', $name));
- Exclude checks
Inline control structures are not allowed Open
if ($count > 30)
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
* بررسی میکند که آیا محتویی هم نام با نام در نظر گرفته شده در ملک وجود دارد
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
* نام یک محتوی باید در یک ملک به صورت انحصاری تعیین شود. بنابر این روال
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
'more than one Part exist with the name $s', $name));
- Exclude checks
Whitespace found at end of line Open
* @param string $name
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
));
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
));
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
'more than one Part exist with the name $s', $name));
- Exclude checks
Opening brace should be on a new line Open
function ELearn_Shortcuts_FindAll($model, $filter, $sort){
- Exclude checks
Whitespace found at end of line Open
*
- Exclude checks
Expected 1 newline at end of file; 0 found Open
}
- Exclude checks
Whitespace found at end of line Open
*
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 16 Open
'more than one Part exist with the name $s', $name));
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
));
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
));
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
'more than one Part exist with the name $s', $name));
- Exclude checks