Missing class import via use statement (line '81', column '27'). Open
$oskill = new SkillModel();
- 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 save_data uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$skill['parent_id'] = 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
Avoid unused local variables such as '$index'. Open
foreach ($skills as $index => $skill) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused local variables such as '$index'. Open
foreach ($skills as $index => $skill) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Variable "allowed_file_mimetype" is not in valid camel caps format Open
$allowed_file_mimetype = ['csv'];
- Exclude checks
Variable "mandatory_fields" is not in valid camel caps format Open
foreach ($mandatory_fields as $field) {
- Exclude checks
Variable "skill_id" is not in valid camel caps format Open
$skill_id = $oskill->add($skill);
- Exclude checks
Variable "skill_id_error" is not in valid camel caps format Open
$skills_to_insert = $skill_id_error = [];
- Exclude checks
Variable "error_message" is not in valid camel caps format Open
$error_message = get_lang('You must import a file corresponding to the selected format');
- Exclude checks
Variable "ext_import_file" is not in valid camel caps format Open
$ext_import_file = substr($_FILES['import_file']['name'], (strrpos($_FILES['import_file']['name'], '.') + 1));
- Exclude checks
Variable "my_skill" is not in valid camel caps format Open
$skills_to_insert[] = $my_skill;
- Exclude checks
Variable "allowed_file_mimetype" is not in valid camel caps format Open
if (in_array($ext_import_file, $allowed_file_mimetype)) {
- Exclude checks
Variable "my_skill" is not in valid camel caps format Open
if (isset($my_skill['title']) && !in_array($my_skill['title'], $skill_id_error)) {
- Exclude checks
Missing parameter name Open
* @param array List of users
- Exclude checks
Variable "saved_id" is not in valid camel caps format Open
$saved_id = $skill['id'];
- Exclude checks
Consider putting global function "parse_csv_data" in a static class Open
function parse_csv_data($file)
- Exclude checks
Variable "my_skill" is not in valid camel caps format Open
if (isset($my_skill['title']) && !in_array($my_skill['title'], $skill_id_error)) {
- Exclude checks
Variable "error_message" is not in valid camel caps format Open
$error_message = '';
- Exclude checks
Variable "my_errors" is not in valid camel caps format Open
$skill_id_error[] = $my_errors['SkillName'];
- Exclude checks
Consider putting global function "validate_data" in a static class Open
function validate_data($skills)
- Exclude checks
Consider putting global function "save_data" in a static class Open
function save_data($skills)
- Exclude checks
Variable "saved_id" is not in valid camel caps format Open
$parents[$saved_id] = $skill_id;
- Exclude checks
Variable "extra_fields" is not in valid camel caps format Open
$extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', true);
- Exclude checks
Variable "my_skill" is not in valid camel caps format Open
foreach ($skills as $my_skill) {
- Exclude checks
Variable "skills_to_insert" is not in valid camel caps format Open
save_data($skills_to_insert);
- Exclude checks
Variable "file_type" is not in valid camel caps format Open
$file_type = $_POST['file_type'];
- Exclude checks
Variable "file_type" is not in valid camel caps format Open
if (0 === strcmp($file_type, 'csv') && $ext_import_file == $allowed_file_mimetype[0]) {
- Exclude checks
Variable "allowed_file_mimetype" is not in valid camel caps format Open
if (0 === strcmp($file_type, 'csv') && $ext_import_file == $allowed_file_mimetype[0]) {
- Exclude checks
Variable "error_kind_file" is not in valid camel caps format Open
$error_kind_file = true;
- Exclude checks
Variable "this_section" is not in valid camel caps format Open
$this_section = SECTION_PLATFORM_ADMIN;
- Exclude checks
Variable "skill_id_error" is not in valid camel caps format Open
$skill_id_error[] = $my_errors['SkillName'];
- Exclude checks
Variable "skill_id_error" is not in valid camel caps format Open
if (isset($my_skill['title']) && !in_array($my_skill['title'], $skill_id_error)) {
- Exclude checks
Variable "tool_name" is not in valid camel caps format Open
$tool_name = get_lang('Import skills from a CSV file');
- Exclude checks
Variable "error_message" is not in valid camel caps format Open
$error_message = '';
- Exclude checks
Variable "ext_import_file" is not in valid camel caps format Open
if (in_array($ext_import_file, $allowed_file_mimetype)) {
- Exclude checks
Variable "error_kind_file" is not in valid camel caps format Open
$error_kind_file = false;
- Exclude checks
Variable "error_kind_file" is not in valid camel caps format Open
$error_kind_file = true;
- Exclude checks
Variable "skills_to_insert" is not in valid camel caps format Open
$skills_to_insert = $skill_id_error = [];
- Exclude checks
Variable "skills_to_insert" is not in valid camel caps format Open
$skills_to_insert[] = $my_skill;
- Exclude checks
Variable "see_message_import" is not in valid camel caps format Open
$see_message_import = get_lang('Only skills that were not registered were imported');
- Exclude checks
Variable "warning_message" is not in valid camel caps format Open
$warning_message = '<ul>';
- Exclude checks
Variable "mandatory_fields" is not in valid camel caps format Open
$mandatory_fields = ['id', 'parent_id', 'title'];
- Exclude checks
Variable "user_id_error" is not in valid camel caps format Open
$user_id_error = [];
- Exclude checks
Variable "error_kind_file" is not in valid camel caps format Open
$error_kind_file = false;
- Exclude checks
Variable "ext_import_file" is not in valid camel caps format Open
if (0 === strcmp($file_type, 'csv') && $ext_import_file == $allowed_file_mimetype[0]) {
- Exclude checks
Variable "my_errors" is not in valid camel caps format Open
foreach ($errors as $my_errors) {
- Exclude checks
Variable "file_type" is not in valid camel caps format Open
if (0 === strcmp($file_type, 'csv')) {
- Exclude checks
Variable "see_message_import" is not in valid camel caps format Open
$see_message_import = get_lang('File imported');
- Exclude checks
Missing parameter name Open
* @param $skills
- Exclude checks
Variable "skill_id" is not in valid camel caps format Open
$parents[$saved_id] = $skill_id;
- Exclude checks
Variable "error_skill" is not in valid camel caps format Open
$warning_message .= '<strong>'.$error_skill['SkillName'].'</strong> ('.$error_skill['SkillName'].')';
- Exclude checks
Variable "error_message" is not in valid camel caps format Open
echo Display::return_message($error_message, 'error');
- Exclude checks
Variable "error_kind_file" is not in valid camel caps format Open
if ($error_kind_file) {
- Exclude checks
Variable "warning_message" is not in valid camel caps format Open
$warning_message .= '</li>';
- Exclude checks
Variable "warning_message" is not in valid camel caps format Open
$warning_message .= '<strong>'.$error_skill['SkillName'].'</strong> ('.$error_skill['SkillName'].')';
- Exclude checks
Variable "tool_name" is not in valid camel caps format Open
Display :: display_header($tool_name);
- Exclude checks
Variable "warning_message" is not in valid camel caps format Open
$warning_message .= '<li><b>'.$error_skill['error'].'</b>: ';
- Exclude checks
Variable "error_skill" is not in valid camel caps format Open
$warning_message .= '<strong>'.$error_skill['SkillName'].'</strong> ('.$error_skill['SkillName'].')';
- Exclude checks
Variable "see_message_import" is not in valid camel caps format Open
echo Display::return_message($see_message_import, 'normal');
- Exclude checks
Variable "see_message_import" is not in valid camel caps format Open
if (!empty($see_message_import)) {
- Exclude checks
Variable "error_skill" is not in valid camel caps format Open
$warning_message .= '<li><b>'.$error_skill['error'].'</b>: ';
- Exclude checks
Variable "warning_message" is not in valid camel caps format Open
$warning_message .= '</ul>';
- Exclude checks
Variable "error_message" is not in valid camel caps format Open
$error_message = get_lang('You must import a file corresponding to the selected format');
- Exclude checks
Variable "error_message" is not in valid camel caps format Open
if (!empty($error_message)) {
- Exclude checks
Variable "tool_name" is not in valid camel caps format Open
$form->addElement('header', '', $tool_name);
- Exclude checks
Variable "error_skill" is not in valid camel caps format Open
foreach ($errors as $index => $error_skill) {
- Exclude checks
The variable $skill_id is not named in camelCase. Open
function save_data($skills)
{
if (is_array($skills)) {
$parents = [];
$urlId = api_get_current_access_url_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 $mandatory_fields is not named in camelCase. Open
function validate_data($skills)
{
$errors = [];
// 1. Check if mandatory fields are set.
$mandatory_fields = ['id', 'parent_id', 'title'];
- 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 $mandatory_fields is not named in camelCase. Open
function validate_data($skills)
{
$errors = [];
// 1. Check if mandatory fields are set.
$mandatory_fields = ['id', 'parent_id', 'title'];
- 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 $skill_id is not named in camelCase. Open
function save_data($skills)
{
if (is_array($skills)) {
$parents = [];
$urlId = api_get_current_access_url_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 $saved_id is not named in camelCase. Open
function save_data($skills)
{
if (is_array($skills)) {
$parents = [];
$urlId = api_get_current_access_url_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 $saved_id is not named in camelCase. Open
function save_data($skills)
{
if (is_array($skills)) {
$parents = [];
$urlId = api_get_current_access_url_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();
}
}