chamilo/chamilo-lms

View on GitHub
public/main/tracking/lp_report.php

Summary

Maintainability
A
0 mins
Test Coverage

The function prepare_user_sql_query() has an NPath complexity of 8342784. The configured NPath complexity threshold is 200.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 '157', column '27').
Open

        $extraField = new ExtraField('user');
Severity: Minor
Found in public/main/tracking/lp_report.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 prepare_user_sql_query uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $sql .= 'u.lastname AS col3, u.firstname AS col4, ';
        }
Severity: Minor
Found in public/main/tracking/lp_report.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 prepare_user_sql_query uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

    } else {
        $sql .= 'SELECT u.id AS col0, u.official_code AS col2, ';

        if (api_is_western_name_order()) {
            $sql .= 'u.firstname AS col3, u.lastname AS col4, ';
Severity: Minor
Found in public/main/tracking/lp_report.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 getCount uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

    } else {
        // Registered students in session.
        $count = CourseManager::get_student_list_from_course_code(
            $courseCode,
            true,
Severity: Minor
Found in public/main/tracking/lp_report.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 prepare_user_sql_query uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                    } else {
                        $result = UserManager::get_extra_user_data_by_value(
                            $variable,
                            $value
                        );
Severity: Minor
Found in public/main/tracking/lp_report.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 getData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $time = Tracking::get_time_spent_in_lp(
                    $userId,
                    $course,
                    [$lpId],
Severity: Minor
Found in public/main/tracking/lp_report.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 prepare_user_sql_query uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $values = [$_GET['extra_'.$variable]];
                }
Severity: Minor
Found in public/main/tracking/lp_report.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 getData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

    } else {
        // Registered students in session.
        $students = CourseManager::get_student_list_from_course_code(
            $courseCode,
            true,
Severity: Minor
Found in public/main/tracking/lp_report.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

Avoid unused parameters such as '$column'.
Open

function getData($from, $numberOfItems, $column, $direction, $params)
Severity: Minor
Found in public/main/tracking/lp_report.php by phpmd

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 '$direction'.
Open

function getData($from, $numberOfItems, $column, $direction, $params)
Severity: Minor
Found in public/main/tracking/lp_report.php by phpmd

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

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

    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);

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

            $keyword_extra_value

Missing parameter name
Open

 * @param   int     offset of first user to recover

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

        $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);

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

function prepare_user_sql_query($getCount)

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

$is_allowedToTrack = Tracking::isAllowToTrack($sessionId);

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

        $sql .= "SELECT COUNT(u.id) AS total_number_of_items FROM $user_table u";

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

            $query_admin_table = " , $admin_table a ";

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

        $keyword_extra_value = '';

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

            $keyword_admin = ' AND a.user_id = u.id ';

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

if (!$is_allowedToTrack) {

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

    $user_table = Database::get_main_table(TABLE_MAIN_USER);

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

        $sql .= " INNER JOIN $access_url_rel_user_table url_rel_user

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

            $query_admin_table = " , $admin_table a ";

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

                FROM $user_table u";

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

            $keyword_admin

Missing parameter name
Open

 * @param   int     Column to sort on

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

        $query_admin_table = '';

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

function getCount()

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

$tool_name = get_lang('CourseLPsGenericStats');

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

        $sql .= " $query_admin_table

Missing parameter name
Open

 * @param   string  Order (ASC,DESC)

Missing function doc comment
Open

function getCount()

Missing parameter name
Open

 * @param   int     Number of users to get

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

        $keyword_admin = '';

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

function getData($from, $numberOfItems, $column, $direction, $params)

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

$tpl = new Template($tool_name);

The variable $access_url_rel_user_table is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $query_admin_table is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $query_admin_table is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $keyword_admin is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $admin_table is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $admin_table is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $access_url_rel_user_table is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $user_table is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $keyword_extra_value is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $user_table is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $query_admin_table is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $keyword_admin is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $keyword_admin is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $user_table is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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 $keyword_extra_value is not named in camelCase.
Open

function prepare_user_sql_query($getCount)
{
    $sql = '';
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
Severity: Minor
Found in public/main/tracking/lp_report.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