chamilo/chamilo-lms

View on GitHub
public/main/gradebook/lib/results_data_generator.class.php

Summary

Maintainability
A
0 mins
Test Coverage

The method get_data() has an NPath complexity of 1480. The configured NPath complexity threshold is 200.
Open

    public function get_data(
        $sorting = 0,
        $start = 0,
        $count = null,
        $ignore_score_color = 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

Avoid unused private fields such as '$include_edit'.
Open

    private $include_edit;

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

Avoid unused parameters such as '$include_edit'.
Open

        $include_edit = false

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

    private $is_course_ind;

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

The method sort_by_score uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            return $item1['percentage_score'] < $item2['percentage_score'] ? -1 : 1;
        }

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

            } else {
                $user['score'] = $this->get_score_display(
                    $result->get_score(),
                    true,
                    $ignore_score_color

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

    private function get_score_display(
        $score,
        $realscore,
        $ignore_score_color = false
    ) {

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

The property $include_edit is not named in camelCase.
Open

class ResultsDataGenerator
{
    // Sorting types constants
    const RDG_SORT_LASTNAME = 1;
    const RDG_SORT_FIRSTNAME = 2;

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The parameter $ignore_score_color is not named in camelCase.
Open

    public function get_data(
        $sorting = 0,
        $start = 0,
        $count = null,
        $ignore_score_color = false,

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

The property $is_course_ind is not named in camelCase.
Open

class ResultsDataGenerator
{
    // Sorting types constants
    const RDG_SORT_LASTNAME = 1;
    const RDG_SORT_FIRSTNAME = 2;

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The parameter $include_edit is not named in camelCase.
Open

    public function __construct(
        $evaluation,
        $results = [],
        $include_edit = false
    ) {

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

Method name "ResultsDataGenerator::get_data" is not in camel caps format
Open

    public function get_data(

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

        $number_decimals = api_get_setting('gradebook_number_decimals');

Doc comment for parameter $count does not match actual variable name $sorting
Open

     * @param int $count

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

        $include_edit = false

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

        $ignore_score_color = false

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

                $ignore_score_color

Method name "ResultsDataGenerator::sort_by_mask" is not in camel caps format
Open

    public function sort_by_mask($item1, $item2)

Method name "ResultsDataGenerator::get_score_display" is not in camel caps format
Open

    private function get_score_display(

Method name "ResultsDataGenerator::sort_by_first_name" is not in camel caps format
Open

    public function sort_by_first_name($item1, $item2)

Method name "ResultsDataGenerator::sort_by_score" is not in camel caps format
Open

    public function sort_by_score($item1, $item2)

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

            if ($pdf && null == $number_decimals) {

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

                    $ignore_score_color

Method name "ResultsDataGenerator::get_total_results_count" is not in camel caps format
Open

    public function get_total_results_count()

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

        $ignore_score_color = false,

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

                    $ignore_score_color

Method name "ResultsDataGenerator::sort_by_last_name" is not in camel caps format
Open

    public function sort_by_last_name($item1, $item2)

The variable $number_decimals is not named in camelCase.
Open

    public function get_data(
        $sorting = 0,
        $start = 0,
        $count = null,
        $ignore_score_color = 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 $ignore_score_color is not named in camelCase.
Open

    public function get_data(
        $sorting = 0,
        $start = 0,
        $count = null,
        $ignore_score_color = 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 $number_decimals is not named in camelCase.
Open

    public function get_data(
        $sorting = 0,
        $start = 0,
        $count = null,
        $ignore_score_color = 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 $ignore_score_color is not named in camelCase.
Open

    public function get_data(
        $sorting = 0,
        $start = 0,
        $count = null,
        $ignore_score_color = 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 $ignore_score_color is not named in camelCase.
Open

    private function get_score_display(
        $score,
        $realscore,
        $ignore_score_color = 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 method get_data is not named in camelCase.
Open

    public function get_data(
        $sorting = 0,
        $start = 0,
        $count = null,
        $ignore_score_color = false,

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

    private function get_score_display(
        $score,
        $realscore,
        $ignore_score_color = false
    ) {

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

    public function sort_by_last_name($item1, $item2)
    {
        return api_strcmp($item1['lastname'], $item2['lastname']);
    }

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

    public function sort_by_first_name($item1, $item2)
    {
        return api_strcmp($item1['firstname'], $item2['firstname']);
    }

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

    public function sort_by_score($item1, $item2)
    {
        if ($item1['percentage_score'] == $item2['percentage_score']) {
            return 0;
        } else {

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

    public function sort_by_mask($item1, $item2)
    {
        $score1 = (isset($item1['score']) ? [$item1['score'], $this->evaluation->get_max()] : null);
        $score2 = (isset($item2['score']) ? [$item2['score'], $this->evaluation->get_max()] : 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 get_total_results_count is not named in camelCase.
Open

    public function get_total_results_count()
    {
        return count($this->results);
    }

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