chamilo/chamilo-lms

View on GitHub
public/main/ticket/new_ticket.php

Summary

Maintainability
A
0 mins
Test Coverage

The function save_ticket() has an NPath complexity of 256. The configured NPath complexity threshold is 200.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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

The method save_ticket 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('There was an error registering your ticket')));
    }
Severity: Minor
Found in public/main/ticket/new_ticket.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 "other_area" is not in valid camel caps format
Open

        $other_area,

Missing parameter name
Open

 * @param $name

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

    $file_attachments = $_FILES;

Missing parameter name
Open

 * @param $array

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

        $category_id,

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

function js_array($array, $name, $key)

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

        $file_attachments,

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

function save_ticket()

Missing parameter name
Open

 * @param $key

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

    $course_id = isset($_POST['course_id']) ? (int) $_POST['course_id'] : '';

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

    $project_id = (int) $_POST['project_id'];

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

        $course_id,

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

        $project_id,

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

    $user_id = isset($_POST['user_id']) ? (int) $_POST['user_id'] : null;

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

        $personal_email,

Missing function doc comment
Open

function save_ticket()

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

    $category_id = isset($_POST['category_id']) ? (int) $_POST['category_id'] : '';

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

    $other_area = (int) $_POST['other_area'];

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

        $user_id

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

    $personal_email = $_POST['personal_email'];

The variable $personal_email is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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 $project_id is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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 $other_area is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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 $other_area is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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 $file_attachments is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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 $course_id is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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 $course_id is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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 $category_id is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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_id is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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_id is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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 $category_id is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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 $project_id is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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 $personal_email is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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 $file_attachments is not named in camelCase.
Open

function save_ticket()
{
    $content = $_POST['content'];
    if (!empty($_POST['phone'])) {
        $content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.Security::remove_XSS($_POST['phone']).'</p>';
Severity: Minor
Found in public/main/ticket/new_ticket.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