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;
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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);
}
- Read upRead up
- Exclude checks
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];
- Read upRead up
- Exclude checks
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">
- Read upRead up
- Exclude checks
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 = [])
- Read upRead up
- Exclude checks
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 = [])
- Read upRead up
- Exclude checks
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 = [])
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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.'
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
'ch-tool-icon',
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
$toolName
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
null,
- Exclude checks
Doc comment for parameter $questionData does not match actual variable name $form Open
* @param array $questionData
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
ICON_SIZE_SMALL,
- Exclude checks
Doc comment for parameter $surveyData does not match actual variable name $formData Open
* @param array $surveyData
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
SurveyManager::icon_question($type),
- Exclude checks
Doc comment for parameter $answers does not match actual variable name $questionData Open
* @param array $answers
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
).' ';
- Exclude checks
Missing function doc comment Open
public function save(CSurvey $survey, array $formData, array $dataFromDatabase = [])
- Exclude checks
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);
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
null,
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
SurveyManager::icon_question($type),
- Exclude checks
Class name "survey_question" is not in camel caps format Open
class survey_question
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
'ch-tool-icon',
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
$toolName
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
).' ';
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
ICON_SIZE_SMALL,
- Exclude checks
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;
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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();
}
}