The method getCourseCategoryUrl() has an NPath complexity of 768. The configured NPath complexity threshold is 200. Open
public static function getCourseCategoryUrl(
$pageCurrent,
$pageLength,
$categoryCode = null,
$hiddenLinks = null,
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
Avoid using undefined variables such as '$categories' which will lead to PHP notices. Open
$categories[$cat['id']] = '('.$cat['code'].') '.$cat['title'];
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$categories' which will lead to PHP notices. Open
$categories[''] = '-';
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Missing class import via use statement (line '370', column '26'). Open
$table = new HTML_Table(['class' => 'data_table']);
- 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 '264', column '14'). Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = (int) $tree_pos;
- 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
The method getCatalogPagination uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$pageItemAttributes = ['class' => 'page-item'];
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid assigning values to variables in if clauses and the like (line '273', column '18'). Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = (int) $tree_pos;
- 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 unused parameters such as '$getCount'. Open
$getCount = 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 '$code'. Open
public static function edit($categoryId, $name, $canHaveCourses, $code, $description): ?CourseCategoryEntity
- 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 '$avoidCourses'. Open
$avoidCourses = true,
- 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 '$keyword'. Open
$keyword = '',
- 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 '$conditions'. Open
$conditions = [],
- 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
The parameter $tree_pos is not named in camelCase. Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = (int) $tree_pos;
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $category_code is not named in camelCase. Open
public static function countCoursesInCategory(
$category_code = '',
$keyword = '',
$avoidCourses = true,
$conditions = []
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $parent_id is not named in camelCase. Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = (int) $tree_pos;
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Variable "tbl_category" is not in valid camel caps format Open
FROM $tbl_category t1
- Exclude checks
Variable "tree_pos" is not in valid camel caps format Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
- Exclude checks
Variable "parent_id" is not in valid camel caps format Open
$parent_id = Database::escape_string($parent_id);
- Exclude checks
Variable "tree_pos" is not in valid camel caps format Open
SET tree_pos = '$tree_pos'
- Exclude checks
Missing parameter name Open
* @param $pageNumber
- Exclude checks
Missing class doc comment Open
class CourseCategory
- Exclude checks
Variable "tbl_category" is not in valid camel caps format Open
$tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
- Exclude checks
Missing function doc comment Open
public static function edit($categoryId, $name, $canHaveCourses, $code, $description): ?CourseCategoryEntity
- Exclude checks
Variable "tree_pos" is not in valid camel caps format Open
tree_pos < $tree_pos
- Exclude checks
Variable "tbl_category" is not in valid camel caps format Open
$tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
- Exclude checks
Variable "category_code" is not in valid camel caps format Open
return self::getCoursesInCategory($category_code, $keyword, $avoidCourses, $conditions, true);
- Exclude checks
Variable "parent_id" is not in valid camel caps format Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
- Exclude checks
Variable "parent_id" is not in valid camel caps format Open
$parentIdCondition = " AND parent_id = '$parent_id' ";
- Exclude checks
Variable "tree_pos" is not in valid camel caps format Open
tree_pos > $tree_pos
- Exclude checks
Multi-line function call not indented correctly; expected 28 spaces but found 32 Open
).'\')) return false;',
- Exclude checks
Multi-line function call not indented correctly; expected 32 spaces but found 36 Open
api_htmlentities(sprintf(get_lang('Please confirm your choice')), ENT_QUOTES)
- Exclude checks
Variable "tbl_category" is not in valid camel caps format Open
FROM $tbl_category c
- Exclude checks
Missing parameter name Open
* @param $pageLength
- Exclude checks
Expected 5 spaces after parameter type; 1 found Open
* @param string $content
- Exclude checks
Variable "parent_id" is not in valid camel caps format Open
$parent_id = Database::escape_string($parent_id);
- Exclude checks
Variable "category_code" is not in valid camel caps format Open
$category_code = '',
- Exclude checks
Variable "tree_pos" is not in valid camel caps format Open
->setTreePos($tree_pos)
- Exclude checks
Variable "tree_pos" is not in valid camel caps format Open
$tree_pos = (int) $tree_pos;
- Exclude checks
Doc comment for parameter $parentId does not match actual variable name $description Open
* @param int|null $parentId
- Exclude checks
Variable "parent_id" is not in valid camel caps format Open
if (!empty($parent_id)) {
- Exclude checks
Doc comment for parameter $fileData does not match actual variable name $category Open
* @param array $fileData File data from $_FILES
- Exclude checks
Variable "tbl_course" is not in valid camel caps format Open
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
- Exclude checks
Variable "tree_pos" is not in valid camel caps format Open
$tree_pos = $row['maxTreePos'] + 1;
- Exclude checks
Missing function doc comment Open
public static function listCategories(array $categorySource = []): string
- Exclude checks
Variable "tbl_course" is not in valid camel caps format Open
LEFT JOIN $tbl_course t3
- Exclude checks
Expected 6 spaces after parameter type; 2 found Open
* @param array $liAttributes
- Exclude checks
Missing parameter name Open
* @param $pageLength
- Exclude checks
Missing parameter name Open
* @param $pageCurrent
- Exclude checks
Variable "tree_pos" is not in valid camel caps format Open
$tree_pos = (int) $tree_pos;
- Exclude checks
Missing parameter name Open
* @param $pageTotal
- Exclude checks
Multi-line function call not indented correctly; expected 32 spaces but found 36 Open
api_htmlentities(sprintf(get_lang('Please confirm your choice')), ENT_QUOTES)
- Exclude checks
Multi-line function call not indented correctly; expected 28 spaces but found 32 Open
).'\')) return false;',
- Exclude checks
The variable $parent_id is not named in camelCase. Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = (int) $tree_pos;
- 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 $tbl_category is not named in camelCase. Open
public static function getCategoriesCanBeAddedInCourse($categoryCode)
{
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
$conditions = " INNER JOIN $table a ON (c.id = a.course_category_id)";
$whereCondition = ' AND a.access_url_id = '.api_get_current_access_url_id();
- 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 $parent_id is not named in camelCase. Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = (int) $tree_pos;
- 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 $tree_pos is not named in camelCase. Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = (int) $tree_pos;
- 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 $category_code is not named in camelCase. Open
public static function countCoursesInCategory(
$category_code = '',
$keyword = '',
$avoidCourses = true,
$conditions = []
- 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 $tree_pos is not named in camelCase. Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = (int) $tree_pos;
- 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 $parent_id is not named in camelCase. Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = (int) $tree_pos;
- 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 $tbl_category is not named in camelCase. Open
public static function getCategoriesCanBeAddedInCourse($categoryCode)
{
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
$conditions = " INNER JOIN $table a ON (c.id = a.course_category_id)";
$whereCondition = ' AND a.access_url_id = '.api_get_current_access_url_id();
- 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 $tbl_course is not named in camelCase. Open
public static function getAllCategories()
{
$tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
- 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 $tree_pos is not named in camelCase. Open
public static function add($code, $name, $canHaveCourses, $description = '', $parentId = null): ?CourseCategoryEntity
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = trim($code);
$name = trim($name);
- 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 $tree_pos is not named in camelCase. Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = (int) $tree_pos;
- 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 $tree_pos is not named in camelCase. Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = (int) $tree_pos;
- 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 $tbl_category is not named in camelCase. Open
public static function getAllCategories()
{
$tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
- 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 $tree_pos is not named in camelCase. Open
public static function add($code, $name, $canHaveCourses, $description = '', $parentId = null): ?CourseCategoryEntity
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = trim($code);
$name = trim($name);
- 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 $tbl_category is not named in camelCase. Open
public static function getAllCategories()
{
$tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
- 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 $tbl_course is not named in camelCase. Open
public static function getAllCategories()
{
$tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
- 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 $parent_id is not named in camelCase. Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = (int) $tree_pos;
- 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 $tree_pos is not named in camelCase. Open
public static function moveNodeUp($code, $tree_pos, $parent_id)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = (int) $tree_pos;
- 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();
}
}