chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Controller/Admin/AdminController.php

Summary

Maintainability
A
0 mins
Test Coverage

The method listFilesInfo uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $fileUrls[$file->getId()] = null;
                $creator = null;
            }

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 '$creator'.
Open

                $creator = $resourceNode->getCreator();

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

Closing brace must be on a line by itself
Open

    ) {}

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[Route('/register-campus', name: 'admin_register_campus', methods: ['POST'])]

You must use "/**" style comments for a class comment
Open

class AdminController extends BaseController

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[IsGranted('ROLE_ADMIN')]

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[IsGranted('ROLE_ADMIN')]

Add a single space around assignment operators
Open

declare(strict_types=1);

You must use "/**" style comments for a function comment
Open

    public function listFilesInfo(Request $request, ResourceFileRepository $resourceFileRepository): Response

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

#[Route('/admin')]

Missing function doc comment
Open

    public function __construct(

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[Route('/files_info', name: 'admin_files_info', methods: ['GET'])]

You must use "/**" style comments for a function comment
Open

    public function registerCampus(Request $request, SettingsManager $settingsManager): Response

Closing brace must be on a line by itself
Open

    ) {}

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly ResourceNodeRepository $resourceNodeRepository,

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly AccessUrlHelper $accessUrlHelper

There are no issues that match your filters.

Category
Status