chamilo/chamilo-lms

View on GitHub
public/main/admin/user_update_import.php

Summary

Maintainability
A
0 mins
Test Coverage

The function updateUsers() has an NPath complexity of 23224322. The configured NPath complexity threshold is 200.
Open

function updateUsers(
    $users,
    $resetPassword = false,
    $sendEmail = false)
{

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

The function validate_data() has an NPath complexity of 757. The configured NPath complexity threshold is 200.
Open

function validate_data($users)
{
    global $defined_auth_sources;
    $errors = [];
    $usernames = [];

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 '230', column '19').
Open

        throw new Exception(get_lang('NoDataAvailable'));

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 '28', column '22').
Open

    $usergroup = new UserGroupModel();

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 '238', column '23').
Open

            throw new Exception(get_lang('ThisFieldIsRequired').': UserName');

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 '96', column '22').
Open

    $usergroup = new UserGroupModel();

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 updateUsers uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                if (isset($user['Password'])) {
                    $changePassMethod = 2;
                    $password = $user['Password'];
                }

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 validate_data uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $classExistList[] = $info['id'];
                }

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 "defined_auth_sources" is not in valid camel caps format
Open

    global $defined_auth_sources;

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

            if (!in_array($user['AuthSource'], $defined_auth_sources)) {

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

function updateUsers(

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

            global $extra_fields;

The closing parenthesis of a multi-line function declaration must be on a new line
Open

    $sendEmail = false)

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

$purification_option_for_usernames = false;

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

function parse_csv_data($file)

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Open

{

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

            foreach ($extra_fields as $extras) {

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

                        $user_id,

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

            $userUpdated = api_get_user_info($user_id);

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

function parse_xml_data($file)

Missing function doc comment
Open

function parse_xml_data($file)

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

            $user_id = $userInfo['user_id'];

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

function validate_data($users)

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

                $user_id,

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

                        [$user_id],

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

                        CourseManager::subscribeUser($user_id, $courseInfo['real_id'], $user['Status']);

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

if ($count_fields > 0) {

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

        $list_reponse[] = 'xxx';

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

        $result_xml .= $spaces.'<'.$extra[1].'>xxx</'.$extra[1].'>';

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

if (count($list_reponse) > 0) {

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

$this_section = SECTION_PLATFORM_ADMIN;

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

    $defined_auth_sources = array_merge($defined_auth_sources, array_keys($extAuthSource));

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

    $content .= implode(';', $list_reponse).';';

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

        if ($i != $count_fields - 1) {

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

$defined_auth_sources[] = PLATFORM_AUTH_SOURCE;

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

Display::display_header($tool_name);

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

$count_fields = count($extra_fields);

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

$form->addHeader($tool_name);

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

$list_reponse = [];

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

$count_fields = count($extra_fields);

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

    $defined_auth_sources = array_merge($defined_auth_sources, array_keys($extAuthSource));

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

$extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', true);

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

$result_xml = '';

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

    foreach ($extra_fields as $extra) {

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

            $result_xml .= '<br/>';

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

$tool_name = get_lang('UpdateUserListXMLCSV');

The variable $user_id is not named in camelCase.
Open

function updateUsers(
    $users,
    $resetPassword = false,
    $sendEmail = false)
{

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 $extra_fields is not named in camelCase.
Open

function updateUsers(
    $users,
    $resetPassword = false,
    $sendEmail = false)
{

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_id is not named in camelCase.
Open

function updateUsers(
    $users,
    $resetPassword = false,
    $sendEmail = false)
{

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 $extra_fields is not named in camelCase.
Open

function updateUsers(
    $users,
    $resetPassword = false,
    $sendEmail = false)
{

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_id is not named in camelCase.
Open

function updateUsers(
    $users,
    $resetPassword = false,
    $sendEmail = false)
{

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 $defined_auth_sources is not named in camelCase.
Open

function validate_data($users)
{
    global $defined_auth_sources;
    $errors = [];
    $usernames = [];

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_id is not named in camelCase.
Open

function updateUsers(
    $users,
    $resetPassword = false,
    $sendEmail = false)
{

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 $defined_auth_sources is not named in camelCase.
Open

function validate_data($users)
{
    global $defined_auth_sources;
    $errors = [];
    $usernames = [];

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_id is not named in camelCase.
Open

function updateUsers(
    $users,
    $resetPassword = false,
    $sendEmail = false)
{

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_id is not named in camelCase.
Open

function updateUsers(
    $users,
    $resetPassword = false,
    $sendEmail = false)
{

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