chamilo/chamilo-lms

View on GitHub
public/main/gradebook/lib/be/evallink.class.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '173', column '29').
Open

                $eval = new Evaluation();

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

            } else {
                $eval = new Evaluation();
                $eval->set_category_id(-1);
                $eval->set_date(api_get_utc_datetime()); // these values will be changed
                $eval->set_weight(0); //   when the link setter

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

Method name "EvalLink::has_results" is not in camel caps format
Open

    public function has_results()

Abstract class name is not prefixed with "Abstract"
Open

abstract class EvalLink extends AbstractLink

Missing function doc comment
Open

    public function get_name()

Method name "EvalLink::get_description" is not in camel caps format
Open

    public function get_description()

Missing function doc comment
Open

    public function get_max()

Method name "EvalLink::add_linked_data" is not in camel caps format
Open

    public function add_linked_data()

Method name "EvalLink::needs_results" is not in camel caps format
Open

    public function needs_results()

Missing function doc comment
Open

    public function get_description()

Missing function doc comment
Open

    public function set_weight($weight)

Missing function doc comment
Open

    public function get_link()

Method name "EvalLink::get_link" is not in camel caps format
Open

    public function get_link()

Method name "EvalLink::needs_max" is not in camel caps format
Open

    public function needs_max()

Method name "EvalLink::delete_linked_data" is not in camel caps format
Open

    public function delete_linked_data()

Missing function doc comment
Open

    public function set_name($name)

Missing function doc comment
Open

    public function set_description($description)

Method name "EvalLink::get_max" is not in camel caps format
Open

    public function get_max()

Doc comment for parameter $userId does not match actual variable name $studentId
Open

     * @param int    $userId

Method name "EvalLink::calc_score" is not in camel caps format
Open

    public function calc_score($studentId = null, $type = null)

Missing function doc comment
Open

    public function needs_name_and_description()

Method name "EvalLink::needs_name_and_description" is not in camel caps format
Open

    public function needs_name_and_description()

Missing function doc comment
Open

    public function set_visible($visible)

Missing function doc comment
Open

    public function add_linked_data()

Missing function doc comment
Open

    public function set_max($max)

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

    public function set_date($date)

Method name "EvalLink::set_weight" is not in camel caps format
Open

    public function set_weight($weight)

Method name "EvalLink::get_name" is not in camel caps format
Open

    public function get_name()

Method name "EvalLink::get_evaluation" is not in camel caps format
Open

    protected function get_evaluation()

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

            if (isset($this->ref_id)) {

Method name "EvalLink::set_max" is not in camel caps format
Open

    public function set_max($max)

Missing function doc comment
Open

    public function save_linked_data()

Method name "EvalLink::set_description" is not in camel caps format
Open

    public function set_description($description)

Method name "EvalLink::set_date" is not in camel caps format
Open

    public function set_date($date)

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

        $this->created_at = $date;

Method name "EvalLink::is_valid_link" is not in camel caps format
Open

    public function is_valid_link()

Missing function doc comment
Open

    public function needs_max()

Method name "EvalLink::set_name" is not in camel caps format
Open

    public function set_name($name)

Missing function doc comment
Open

    public function is_valid_link()

Missing function doc comment
Open

    public function needs_results()

Method name "EvalLink::save_linked_data" is not in camel caps format
Open

    public function save_linked_data()

Missing function doc comment
Open

    public function delete_linked_data()

Method name "EvalLink::set_visible" is not in camel caps format
Open

    public function set_visible($visible)

The method needs_name_and_description is not named in camelCase.
Open

    public function needs_name_and_description()
    {
        return true;
    }

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

    public function set_date($date)
    {
        $this->created_at = $date;
        if ($this->is_valid_link()) {
            $this->evaluation->set_date($date);

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

    public function set_description($description)
    {
        if ($this->is_valid_link()) {
            $this->evaluation->set_description($description);
        }

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

    protected function get_evaluation()
    {
        if (!isset($this->evaluation)) {
            if (isset($this->ref_id)) {
                $evalarray = Evaluation::load($this->get_ref_id());

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

    public function add_linked_data()
    {
        if ($this->is_valid_link()) {
            $this->evaluation->add();
            $this->set_ref_id($this->evaluation->get_id());

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

    public function needs_max()
    {
        return true;
    }

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

    public function get_link()
    {
        $eval = $this->get_evaluation();
        // course/platform admin can go to the view_results page
        if (api_is_allowed_to_edit()) {

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

    public function get_name()
    {
        $eval = $this->get_evaluation();

        return $eval->get_name();

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

    public function is_valid_link()
    {
        $eval = $this->get_evaluation();

        return isset($eval);

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

    public function save_linked_data()
    {
        if ($this->is_valid_link()) {
            $this->evaluation->save();
        }

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

    public function set_name($name)
    {
        if ($this->is_valid_link()) {
            $this->evaluation->set_name($name);
        }

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

    public function set_max($max)
    {
        if ($this->is_valid_link()) {
            $this->evaluation->set_max($max);
        }

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

    public function has_results()
    {
        $eval = $this->get_evaluation();

        return $eval->has_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

The method get_description is not named in camelCase.
Open

    public function get_description()
    {
        $eval = $this->get_evaluation();

        return $eval->get_description();

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

    public function needs_results()
    {
        return true;
    }

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

    public function delete_linked_data()
    {
        if ($this->is_valid_link()) {
            $this->evaluation->delete_with_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

The method get_max is not named in camelCase.
Open

    public function get_max()
    {
        $eval = $this->get_evaluation();

        return $eval->get_max();

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

    public function set_weight($weight)
    {
        $this->weight = $weight;
        if ($this->is_valid_link()) {
            $this->evaluation->set_weight($weight);

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

    public function set_visible($visible)
    {
        $this->visible = $visible;
        if ($this->is_valid_link()) {
            $this->evaluation->set_visible($visible);

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

    public function calc_score($studentId = null, $type = null)
    {
        $eval = $this->get_evaluation();

        return $eval->calc_score($studentId, $type);

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