chamilo/chamilo-lms

View on GitHub
public/main/inc/lib/redirect.class.php

Summary

Maintainability
A
0 mins
Test Coverage

The method session_request_uri() has an NPath complexity of 4896. The configured NPath complexity threshold is 200.
Open

    public static function session_request_uri($logging_in = false, $userInfo = null)
    {
        $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;

        if ($no_redirection) {

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

                } else {
                    // if no multiple URL, then it's enough to be platform admin
                    if (api_is_platform_admin_by_id($userId)) {
                        self::navigate(api_get_path(WEB_CODE_PATH).'admin/index.php');
                    }

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

    public static function session_request_uri($logging_in = false, $userInfo = null)
    {
        $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;

        if ($no_redirection) {

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

        if ($is_full_uri) {

Method name "Redirect::session_request_uri" is not in camel caps format
Open

    public static function session_request_uri($logging_in = false, $userInfo = null)

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

            $page_after_login = api_get_setting('page_after_login');

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

                $user_status = $userInfo['status'];

Method name "Redirect::user_home" is not in camel caps format
Open

    public static function user_home()

Missing parameter name
Open

     * @param bool Whether the user just logged in (in this case, use page_after_login rules)

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

        $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;

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

        if ($no_redirection) {

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

    public static function session_request_uri($logging_in = false, $userInfo = null)

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

            if (!empty($page_after_login)) {

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

                switch ($user_status) {

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

        } elseif ($logging_in ||

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

        $is_full_uri = (0 === strpos($url, 'http'));

Missing parameter name
Open

     * @param int  The user_id, if defined. Otherwise just send to where the page_after_login setting says

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

                self::navigate(api_get_path(WEB_PATH).$page_after_login);

The variable $page_after_login is not named in camelCase.
Open

    public static function session_request_uri($logging_in = false, $userInfo = null)
    {
        $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;

        if ($no_redirection) {

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

    public static function session_request_uri($logging_in = false, $userInfo = null)
    {
        $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;

        if ($no_redirection) {

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

    public static function go($url = '')
    {
        if (empty($url)) {
            self::session_request_uri();
            $www = self::www();

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

    public static function go($url = '')
    {
        if (empty($url)) {
            self::session_request_uri();
            $www = self::www();

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

    public static function session_request_uri($logging_in = false, $userInfo = null)
    {
        $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;

        if ($no_redirection) {

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

    public static function session_request_uri($logging_in = false, $userInfo = null)
    {
        $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;

        if ($no_redirection) {

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

    public static function session_request_uri($logging_in = false, $userInfo = null)
    {
        $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;

        if ($no_redirection) {

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

    public static function session_request_uri($logging_in = false, $userInfo = null)
    {
        $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;

        if ($no_redirection) {

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

    public static function session_request_uri($logging_in = false, $userInfo = null)
    {
        $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;

        if ($no_redirection) {

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

    public static function session_request_uri($logging_in = false, $userInfo = null)
    {
        $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;

        if ($no_redirection) {

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

    public static function session_request_uri($logging_in = false, $userInfo = null)
    {
        $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;

        if ($no_redirection) {

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method user_home is not named in camelCase.
Open

    public static function user_home()
    {
        $www = self::www();
        self::navigate("$www/user_portal.php");
    }

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status