chamilo/chamilo-lms

View on GitHub
public/main/plagiarism/compilatio/upload.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '114', column '23').
Open

    $compilatio = new Compilatio();

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

        } else {
            $filename = $documentUrl;
        }

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

    } else {
        echo Display::return_message(get_lang('Error'), 'error');
    }

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

    } else {
        $pieces = explode('/', $doc->url);
        $nbPieces = count($pieces);
        $filename = $pieces[$nbPieces - 1];
        $compilatioId = $compilatio->sendDoc($doc->title, '', $filename, $mime, file_get_contents($filePath));

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

Multi-line function call not indented correctly; expected 28 spaces but found 32
Open

                                $compilatio->getWgetUri()

Consider putting global function "getFilename" in a static class
Open

function getFilename($txt)

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

                        file_get_contents($LocalWrkUrl)

Missing function doc comment
Open

function sendDocument($documentId, $courseInfo)

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

                $WrkUrl = $currentCourseRepositoryWeb.$doc->url;

Multi-line function call not indented correctly; expected 28 spaces but found 32
Open

                                '',

Multi-line function call not indented correctly; expected 24 spaces but found 28
Open

                            ).'/'.$courseInfo['path'].'/'.$doc->url;

Missing parameter name
Open

 * @param $courseId

Missing function doc comment
Open

function getFileExtension($filename)

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

                $LocalWrkUrl = $courseInfo['course_sys_path'].$doc->url;

Consider putting global function "sendDocument" in a static class
Open

function sendDocument($documentId, $courseInfo)

Consider putting global function "getFileExtension" in a static class
Open

function getFileExtension($filename)

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

                        $filename = $WrkUrl;

Missing function doc comment
Open

function getWorkTitle($docId, $courseId)

Multi-line function call not indented correctly; expected 28 spaces but found 32
Open

                                '/$',

Missing parameter name
Open

 * @param $docId

Consider putting global function "workDocExtension" in a static class
Open

function workDocExtension($docId, $courseId)

Consider putting global function "getWorkTitle" in a static class
Open

function getWorkTitle($docId, $courseId)

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

    $work_folder = getWorkFolder($urlFile);

Missing function doc comment
Open

function compilatioUpdateWorkDocument($docId, $courseId)

Missing function doc comment
Open

function getFilename($txt)

Consider putting global function "getWorkFolder" in a static class
Open

function getWorkFolder($txt)

Consider putting global function "getShortFilename" in a static class
Open

function getShortFilename($txt)

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

        $sql = "UPDATE $workTable SET url='".$work_folder.$newestFilename."'

Consider putting global function "compilatioUpdateWorkDocument" in a static class
Open

function compilatioUpdateWorkDocument($docId, $courseId)

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

    $_course = api_get_course_info();

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

    $coursePath = $_course['course_sys_path'];

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

    if ('' != $extensionFile && '' == $urlFile_ext) {

Missing function doc comment
Open

function getShortFilename($txt)

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

        rename($coursePath.$urlFile, $coursePath.$work_folder.$newestFilename);

Missing function doc comment
Open

function getWorkFolder($txt)

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

    $urlFile_ext = getFileExtension($urlFile);

Multi-line function call not indented correctly; expected 28 spaces but found 32
Open

                                '',

Multi-line function call not indented correctly; expected 28 spaces but found 32
Open

                                '/$',

Multi-line function call not indented correctly; expected 28 spaces but found 32
Open

                                $compilatio->getWgetUri()

Multi-line function call not indented correctly; expected 24 spaces but found 28
Open

                            ).'/'.$courseInfo['path'].'/'.$doc->url;

The variable $_course is not named in camelCase.
Open

function compilatioUpdateWorkDocument($docId, $courseId)
{
    $_course = api_get_course_info();

    $docId = (int) $docId;

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

function compilatioUpdateWorkDocument($docId, $courseId)
{
    $_course = api_get_course_info();

    $docId = (int) $docId;

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

function compilatioUpdateWorkDocument($docId, $courseId)
{
    $_course = api_get_course_info();

    $docId = (int) $docId;

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

function compilatioUpdateWorkDocument($docId, $courseId)
{
    $_course = api_get_course_info();

    $docId = (int) $docId;

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

function compilatioUpdateWorkDocument($docId, $courseId)
{
    $_course = api_get_course_info();

    $docId = (int) $docId;

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

function compilatioUpdateWorkDocument($docId, $courseId)
{
    $_course = api_get_course_info();

    $docId = (int) $docId;

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

function compilatioUpdateWorkDocument($docId, $courseId)
{
    $_course = api_get_course_info();

    $docId = (int) $docId;

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

There are no issues that match your filters.

Category
Status