chamilo/chamilo-lms

View on GitHub
public/main/survey/survey_question.php

Summary

Maintainability
A
0 mins
Test Coverage

The method addParentMenu() has an NPath complexity of 384. The configured NPath complexity threshold is 200.
Open

    public function addParentMenu($formData, FormValidator $form, $surveyData)
    {
        $surveyId = $surveyData['iid'];
        $questionId = isset($formData['question_id']) ? $formData['question_id'] : 0;
        $parentId = isset($formData['parent_id']) ? $formData['parent_id'] : 0;

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

The method createForm() has an NPath complexity of 133120. The configured NPath complexity threshold is 200.
Open

    public function createForm($surveyData, $formData)
    {
        $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null;
        $questionId = isset($_GET['question_id']) ? (int) $_GET['question_id'] : null;
        $surveyId = isset($_GET['survey_id']) ? (int) $_GET['survey_id'] : null;

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

The method preSave() has an NPath complexity of 4815360. The configured NPath complexity threshold is 200.
Open

    public function preSave($formData)
    {
        $counter = Session::read('answer_count');
        $answerList = Session::read('answer_list');

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

The class survey_question has a coupling between objects value of 21. Consider to reduce the number of dependencies under 13.
Open

class survey_question
{
    public $buttonList = [];
    /** @var FormValidator */
    private $form;

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

Missing class import via use statement (line '128', column '28').
Open

                return new ch_yesno();

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

Missing class import via use statement (line '124', column '28').
Open

                return new ch_personality();

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

Missing class import via use statement (line '132', column '28').
Open

                return new ch_multiplechoiceother();

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

Missing class import via use statement (line '216', column '21').
Open

        $form = new FormValidator('question_form', 'post', $url);

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

Missing class import via use statement (line '116', column '28').
Open

                return new ch_multipleresponse();

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

Missing class import via use statement (line '118', column '28').
Open

                return new ch_open();

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

Missing class import via use statement (line '126', column '28').
Open

                return new ch_score();

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

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

                return new ch_multiplechoice();

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

Missing class import via use statement (line '120', column '28').
Open

                return new ch_pagebreak();

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

Missing class import via use statement (line '112', column '28').
Open

                return new ch_dropdown();

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

Missing class import via use statement (line '130', column '28').
Open

                return new ch_selectivedisplay();

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

Missing class import via use statement (line '110', column '28').
Open

                return new ch_comment();

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

Missing class import via use statement (line '122', column '28').
Open

                return new ch_percentage();

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

        } else {
            $this->buttonList[] = $this->getForm()->addButtonSave(get_lang('Create question'), 'save', true);
        }

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

                } else {
                    // keep as is
                    $newAnswers[$key] = $value;
                    if (isset($formData['answersid'])) {
                        $newAnswersId[$key] = $formData['answersid'][$key];

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

            } else {
                $this->getForm()->addHtml('
                    <div class="form-group">
                        <label class="col-sm-2 control-label"></label>
                        <div class="col-sm-8">

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 parameters such as '$questionData'.
Open

    public function render(FormValidator $form, $questionData = [], $answers = [])

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 parameters such as '$answers'.
Open

    public function render(FormValidator $form, $questionData = [], $answers = [])

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 parameters such as '$form'.
Open

    public function render(FormValidator $form, $questionData = [], $answers = [])

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

The class survey_question is not named in CamelCase.
Open

class survey_question
{
    public $buttonList = [];
    /** @var FormValidator */
    private $form;

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

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

            $sql = 'SELECT id, title FROM '.$table_survey_question_group.'

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                'ch-tool-icon',

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                $toolName

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                null,

Doc comment for parameter $questionData does not match actual variable name $form
Open

     * @param array $questionData

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                ICON_SIZE_SMALL,

Doc comment for parameter $surveyData does not match actual variable name $formData
Open

     * @param array $surveyData

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                SurveyManager::icon_question($type),

Doc comment for parameter $answers does not match actual variable name $questionData
Open

     * @param array $answers

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            ).' ';

Missing function doc comment
Open

    public function save(CSurvey $survey, array $formData, array $dataFromDatabase = [])

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

            $table_survey_question_group = Database::get_course_table(TABLE_SURVEY_QUESTION_GROUP);

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                null,

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                SurveyManager::icon_question($type),

Class name "survey_question" is not in camel caps format
Open

class survey_question

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                'ch-tool-icon',

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                $toolName

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            ).' ';

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                ICON_SIZE_SMALL,

The variable $table_survey_question_group is not named in camelCase.
Open

    public function createForm($surveyData, $formData)
    {
        $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null;
        $questionId = isset($_GET['question_id']) ? (int) $_GET['question_id'] : null;
        $surveyId = isset($_GET['survey_id']) ? (int) $_GET['survey_id'] : null;

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

    public function createForm($surveyData, $formData)
    {
        $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null;
        $questionId = isset($_GET['question_id']) ? (int) $_GET['question_id'] : null;
        $surveyId = isset($_GET['survey_id']) ? (int) $_GET['survey_id'] : null;

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