chamilo/chamilo-lms

View on GitHub
public/main/exercise/tests_category.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '129', column '21').
Open

        $form = new FormValidator(

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 '217', column '17').
Open

    $form = new FormValidator('note', 'post', api_get_self().'?action='.$action.'&'.api_get_cidreq());

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

        $objcat = new TestCategory();

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 '195', column '25').
Open

        $category = new TestCategory();

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 '107', column '17').
Open

    $form = new FormValidator('import', 'post', api_get_self().'?action=import_category&'.api_get_cidreq());

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 '236', column '29').
Open

            $category = new TestCategory();

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 '164', column '33').
Open

                $category = new TestCategory();

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

            } else {
                Display::addFlash(Display::return_message(get_lang('Already exists'), 'warning'));
            }

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

    } else {
        Display::addFlash(Display::return_message(get_lang('Error: could not delete category'), 'error'));
    }

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

    } else {
        $token = Security::get_token();
        $form->addElement('hidden', 'sec_token');
        $form->setConstants(['sec_token' => $token]);

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

                } else {
                    Display::addFlash(Display::return_message(get_lang('Edit categoryError'), 'error'));
                }

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

        } else {
            $token = Security::get_token();
            $form->addElement('hidden', 'sec_token');
            $form->setConstants(['sec_token' => $token]);

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

        } else {
            Display::addFlash(Display::return_message(get_lang('Error: could not delete category'), 'error'));
        }

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

    } else {
        Display::addFlash(
            Display::return_message(get_lang('Could not edit category'), 'error')
        );
    }

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

$this_section = SECTION_COURSES;

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

function delete_category_form()

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

function add_category_form($action)

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

function edit_category_form($action)

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

function importCategoryForm()

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

        $objcat = $objcat->getCategory($category_id);

You must use "/**" style comments for a function comment
Open

function delete_category_form()

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

function displayActionBar()

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

        $category_id = (int) $_GET['id'];

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

            api_get_self().'?action='.$action.'&id='.$category_id.'&'.api_get_cidreq()

You must use "/**" style comments for a function comment
Open

function displayActionBar()

The variable $category_id is not named in camelCase.
Open

function edit_category_form($action)
{
    $action = Security::remove_XSS($action);
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $category_id = (int) $_GET['id'];

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

function edit_category_form($action)
{
    $action = Security::remove_XSS($action);
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $category_id = (int) $_GET['id'];

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

function edit_category_form($action)
{
    $action = Security::remove_XSS($action);
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $category_id = (int) $_GET['id'];

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