The method get_data() has an NPath complexity of 1480. The configured NPath complexity threshold is 200. Open
public function get_data(
$sorting = 0,
$start = 0,
$count = null,
$ignore_score_color = false,
- 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
Avoid unused private fields such as '$include_edit'. Open
private $include_edit;
- Read upRead up
- Exclude checks
UnusedPrivateField
Since: 0.2
Detects when a private field is declared and/or assigned a value, but not used.
Example
class Something
{
private static $FOO = 2; // Unused
private $i = 5; // Unused
private $j = 6;
public function addOne()
{
return $this->j++;
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatefield
Avoid unused parameters such as '$include_edit'. Open
$include_edit = false
- 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 private fields such as '$is_course_ind'. Open
private $is_course_ind;
- Read upRead up
- Exclude checks
UnusedPrivateField
Since: 0.2
Detects when a private field is declared and/or assigned a value, but not used.
Example
class Something
{
private static $FOO = 2; // Unused
private $i = 5; // Unused
private $j = 6;
public function addOne()
{
return $this->j++;
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatefield
The method sort_by_score uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return $item1['percentage_score'] < $item2['percentage_score'] ? -1 : 1;
}
- 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_data uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$user['score'] = $this->get_score_display(
$result->get_score(),
true,
$ignore_score_color
- 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 parameter $ignore_score_color is not named in camelCase. Open
private function get_score_display(
$score,
$realscore,
$ignore_score_color = false
) {
- Read upRead up
- Exclude checks
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 $include_edit is not named in camelCase. Open
class ResultsDataGenerator
{
// Sorting types constants
const RDG_SORT_LASTNAME = 1;
const RDG_SORT_FIRSTNAME = 2;
- 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 parameter $ignore_score_color is not named in camelCase. Open
public function get_data(
$sorting = 0,
$start = 0,
$count = null,
$ignore_score_color = false,
- Read upRead up
- Exclude checks
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 $is_course_ind is not named in camelCase. Open
class ResultsDataGenerator
{
// Sorting types constants
const RDG_SORT_LASTNAME = 1;
const RDG_SORT_FIRSTNAME = 2;
- 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 parameter $include_edit is not named in camelCase. Open
public function __construct(
$evaluation,
$results = [],
$include_edit = false
) {
- Read upRead up
- Exclude checks
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
Method name "ResultsDataGenerator::get_data" is not in camel caps format Open
public function get_data(
- Exclude checks
Variable "number_decimals" is not in valid camel caps format Open
$number_decimals = api_get_setting('gradebook_number_decimals');
- Exclude checks
Doc comment for parameter $count does not match actual variable name $sorting Open
* @param int $count
- Exclude checks
Variable "include_edit" is not in valid camel caps format Open
$include_edit = false
- Exclude checks
Variable "ignore_score_color" is not in valid camel caps format Open
$ignore_score_color = false
- Exclude checks
Variable "ignore_score_color" is not in valid camel caps format Open
$ignore_score_color
- Exclude checks
Method name "ResultsDataGenerator::sort_by_mask" is not in camel caps format Open
public function sort_by_mask($item1, $item2)
- Exclude checks
Method name "ResultsDataGenerator::get_score_display" is not in camel caps format Open
private function get_score_display(
- Exclude checks
Method name "ResultsDataGenerator::sort_by_first_name" is not in camel caps format Open
public function sort_by_first_name($item1, $item2)
- Exclude checks
Method name "ResultsDataGenerator::sort_by_score" is not in camel caps format Open
public function sort_by_score($item1, $item2)
- Exclude checks
Variable "number_decimals" is not in valid camel caps format Open
if ($pdf && null == $number_decimals) {
- Exclude checks
Variable "ignore_score_color" is not in valid camel caps format Open
$ignore_score_color
- Exclude checks
Method name "ResultsDataGenerator::get_total_results_count" is not in camel caps format Open
public function get_total_results_count()
- Exclude checks
Variable "ignore_score_color" is not in valid camel caps format Open
$ignore_score_color = false,
- Exclude checks
Variable "ignore_score_color" is not in valid camel caps format Open
$ignore_score_color
- Exclude checks
Method name "ResultsDataGenerator::sort_by_last_name" is not in camel caps format Open
public function sort_by_last_name($item1, $item2)
- Exclude checks
The variable $number_decimals is not named in camelCase. Open
public function get_data(
$sorting = 0,
$start = 0,
$count = null,
$ignore_score_color = false,
- 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 $ignore_score_color is not named in camelCase. Open
public function get_data(
$sorting = 0,
$start = 0,
$count = null,
$ignore_score_color = false,
- 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 $number_decimals is not named in camelCase. Open
public function get_data(
$sorting = 0,
$start = 0,
$count = null,
$ignore_score_color = false,
- 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 $ignore_score_color is not named in camelCase. Open
public function get_data(
$sorting = 0,
$start = 0,
$count = null,
$ignore_score_color = false,
- 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 $ignore_score_color is not named in camelCase. Open
private function get_score_display(
$score,
$realscore,
$ignore_score_color = false
) {
- 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 get_data is not named in camelCase. Open
public function get_data(
$sorting = 0,
$start = 0,
$count = null,
$ignore_score_color = 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_score_display is not named in camelCase. Open
private function get_score_display(
$score,
$realscore,
$ignore_score_color = 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 sort_by_last_name is not named in camelCase. Open
public function sort_by_last_name($item1, $item2)
{
return api_strcmp($item1['lastname'], $item2['lastname']);
}
- 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 sort_by_first_name is not named in camelCase. Open
public function sort_by_first_name($item1, $item2)
{
return api_strcmp($item1['firstname'], $item2['firstname']);
}
- 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 sort_by_score is not named in camelCase. Open
public function sort_by_score($item1, $item2)
{
if ($item1['percentage_score'] == $item2['percentage_score']) {
return 0;
} else {
- 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 sort_by_mask is not named in camelCase. Open
public function sort_by_mask($item1, $item2)
{
$score1 = (isset($item1['score']) ? [$item1['score'], $this->evaluation->get_max()] : null);
$score2 = (isset($item2['score']) ? [$item2['score'], $this->evaluation->get_max()] : null);
- 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_total_results_count is not named in camelCase. Open
public function get_total_results_count()
{
return count($this->results);
}
- 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() {
}
}