chamilo/chamilo-lms

View on GitHub
public/main/my_space/course.php

Summary

Maintainability
A
0 mins
Test Coverage

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);
Severity: Minor
Found in public/main/my_space/course.php by phpmd

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();
Severity: Minor
Found in public/main/my_space/course.php by phpmd

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();
Severity: Minor
Found in public/main/my_space/course.php by phpmd

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,
Severity: Minor
Found in public/main/my_space/course.php by phpmd

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,
Severity: Minor
Found in public/main/my_space/course.php by phpmd

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
                );
Severity: Minor
Found in public/main/my_space/course.php by phpmd

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,
Severity: Minor
Found in public/main/my_space/course.php by phpmd

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']);

Variable "a_courses" is not in valid camel caps format
Open

    $a_courses = array_keys($courses);

Variable "menu_items" is not in valid camel caps format
Open

            $menu_items[] = $link;

Variable "nb_courses" is not in valid camel caps format
Open

    return $nb_courses;

Variable "user_id" is not in valid camel caps format
Open

            $courses = CourseManager::get_course_list_of_user_as_course_admin($user_id);

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().'">'.

Consider putting global function "get_count_courses" in a static class
Open

function get_count_courses()

Variable "tematic_advance" is not in valid camel caps format
Open

            $tematic_advance = $thematic->get_total_average_of_thematic_advances($course, $session);

Variable "menu_items" is not in valid camel caps format
Open

        $menu_items[] = Display::url(

Variable "tematic_advance" is not in valid camel caps format
Open

            if (!empty($tematic_advance)) {

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']);

Missing parameter name
Open

 * @param $limit

Variable "user_id" is not in valid camel caps format
Open

            $user_info = api_get_user_info($user_id);

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']);

Variable "menu_items" is not in valid camel caps format
Open

        $menu_items[] = Display::url(

Missing parameter name
Open

 * @param $from

Variable "a_courses" is not in valid camel caps format
Open

    if (count($a_courses) > 0) {

Variable "menu_items" is not in valid camel caps format
Open

        $menu_items[] = Display::url(

Variable "menu_items" is not in valid camel caps format
Open

        $menu_items[] = Display::url(

Variable "nb_menu_items" is not in valid camel caps format
Open

    $nb_menu_items = count($menu_items);

Missing parameter name
Open

 * @param $column

Variable "user_id" is not in valid camel caps format
Open

$user_id = 0;

Variable "menu_items" is not in valid camel caps format
Open

        $menu_items[] = Display::url(

Variable "menu_items" is not in valid camel caps format
Open

        foreach ($menu_items as $key => $item) {

Variable "a_courses" is not in valid camel caps format
Open

$a_courses = [];

Variable "tematic_advance" is not in valid camel caps format
Open

                    $tematic_advance.'%</a>';

Consider putting global function "count_courses" in a static class
Open

function count_courses()

Variable "menu_items" is not in valid camel caps format
Open

    $nb_menu_items = count($menu_items);

Variable "nb_menu_items" is not in valid camel caps format
Open

    if ($nb_menu_items > 1) {

Consider putting global function "get_courses" in a static class
Open

function get_courses($from, $limit, $column, $direction)

Variable "menu_items" is not in valid camel caps format
Open

        $menu_items[] = Display::url(

Missing function doc comment
Open

function count_courses()

Variable "nb_courses" is not in valid camel caps format
Open

    global $nb_courses;

Variable "session_name" is not in valid camel caps format
Open

        $session_name = api_get_session_name($sessionId);

Variable "menu_items" is not in valid camel caps format
Open

        $menu_items[] = Display::url(

Variable "menu_items" is not in valid camel caps format
Open

$menu_items = [];

Variable "user_info" is not in valid camel caps format
Open

            $user_info = api_get_user_info($user_id);

Variable "this_section" is not in valid camel caps format
Open

$this_section = SECTION_TRACKING;

Variable "session_name" is not in valid camel caps format
Open

        $title = $session_name.' : '.get_lang('Courses in this session');

Variable "user_id" is not in valid camel caps format
Open

        if (api_can_login_as($user_id)) {

Missing parameter name
Open

 * @param $direction

The variable $nb_courses is not named in camelCase.
Open

function count_courses()
{
    global $nb_courses;

    return $nb_courses;
Severity: Minor
Found in public/main/my_space/course.php by phpmd

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;
Severity: Minor
Found in public/main/my_space/course.php by phpmd

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);
Severity: Minor
Found in public/main/my_space/course.php by phpmd

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);
Severity: Minor
Found in public/main/my_space/course.php by phpmd

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);
Severity: Minor
Found in public/main/my_space/course.php by phpmd

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

There are no issues that match your filters.

Category
Status