chamilo/chamilo-lms

View on GitHub
public/main/gradebook/lib/fe/resulttable.class.php

Summary

Maintainability
A
0 mins
Test Coverage

The method get_table_data() has an NPath complexity of 792. The configured NPath complexity threshold is 200.
Open

    public function get_table_data(
        $from = 1,
        $perPage = null,
        $column = null,
        $direction = null,

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 '44', column '30').
Open

        $this->datagen = new ResultsDataGenerator($evaluation, $results, true);

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 '26').
Open

        $htmlTable = new HTML_Table(['class' => 'table table-hover table-striped data_table']);

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

        } else {
            $sorting |= ResultsDataGenerator::RDG_SORT_ASC;
        }

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

            } else {
                $editColumn .= '<a href="'.api_get_self().'?editres='.$item['result_id'].'&selecteval='.$this->evaluation->get_id().'&'.api_get_cidreq().'">'.
                    Display::getMdiIcon(ActionIcon::EDIT, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Edit')).'</a>';
            }

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

                } else {
                    $editColumn .= '<a href="'.api_get_self().'?editres='.$item['result_id'].'&selecteval='.$this->evaluation->get_id().'&'.api_get_cidreq().'">'.
                        Display::getMdiIcon(ActionIcon::EDIT, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Edit')).'</a>';
                }

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

                } else {
                    $sorting = ResultsDataGenerator::RDG_SORT_FIRSTNAME;
                }

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

                } else {
                    $sorting = ResultsDataGenerator::RDG_SORT_LASTNAME;
                }

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

            } else {
                $row[] = $item['lastname'];
                $row[] = $item['firstname'];
            }

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

        } else {
            $this->set_header($column++, get_lang('Last name'));
            $this->set_header($column++, get_lang('First name'));
        }

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

        $column = null,

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

        $perPage = null,

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

        $sort = null

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

        $direction = null,

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 private fields such as '$allresults'.
Open

    private $allresults;

UnusedPrivateField

Since: 0.2

Detects when a private field is declared and/or assigned a value, but not used.

Example

class Something
{
    private static $FOO = 2; // Unused
    private $i = 5; // Unused
    private $j = 6;
    public function addOne()
    {
        return $this->j++;
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatefield

Method name "ResultTable::get_total_number_of_items" is not in camel caps format
Open

    public function get_total_number_of_items()

Method name "ResultTable::get_table_data" is not in camel caps format
Open

    public function get_table_data(

Expected 5 spaces after parameter type; 7 found
Open

     * @param ?array       $addparams

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

            case 3 + $col_adjust:

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

        $data_array = $this->datagen->get_data($sorting, $from, $this->per_page);

Expected 1 spaces after parameter type; 3 found
Open

     * @param Evaluation   $evaluation

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

            case 1 + $col_adjust:

Expected 6 spaces after parameter type; 8 found
Open

     * @param ?bool        $forprint

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

            case 0 + $col_adjust:

Expected 5 spaces after parameter type; 7 found
Open

     * @param ?array       $results

Expected 4 spaces after parameter type; 6 found
Open

     * @param ?string      $iscourse

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

        $col_adjust = '1' == $this->iscourse ? 1 : 0;

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

            case 2 + $col_adjust:

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

        $data_array = $this->datagen->get_data($sorting, $from, $this->per_page);

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

            $sortable_data[] = $row;

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

                $editColumn .= '&nbsp;<a href="'.$doc_url.'" target="_blank">';

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

            $doc_url = $link->get_view_url($item['id']);

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

        if (api_is_allowed_to_edit(null, true) && 0 == $locked_status) {

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

        $sortable_data = [];

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

        $locked_status = $this->evaluation->get_locked();

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

            if (null != $doc_url) {

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

        foreach ($data_array as $item) {

Method name "ResultTable::build_edit_column" is not in camel caps format
Open

    private function build_edit_column($item)

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

        return $sortable_data;

The variable $locked_status is not named in camelCase.
Open

    private function build_edit_column($item)
    {
        $locked_status = $this->evaluation->get_locked();
        $allowMultipleAttempts = ('true' === api_get_setting('gradebook.gradebook_multiple_evaluation_attempts'));
        $baseUrl = api_get_self().'?selecteval='.$this->evaluation->get_id().'&'.api_get_cidreq();

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

    public function get_table_data(
        $from = 1,
        $perPage = null,
        $column = null,
        $direction = null,

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

    public function get_table_data(
        $from = 1,
        $perPage = null,
        $column = null,
        $direction = null,

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

    private function build_edit_column($item)
    {
        $locked_status = $this->evaluation->get_locked();
        $allowMultipleAttempts = ('true' === api_get_setting('gradebook.gradebook_multiple_evaluation_attempts'));
        $baseUrl = api_get_self().'?selecteval='.$this->evaluation->get_id().'&'.api_get_cidreq();

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

    public function get_table_data(
        $from = 1,
        $perPage = null,
        $column = null,
        $direction = null,

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

    public function get_table_data(
        $from = 1,
        $perPage = null,
        $column = null,
        $direction = null,

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

    public function get_table_data(
        $from = 1,
        $perPage = null,
        $column = null,
        $direction = null,

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

    public function get_table_data(
        $from = 1,
        $perPage = null,
        $column = null,
        $direction = null,

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

    private function build_edit_column($item)
    {
        $locked_status = $this->evaluation->get_locked();
        $allowMultipleAttempts = ('true' === api_get_setting('gradebook.gradebook_multiple_evaluation_attempts'));
        $baseUrl = api_get_self().'?selecteval='.$this->evaluation->get_id().'&'.api_get_cidreq();

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

    private function build_edit_column($item)
    {
        $locked_status = $this->evaluation->get_locked();
        $allowMultipleAttempts = ('true' === api_get_setting('gradebook.gradebook_multiple_evaluation_attempts'));
        $baseUrl = api_get_self().'?selecteval='.$this->evaluation->get_id().'&'.api_get_cidreq();

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

    public function get_table_data(
        $from = 1,
        $perPage = null,
        $column = null,
        $direction = null,

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

    public function get_table_data(
        $from = 1,
        $perPage = null,
        $column = null,
        $direction = null,

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

    public function get_table_data(
        $from = 1,
        $perPage = null,
        $column = null,
        $direction = null,

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

    private function build_edit_column($item)
    {
        $locked_status = $this->evaluation->get_locked();
        $allowMultipleAttempts = ('true' === api_get_setting('gradebook.gradebook_multiple_evaluation_attempts'));
        $baseUrl = api_get_self().'?selecteval='.$this->evaluation->get_id().'&'.api_get_cidreq();

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

    public function get_table_data(
        $from = 1,
        $perPage = null,
        $column = null,
        $direction = null,

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

    public function get_table_data(
        $from = 1,
        $perPage = null,
        $column = null,
        $direction = null,

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

    private function build_edit_column($item)
    {
        $locked_status = $this->evaluation->get_locked();
        $allowMultipleAttempts = ('true' === api_get_setting('gradebook.gradebook_multiple_evaluation_attempts'));
        $baseUrl = api_get_self().'?selecteval='.$this->evaluation->get_id().'&'.api_get_cidreq();

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

    public function get_total_number_of_items()
    {
        return $this->datagen->get_total_results_count();
    }

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