public/main/admin/usergroup_import.php
Missing class import via use statement (line '47', column '22'). Open
Open
$usergroup = new UserGroupModel();
- 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 '16', column '22'). Open
Open
$usergroup = new UserGroupModel();
- 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 validate_data uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
// 2. Check whether class doesn't exist yet.
if ($usergroup->usergroup_exists($class['name'])) {
$class['line'] = $index + 2;
$class['error'] = get_lang('Class name exists').
- 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
Open
foreach ($classes as $index => $class) {
- 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 "error_message" is not in valid camel caps format Open
Open
$error_message = get_lang('Errors when importing file');
- Exclude checks
Variable "error_message" is not in valid camel caps format Open
Open
$error_message .= '<li>'.$error_class['error'].' ('.get_lang('Line').' '.$error_class['line'].')';
- Exclude checks
Variable "error_class" is not in valid camel caps format Open
Open
$error_message .= '<li>'.$error_class['error'].' ('.get_lang('Line').' '.$error_class['line'].')';
- Exclude checks
Variable "tool_name" is not in valid camel caps format Open
Open
$tool_name = get_lang('Import class list via CSV');
- Exclude checks
Variable "this_section" is not in valid camel caps format Open
Open
$this_section = SECTION_PLATFORM_ADMIN;
- Exclude checks
Variable "error_message" is not in valid camel caps format Open
Open
$error_message .= '<ul>';
- Exclude checks
Variable "error_class" is not in valid camel caps format Open
Open
foreach ($errors as $index => $error_class) {
- Exclude checks
Variable "number_of_added_classes" is not in valid camel caps format Open
Open
$number_of_added_classes = save_data($classes);
- Exclude checks
Variable "error_message" is not in valid camel caps format Open
Open
$error_message .= '</li>';
- Exclude checks
Variable "tool_name" is not in valid camel caps format Open
Open
Display::display_header($tool_name);
- Exclude checks
Missing parameter name Open
Open
* @param $classes
- Exclude checks
Variable "error_message" is not in valid camel caps format Open
Open
$error_message .= get_lang('Error');
- Exclude checks
Variable "error_message" is not in valid camel caps format Open
Open
Display::addFlash(Display::return_message($error_message, 'error', false));
- Exclude checks
Variable "error_class" is not in valid camel caps format Open
Open
$error_message .= '<li>'.$error_class['error'].' ('.get_lang('Line').' '.$error_class['line'].')';
- Exclude checks
Consider putting global function "save_data" in a static class Open
Open
function save_data($classes)
- Exclude checks
Variable "error_message" is not in valid camel caps format Open
Open
$error_message .= '</ul>';
- Exclude checks
Consider putting global function "validate_data" in a static class Open
Open
function validate_data($classes)
- Exclude checks
Variable "number_of_added_classes" is not in valid camel caps format Open
Open
Display::addFlash(Display::return_message($number_of_added_classes.' '.get_lang('Added'), 'normal'));
- Exclude checks