The function get_courses() has an NPath complexity of 497952. The configured NPath complexity threshold is 200. Open
function get_courses($from, $limit, $column, $direction)
{
$userId = api_get_user_id();
$sessionId = isset($_GET['sid']) ? intval($_GET['sid']) : 0;
$session = api_get_session_entity($sessionId);
- 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
Missing class import via use statement (line '323', column '29'). Open
$thematic = new Thematic();
- 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 '347', column '35'). Open
$attendance = new Attendance();
- 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
The method get_courses uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$userList = CourseManager::get_user_list_from_course_code(
$data['code'],
$sessionId,
null,
- 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
The method get_courses uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$courses = CourseManager::getCoursesFollowedByUser(
$userId,
COURSEMANAGER,
$from,
- 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
The method get_count_courses uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$count = SessionManager::getCourseCountBySessionId(
$session->getId(),
$keyword
);
- 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
The method get_count_courses uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$count = CourseManager::getCoursesFollowedByUser(
$userId,
COURSEMANAGER,
null,
- 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
Variable "user_id" is not in valid camel caps format Open
$user_id = intval($_GET['user_id']);
- Exclude checks
Variable "a_courses" is not in valid camel caps format Open
$a_courses = array_keys($courses);
- Exclude checks
Variable "menu_items" is not in valid camel caps format Open
$menu_items[] = $link;
- Exclude checks
Variable "nb_courses" is not in valid camel caps format Open
return $nb_courses;
- Exclude checks
Variable "user_id" is not in valid camel caps format Open
$courses = CourseManager::get_course_list_of_user_as_course_admin($user_id);
- Exclude checks
Variable "user_id" is not in valid camel caps format Open
href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&user_id='.$user_id.'&sec_token='.Security::get_existing_token().'">'.
- Exclude checks
Consider putting global function "get_count_courses" in a static class Open
function get_count_courses()
- Exclude checks
Variable "tematic_advance" is not in valid camel caps format Open
$tematic_advance = $thematic->get_total_average_of_thematic_advances($course, $session);
- Exclude checks
Variable "menu_items" is not in valid camel caps format Open
$menu_items[] = Display::url(
- Exclude checks
Variable "tematic_advance" is not in valid camel caps format Open
if (!empty($tematic_advance)) {
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
$title = get_lang('Courses assigned to').' '.api_get_person_name($user_info['firstname'], $user_info['lastname']);
- Exclude checks
Missing parameter name Open
* @param $limit
- Exclude checks
Variable "user_id" is not in valid camel caps format Open
$user_info = api_get_user_info($user_id);
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
$title = get_lang('Courses assigned to').' '.api_get_person_name($user_info['firstname'], $user_info['lastname']);
- Exclude checks
Variable "menu_items" is not in valid camel caps format Open
$menu_items[] = Display::url(
- Exclude checks
Missing parameter name Open
* @param $from
- Exclude checks
Variable "a_courses" is not in valid camel caps format Open
if (count($a_courses) > 0) {
- Exclude checks
Variable "menu_items" is not in valid camel caps format Open
$menu_items[] = Display::url(
- Exclude checks
Variable "menu_items" is not in valid camel caps format Open
$menu_items[] = Display::url(
- Exclude checks
Variable "nb_menu_items" is not in valid camel caps format Open
$nb_menu_items = count($menu_items);
- Exclude checks
Missing parameter name Open
* @param $column
- Exclude checks
Variable "user_id" is not in valid camel caps format Open
$user_id = 0;
- Exclude checks
Variable "menu_items" is not in valid camel caps format Open
$menu_items[] = Display::url(
- Exclude checks
Variable "menu_items" is not in valid camel caps format Open
foreach ($menu_items as $key => $item) {
- Exclude checks
Variable "a_courses" is not in valid camel caps format Open
$a_courses = [];
- Exclude checks
Variable "tematic_advance" is not in valid camel caps format Open
$tematic_advance.'%</a>';
- Exclude checks
Consider putting global function "count_courses" in a static class Open
function count_courses()
- Exclude checks
Variable "menu_items" is not in valid camel caps format Open
$nb_menu_items = count($menu_items);
- Exclude checks
Variable "nb_menu_items" is not in valid camel caps format Open
if ($nb_menu_items > 1) {
- Exclude checks
Consider putting global function "get_courses" in a static class Open
function get_courses($from, $limit, $column, $direction)
- Exclude checks
Variable "menu_items" is not in valid camel caps format Open
$menu_items[] = Display::url(
- Exclude checks
Missing function doc comment Open
function count_courses()
- Exclude checks
Variable "nb_courses" is not in valid camel caps format Open
global $nb_courses;
- Exclude checks
Variable "session_name" is not in valid camel caps format Open
$session_name = api_get_session_name($sessionId);
- Exclude checks
Variable "menu_items" is not in valid camel caps format Open
$menu_items[] = Display::url(
- Exclude checks
Variable "menu_items" is not in valid camel caps format Open
$menu_items = [];
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
$user_info = api_get_user_info($user_id);
- Exclude checks
Variable "this_section" is not in valid camel caps format Open
$this_section = SECTION_TRACKING;
- Exclude checks
Variable "session_name" is not in valid camel caps format Open
$title = $session_name.' : '.get_lang('Courses in this session');
- Exclude checks
Variable "user_id" is not in valid camel caps format Open
if (api_can_login_as($user_id)) {
- Exclude checks
Missing parameter name Open
* @param $direction
- Exclude checks
The variable $nb_courses is not named in camelCase. Open
function count_courses()
{
global $nb_courses;
return $nb_courses;
- 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 $nb_courses is not named in camelCase. Open
function count_courses()
{
global $nb_courses;
return $nb_courses;
- 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 $tematic_advance is not named in camelCase. Open
function get_courses($from, $limit, $column, $direction)
{
$userId = api_get_user_id();
$sessionId = isset($_GET['sid']) ? intval($_GET['sid']) : 0;
$session = api_get_session_entity($sessionId);
- 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 $tematic_advance is not named in camelCase. Open
function get_courses($from, $limit, $column, $direction)
{
$userId = api_get_user_id();
$sessionId = isset($_GET['sid']) ? intval($_GET['sid']) : 0;
$session = api_get_session_entity($sessionId);
- 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 $tematic_advance is not named in camelCase. Open
function get_courses($from, $limit, $column, $direction)
{
$userId = api_get_user_id();
$sessionId = isset($_GET['sid']) ? intval($_GET['sid']) : 0;
$session = api_get_session_entity($sessionId);
- 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();
}
}