Method init
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
function init()
{
$this->_a['table'] = 'elearn_course';
$this->_a['verbose'] = 'ELearn_Course';
$this->_a['cols'] = array(
The method preSave has a boolean flag argument $create, which is a certain sign of a Single Responsibility Principle violation. Open
function preSave($create = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method postSave has a boolean flag argument $create, which is a certain sign of a Single Responsibility Principle violation. Open
function postSave($create = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Define a constant instead of duplicating this literal "editable" 8 times. Open
'editable' => false,
- 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 "readable" 8 times. Open
'readable' => true
- 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 "Pluf_DB_Field_Varchar" 4 times. Open
'type' => 'Pluf_DB_Field_Varchar',
- 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 "blank" 7 times. Open
'blank' => false,
- 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.
Remove this commented out code. Open
// );
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Avoid unused parameters such as '$create'. Open
function postSave($create = false)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$create'. Open
function preSave($create = false)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Reference to undeclared property \ELearn_Course->creation_dtime
Open
$this->creation_dtime = gmdate('Y-m-d H:i:s');
- Exclude checks
Reference to undeclared property \ELearn_Course->_a
Open
$this->_a['cols'] = array(
- Exclude checks
Reference to undeclared property \ELearn_Course->_a
Open
$this->_a['table'] = 'elearn_course';
- Exclude checks
Class extends undeclared class \Pluf_Model
Open
class ELearn_Course extends Pluf_Model
- Exclude checks
Reference to undeclared property \ELearn_Course->_a
Open
$this->_a['verbose'] = 'ELearn_Course';
- Exclude checks
Reference to undeclared property \ELearn_Course->id
Open
if ($this->id == '') {
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class ELearn_Course extends Pluf_Model
- Exclude checks
The class ELearn_Course is not named in CamelCase. Open
class ELearn_Course extends Pluf_Model
{
/**
* @brief مدل دادهای را بارگذاری میکند.
- 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
Visibility must be declared on method "preSave" Open
function preSave($create = false)
- Exclude checks
Visibility must be declared on method "postSave" Open
function postSave($create = false)
- Exclude checks
Visibility must be declared on method "preDelete" Open
function preDelete()
- Exclude checks
Visibility must be declared on method "init" Open
function init()
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
* در این متد فایل مربوط به است حذف می شود. این عملیات قابل بازگشت نیست
- Exclude checks
Class name "ELearn_Course" is not in camel caps format Open
class ELearn_Course extends Pluf_Model
- Exclude checks