The method calc_score() has an NPath complexity of 2880. The configured NPath complexity threshold is 200. Open
public function calc_score($studentId = null, $type = null)
{
$studentId = (int) $studentId;
$em = Database::getManager();
$assignment = $this->getStudentPublication();
- 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 methods such as 'get_studpub_table'. Open
private function get_studpub_table()
{
return $this->studpub_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
}
- Read upRead up
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod
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 {
$dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a
WHERE
a.active = :active AND
a.publicationParent = :parent AND
- 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 $studpub_table is not named in camelCase. Open
class StudentPublicationLink extends AbstractLink
{
private $studpub_table;
public function __construct()
- 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
Method name "StudentPublicationLink::get_link" is not in camel caps format Open
public function get_link()
- Exclude checks
Method name "StudentPublicationLink::get_type_name" is not in camel caps format Open
public function get_type_name()
- Exclude checks
Variable "course_id" is not in valid camel caps format Open
if (empty($this->course_id)) {
- Exclude checks
Missing function doc comment Open
public function get_link()
- Exclude checks
Variable "studpub_table" is not in valid camel caps format Open
return $this->studpub_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
- Exclude checks
Method name "StudentPublicationLink::has_results" is not in camel caps format Open
public function has_results()
- Exclude checks
Missing function doc comment Open
public function get_description()
- Exclude checks
Missing function doc comment Open
public function needs_max()
- Exclude checks
Variable "work_name" is not in valid camel caps format Open
$work_name = $data->getTitle();
- Exclude checks
Missing function doc comment Open
public function needs_results()
- Exclude checks
Method name "StudentPublicationLink::is_valid_link" is not in camel caps format Open
public function is_valid_link()
- Exclude checks
Missing function doc comment Open
public function get_icon_name()
- Exclude checks
Method name "StudentPublicationLink::needs_name_and_description" is not in camel caps format Open
public function needs_name_and_description()
- Exclude checks
Method name "StudentPublicationLink::needs_max" is not in camel caps format Open
public function needs_max()
- Exclude checks
Method name "StudentPublicationLink::get_icon_name" is not in camel caps format Open
public function get_icon_name()
- Exclude checks
Missing function doc comment Open
public function __construct()
- Exclude checks
Missing function doc comment Open
public function is_allowed_to_change_name()
- Exclude checks
Variable "work_name" is not in valid camel caps format Open
$work_name = basename($data->getUrl());
- Exclude checks
Method name "StudentPublicationLink::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 save_linked_data()
- Exclude checks
Method name "StudentPublicationLink::get_all_links" is not in camel caps format Open
public function get_all_links()
- Exclude checks
Method name "StudentPublicationLink::save_linked_data" is not in camel caps format Open
public function save_linked_data()
- Exclude checks
Method name "StudentPublicationLink::delete_linked_data" is not in camel caps format Open
public function delete_linked_data()
- Exclude checks
Variable "work_name" is not in valid camel caps format Open
if (empty($work_name)) {
- Exclude checks
Method name "StudentPublicationLink::calc_score" is not in camel caps format Open
public function calc_score($studentId = null, $type = null)
- Exclude checks
Missing function doc comment Open
public function get_name()
- Exclude checks
Method name "StudentPublicationLink::get_name" is not in camel caps format Open
public function get_name()
- Exclude checks
Method name "StudentPublicationLink::needs_results" is not in camel caps format Open
public function needs_results()
- Exclude checks
Missing function doc comment Open
public function is_valid_link()
- Exclude checks
Variable "work_name" is not in valid camel caps format Open
$cats[] = [$data->getIid(), $work_name];
- Exclude checks
Variable "course_id" is not in valid camel caps format Open
$qb = $repo->findAllByCourse(api_get_course_entity($this->course_id), $session, null, 1, 'folder');
- Exclude checks
Method name "StudentPublicationLink::get_studpub_table" is not in camel caps format Open
private function get_studpub_table()
- Exclude checks
Missing function doc comment Open
public function needs_name_and_description()
- Exclude checks
Method name "StudentPublicationLink::get_description" is not in camel caps format Open
public function get_description()
- Exclude checks
The variable $work_name is not named in camelCase. Open
public function get_all_links()
{
if (empty($this->course_id)) {
return [];
}
- 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 $work_name is not named in camelCase. Open
public function get_all_links()
{
if (empty($this->course_id)) {
return [];
}
- 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 $work_name is not named in camelCase. Open
public function get_all_links()
{
if (empty($this->course_id)) {
return [];
}
- 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 $work_name is not named in camelCase. Open
public function get_all_links()
{
if (empty($this->course_id)) {
return [];
}
- 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_name is not named in camelCase. Open
public function get_name()
{
$studentPublication = $this->getStudentPublication();
$title = $studentPublication->getTitle();
- 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 save_linked_data is not named in camelCase. Open
public function save_linked_data()
{
$studentPublication = $this->getStudentPublication();
if (empty($studentPublication)) {
- 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->course_id)) {
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 delete_linked_data is not named in camelCase. Open
public function delete_linked_data()
{
/*$data = $this->get_exercise_data();
if (empty($data)) {
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 get_link is not named in camelCase. Open
public function get_link()
{
$studentPublication = $this->getStudentPublication();
$sessionId = $this->get_session_id();
$url = api_get_path(WEB_PATH).'main/work/work.php?'.
- 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()
{
$studentPublication = $this->getStudentPublication();
return null !== $studentPublication;
- 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_studpub_table is not named in camelCase. Open
private function get_studpub_table()
{
return $this->studpub_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
}
- 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 calc_score is not named in camelCase. Open
public function calc_score($studentId = null, $type = null)
{
$studentId = (int) $studentId;
$em = Database::getManager();
$assignment = $this->getStudentPublication();
- 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()
{
$studentPublication = $this->getStudentPublication();
return $studentPublication->getDescription();
- 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 'studentpublication';
}
- 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 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 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_type_name is not named in camelCase. Open
public function get_type_name()
{
return get_lang('Assignments');
}
- 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()
{
$studentPublication = $this->getStudentPublication();
if (empty($studentPublication)) {
- 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() {
}
}