Avoid assigning values to variables in if clauses and the like (line '102', column '17'). Open
public function calc_score($studentId = null, $type = null)
{
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$session_id = $this->get_session_id();
if (empty($session_id)) {
- Read upRead up
- Exclude checks
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 calc_score uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
// all students -> get average
$students = []; // user list, needed to make sure we only
// take first attempts into account
$rescount = 0;
- 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 calc_score uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
switch ($type) {
case 'best':
return [$bestResult, 100];
break;
- 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 calc_score uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return null;
}
- 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 get_link uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$url .= '&action=build&lp_id='.$this->get_ref_id();
}
- 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 property $learnpath_table is not named in camelCase. Open
class LearnpathLink extends AbstractLink
{
private $learnpath_table;
private $learnpath_data;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $learnpath_data is not named in camelCase. Open
class LearnpathLink extends AbstractLink
{
private $learnpath_table;
private $learnpath_data;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Variable "session_id" is not in valid camel caps format Open
$session_id = $this->get_session_id();
- Exclude checks
Method name "LearnpathLink::has_results" is not in camel caps format Open
public function has_results()
- Exclude checks
Method name "LearnpathLink::calc_score" is not in camel caps format Open
public function calc_score($studentId = null, $type = null)
- Exclude checks
Variable "session_id" is not in valid camel caps format Open
$session_id = $this->get_session_id();
- Exclude checks
Method name "LearnpathLink::needs_name_and_description" is not in camel caps format Open
public function needs_name_and_description()
- Exclude checks
Variable "learnpath_table" is not in valid camel caps format Open
return $this->learnpath_table;
- Exclude checks
Method name "LearnpathLink::get_type_name" is not in camel caps format Open
public function get_type_name()
- Exclude checks
Missing function doc comment Open
public function needs_results()
- Exclude checks
Variable "tbl_stats" is not in valid camel caps format Open
$sql = "SELECT * FROM $tbl_stats
- Exclude checks
Method name "LearnpathLink::get_name" is not in camel caps format Open
public function get_name()
- Exclude checks
Method name "LearnpathLink::is_allowed_to_change_name" is not in camel caps format Open
public function is_allowed_to_change_name()
- Exclude checks
Missing function doc comment Open
public function get_icon_name()
- Exclude checks
Variable "learnpath_table" is not in valid camel caps format Open
$this->learnpath_table = Database::get_course_table(TABLE_LP_MAIN);
- Exclude checks
Variable "learnpath_data" is not in valid camel caps format Open
return $this->learnpath_data;
- Exclude checks
Variable "session_id" is not in valid camel caps format Open
if (empty($session_id)) {
- Exclude checks
Variable "session_id" is not in valid camel caps format Open
session_id = $session_id ";
- Exclude checks
Missing function doc comment Open
public function needs_max()
- Exclude checks
Missing function doc comment Open
public function is_allowed_to_change_name()
- Exclude checks
Variable "learnpath_data" is not in valid camel caps format Open
$this->learnpath_data = Database::fetch_array($result);
- Exclude checks
Variable "learnpath_data" is not in valid camel caps format Open
if (!isset($this->learnpath_data)) {
- Exclude checks
Variable "tbl_stats" is not in valid camel caps format Open
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
- Exclude checks
Method name "LearnpathLink::needs_results" is not in camel caps format Open
public function needs_results()
- Exclude checks
Method name "LearnpathLink::get_learnpath_table" is not in camel caps format Open
private function get_learnpath_table()
- Exclude checks
Variable "tbl_stats" is not in valid camel caps format Open
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
- Exclude checks
Missing parameter name Open
* @param $studentId student id (default: all students who have results - then the average is returned)
- Exclude checks
Method name "LearnpathLink::get_all_links" is not in camel caps format Open
public function get_all_links()
- Exclude checks
Missing parameter name Open
* @param $type The type of score we want to get: best|average|ranking
- Exclude checks
Missing function doc comment Open
public function needs_name_and_description()
- Exclude checks
Method name "LearnpathLink::needs_max" is not in camel caps format Open
public function needs_max()
- Exclude checks
Method name "LearnpathLink::get_icon_name" is not in camel caps format Open
public function get_icon_name()
- Exclude checks
Variable "tbl_stats" is not in valid camel caps format Open
$sql = "SELECT count(id) AS number FROM $tbl_stats
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
$session_id
- Exclude checks
Missing function doc comment Open
public function get_type_name()
- Exclude checks
Method name "LearnpathLink::get_link" is not in camel caps format Open
public function get_link()
- Exclude checks
Method name "LearnpathLink::is_valid_link" is not in camel caps format Open
public function is_valid_link()
- Exclude checks
Variable "session_id" is not in valid camel caps format Open
$session_id
- Exclude checks
Method name "LearnpathLink::get_description" is not in camel caps format Open
public function get_description()
- Exclude checks
Variable "session_id" is not in valid camel caps format Open
$session_id = api_get_session_id();
- Exclude checks
Method name "LearnpathLink::get_learnpath_data" is not in camel caps format Open
private function get_learnpath_data()
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
$session_id
- Exclude checks
The variable $session_id is not named in camelCase. Open
public function get_link()
{
$session_id = $this->get_session_id();
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq_params(
$this->getCourseId(),
- 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 $session_id is not named in camelCase. Open
public function get_link()
{
$session_id = $this->get_session_id();
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq_params(
$this->getCourseId(),
- 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 $tbl_stats is not named in camelCase. Open
public function has_results()
{
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$sql = "SELECT count(id) AS number FROM $tbl_stats
WHERE lp_id = ".$this->get_ref_id();
- 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 $tbl_stats is not named in camelCase. Open
public function calc_score($studentId = null, $type = null)
{
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$session_id = $this->get_session_id();
if (empty($session_id)) {
- 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 $session_id is not named in camelCase. Open
public function calc_score($studentId = null, $type = null)
{
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$session_id = $this->get_session_id();
if (empty($session_id)) {
- 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 $session_id is not named in camelCase. Open
public function calc_score($studentId = null, $type = null)
{
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$session_id = $this->get_session_id();
if (empty($session_id)) {
- 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 $session_id is not named in camelCase. Open
public function calc_score($studentId = null, $type = null)
{
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$session_id = $this->get_session_id();
if (empty($session_id)) {
- 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 $session_id is not named in camelCase. Open
public function calc_score($studentId = null, $type = null)
{
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$session_id = $this->get_session_id();
if (empty($session_id)) {
- 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 $tbl_stats is not named in camelCase. Open
public function has_results()
{
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$sql = "SELECT count(id) AS number FROM $tbl_stats
WHERE lp_id = ".$this->get_ref_id();
- 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 $tbl_stats is not named in camelCase. Open
public function calc_score($studentId = null, $type = null)
{
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$session_id = $this->get_session_id();
if (empty($session_id)) {
- 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 method calc_score is not named in camelCase. Open
public function calc_score($studentId = null, $type = null)
{
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$session_id = $this->get_session_id();
if (empty($session_id)) {
- Read upRead up
- Exclude checks
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;
}
- Read upRead up
- Exclude checks
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()
{
$data = $this->get_learnpath_data();
return $data['description'];
- Read upRead up
- Exclude checks
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;
}
- Read upRead up
- Exclude checks
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_name is not named in camelCase. Open
public function get_name()
{
$data = $this->get_learnpath_data();
return $data['title'];
- Read upRead up
- Exclude checks
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()
{
$sql = 'SELECT count(iid) FROM '.$this->get_learnpath_table().'
WHERE iid = '.$this->get_ref_id().' ';
$result = Database::query($sql);
- Read upRead up
- Exclude checks
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_learnpath_table is not named in camelCase. Open
private function get_learnpath_table()
{
$this->learnpath_table = Database::get_course_table(TABLE_LP_MAIN);
return $this->learnpath_table;
- Read upRead up
- Exclude checks
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->getCourseId())) {
return [];
}
- Read upRead up
- Exclude checks
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;
}
- Read upRead up
- Exclude checks
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_learnpath_data is not named in camelCase. Open
private function get_learnpath_data()
{
if (!isset($this->learnpath_data)) {
$sql = 'SELECT * FROM '.$this->get_learnpath_table().'
WHERE iid = '.$this->get_ref_id().' ';
- Read upRead up
- Exclude checks
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('Learning paths');
}
- Read upRead up
- Exclude checks
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;
}
- Read upRead up
- Exclude checks
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 'learnpath';
}
- Read upRead up
- Exclude checks
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()
{
$session_id = $this->get_session_id();
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq_params(
$this->getCourseId(),
- Read upRead up
- Exclude checks
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()
{
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$sql = "SELECT count(id) AS number FROM $tbl_stats
WHERE lp_id = ".$this->get_ref_id();
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}