chamilo/chamilo-lms

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

Summary

Maintainability
A
0 mins
Test Coverage

Avoid assigning values to variables in if clauses and the like (line '39', column '13').
Open

    public function get_view_url($stud_id)
    {
        // find a file uploaded by the given student,
        // with the same title as the evaluation name

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

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

        } else {
            return null;
        }

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 local variables such as '$fileurl'.
Open

        if ($fileurl = Database::fetch_row($result)) {

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

The parameter $stud_id is not named in camelCase.
Open

    public function get_view_url($stud_id)
    {
        // find a file uploaded by the given student,
        // with the same title as the evaluation name

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

class DropboxLink extends EvalLink
{
    private $dropbox_table = null;

    /**

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 "DropboxLink::get_view_url" is not in camel caps format
Open

    public function get_view_url($stud_id)

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

                    c_id = '.$this->course_id.' AND 

Missing function doc comment
Open

    public function get_type_name()

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

                    uploader_id = '.intval($stud_id)." AND 

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

    public function get_type_name()

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

    public function is_allowed_to_change_name()

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

    public function get_icon_name()

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

    public function get_view_url($stud_id)

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

        $this->dropbox_table = Database::get_course_table(TABLE_DROPBOX_FILE);

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

        return $this->dropbox_table;

Missing function doc comment
Open

    public function is_allowed_to_change_name()

Method name "DropboxLink::get_dropbox_table" is not in camel caps format
Open

    private function get_dropbox_table()

Missing function doc comment
Open

    public function get_icon_name()

The variable $stud_id is not named in camelCase.
Open

    public function get_view_url($stud_id)
    {
        // find a file uploaded by the given student,
        // with the same title as the evaluation name

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

    private function get_dropbox_table()
    {
        $this->dropbox_table = Database::get_course_table(TABLE_DROPBOX_FILE);

        return $this->dropbox_table;

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

    public function get_view_url($stud_id)
    {
        // find a file uploaded by the given student,
        // with the same title as the evaluation 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 get_icon_name is not named in camelCase.
Open

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

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('Dropbox');
    }

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