chamilo/chamilo-lms

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

Summary

Maintainability
A
0 mins
Test Coverage

The method calc_score() has an NPath complexity of 2880. The configured NPath complexity threshold is 200.
Open

    public function calc_score($studentId = null, $type = null)
    {
        $studentId = (int) $studentId;
        $em = Database::getManager();
        $assignment = $this->getStudentPublication();

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 methods such as 'get_studpub_table'.
Open

    private function get_studpub_table()
    {
        return $this->studpub_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
    }

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

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

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

        } else {
            $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a
                    WHERE
                        a.active = :active AND
                        a.publicationParent = :parent AND

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

class StudentPublicationLink extends AbstractLink
{
    private $studpub_table;

    public function __construct()

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

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

    public function get_link()

Method name "StudentPublicationLink::get_type_name" is not in camel caps format
Open

    public function get_type_name()

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

        if (empty($this->course_id)) {

Missing function doc comment
Open

    public function get_link()

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

        return $this->studpub_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);

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

    public function has_results()

Missing function doc comment
Open

    public function get_description()

Missing function doc comment
Open

    public function needs_max()

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

            $work_name = $data->getTitle();

Missing function doc comment
Open

    public function needs_results()

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

    public function is_valid_link()

Missing function doc comment
Open

    public function get_icon_name()

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

    public function needs_name_and_description()

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

    public function needs_max()

Method name "StudentPublicationLink::get_icon_name" is not in camel caps format
Open

    public function get_icon_name()

Missing function doc comment
Open

    public function __construct()

Missing function doc comment
Open

    public function is_allowed_to_change_name()

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

                $work_name = basename($data->getUrl());

Method name "StudentPublicationLink::is_allowed_to_change_name" is not in camel caps format
Open

    public function is_allowed_to_change_name()

Missing function doc comment
Open

    public function save_linked_data()

Method name "StudentPublicationLink::get_all_links" is not in camel caps format
Open

    public function get_all_links()

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

    public function save_linked_data()

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

    public function delete_linked_data()

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

            if (empty($work_name)) {

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

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

Missing function doc comment
Open

    public function get_name()

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

    public function get_name()

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

    public function needs_results()

Missing function doc comment
Open

    public function is_valid_link()

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

            $cats[] = [$data->getIid(), $work_name];

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

        $qb = $repo->findAllByCourse(api_get_course_entity($this->course_id), $session, null, 1, 'folder');

Method name "StudentPublicationLink::get_studpub_table" is not in camel caps format
Open

    private function get_studpub_table()

Missing function doc comment
Open

    public function needs_name_and_description()

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

    public function get_description()

The variable $work_name is not named in camelCase.
Open

    public function get_all_links()
    {
        if (empty($this->course_id)) {
            return [];
        }

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

    public function get_all_links()
    {
        if (empty($this->course_id)) {
            return [];
        }

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

    public function get_all_links()
    {
        if (empty($this->course_id)) {
            return [];
        }

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

    public function get_all_links()
    {
        if (empty($this->course_id)) {
            return [];
        }

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

    public function get_name()
    {
        $studentPublication = $this->getStudentPublication();
        $title = $studentPublication->getTitle();

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()
    {
        $studentPublication = $this->getStudentPublication();

        if (empty($studentPublication)) {

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

    public function get_all_links()
    {
        if (empty($this->course_id)) {
            return [];
        }

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()
    {
        /*$data = $this->get_exercise_data();
        if (empty($data)) {
            return '';

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()
    {
        $studentPublication = $this->getStudentPublication();
        $sessionId = $this->get_session_id();
        $url = api_get_path(WEB_PATH).'main/work/work.php?'.

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()
    {
        $studentPublication = $this->getStudentPublication();

        return null !== $studentPublication;

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

    private function get_studpub_table()
    {
        return $this->studpub_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
    }

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)
    {
        $studentId = (int) $studentId;
        $em = Database::getManager();
        $assignment = $this->getStudentPublication();

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()
    {
        $studentPublication = $this->getStudentPublication();

        return $studentPublication->getDescription();

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

    public function get_icon_name()
    {
        return 'studentpublication';
    }

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

    public function needs_name_and_description()
    {
        return 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 needs_results is not named in camelCase.
Open

    public function needs_results()
    {
        return 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 is_allowed_to_change_name is not named in camelCase.
Open

    public function is_allowed_to_change_name()
    {
        return 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_type_name is not named in camelCase.
Open

    public function get_type_name()
    {
        return get_lang('Assignments');
    }

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()
    {
        $studentPublication = $this->getStudentPublication();

        if (empty($studentPublication)) {

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