chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Controller/SocialController.php

Summary

Maintainability
A
0 mins
Test Coverage

The method getExtraFieldBlock() has an NPath complexity of 246. The configured NPath complexity threshold is 200.
Open

    private function getExtraFieldBlock(
        int $userId,
        UserRepository $userRepository,
        SettingsManager $settingsManager,
        ExtraFieldRepository $extraFieldRepository,

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

The method group() has an NPath complexity of 208. The configured NPath complexity threshold is 200.
Open

    public function group(
        Request $request,
        UsergroupRepository $usergroupRepository,
        EntityManagerInterface $em,
        MessageRepository $messageRepository

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

The class SocialController has a coupling between objects value of 34. Consider to reduce the number of dependencies under 13.
Open

class SocialController extends AbstractController
{
    public function __construct(
        private readonly UserHelper $userHelper,
    ) {}

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

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

        } else {
            return $this->json(['success' => false, 'message' => 'Invalid action type']);
        }

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 getLegalTerms uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $term = $this->getLastConditionByLanguage($languageRepo, $isoCode, $legalTermsRepo, $settingsManager);
        }

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 getGroups uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $groups = $usergroupRepository->getGroupsByUser($userId);
            foreach ($groups as $group) {
                $items[] = [
                    'id' => $group->getId(),

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 handlePrivacyRequest uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            MessageManager::sendMessageToAllAdminUsers($user->getId(), $emailSubject, $emailContent);
        }

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 group uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $data = json_decode($request->getContent(), true);
            $userId = $data['userId'] ?? null;
            $groupId = $data['groupId'] ?? null;
            $action = $data['action'] ?? 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 '$legalTime'.
Open

            [$legalId, $legalLanguageId, $legalTime] = explode(':', $value['value']);

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

            [$legalId, $legalLanguageId, $legalTime] = explode(':', $value['value']);

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 parameters such as '$illustrationRepository'.
Open

    public function groupInvitedUsers(int $groupId, UsergroupRepository $usergroupRepository, IllustrationRepository $illustrationRepository): JsonResponse

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 local variables such as '$coordinates'.
Open

                    $coordinates = $geoData[1] ?? '';

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

                    $res = MessageManager::send_message(

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 parameters such as '$extraFieldRepository'.
Open

        ExtraFieldRepository $extraFieldRepository,

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 local variables such as '$legalId'.
Open

        [$legalId, $legalLanguageId, $legalTime] = explode(':', $value['value']);

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

        [$legalId, $legalLanguageId, $legalTime] = explode(':', $value['value']);

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

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

    #[Route('/legal-status/{userId}', name: 'chamilo_core_social_legal_status')]

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

    public function getLegalStatus(

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

    #[Route('/handle-privacy-request', name: 'chamilo_core_social_handle_privacy_request')]

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

    public function handlePrivacyRequest(

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

    public function getDiscussionMessages(

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

    public function groupInvitedUsers(int $groupId, UsergroupRepository $usergroupRepository, IllustrationRepository $illustrationRepository): JsonResponse

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

    #[IsGranted('ROLE_USER')]

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

    #[Route('/user-profile/{userId}', name: 'chamilo_core_social_user_profile')]

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

    public function group(

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

    #[Route('/group-action', name: 'chamilo_core_social_group_action')]

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

    #[Route('/get-forum-link', name: 'get_forum_link')]

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

    public function groupDetails(

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

    #[Route('/upload-group-picture/{groupId}', name: 'chamilo_core_social_upload_group_picture')]

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

    #[Route('/send-legal-term', name: 'chamilo_core_social_send_legal_term')]

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

    #[Route('/delete-legal', name: 'chamilo_core_social_delete_legal')]

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

    public function deleteLegal(Request $request, TranslatorInterface $translator): JsonResponse

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

    #[Route('/group/{groupId}/discussion/{discussionId}/messages', name: 'chamilo_core_social_group_discussion_messages')]

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

    public function getInvitations(

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

    #[Route('/user-action', name: 'chamilo_core_social_user_action')]

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

    public function uploadGroupPicture(

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

#[Route('/social-network')]

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

    public function sendLegalTerm(

Declare public methods first,then protected ones and finally private ones
Open

    public function getInvitations(

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

    #[Route('/terms-restrictions/{userId}', name: 'chamilo_core_social_terms_restrictions')]

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

    public function search(

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

    public function getOnlineStatus(Request $request, TrackEOnlineRepository $trackOnlineRepository): JsonResponse

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

    public function getForumLink(

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

    public function inviteFriends(

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

    #[Route('/group/{groupId}/invited-users', name: 'chamilo_core_social_group_invited_users')]

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

    #[Route('/group-details/{groupId}', name: 'chamilo_core_social_group_details')]

Add a single space around assignment operators
Open

declare(strict_types=1);

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

class SocialController extends AbstractController

Missing function doc comment
Open

    public function __construct(

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

    #[Route('/add-users-to-group/{groupId}', name: 'chamilo_core_social_add_users_to_group')]

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

    public function getUserProfile(

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

    #[Route('/invitations/count/{userId}', name: 'chamilo_core_social_invitations_count')]

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

    #[IsGranted('ROLE_USER')]

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

    public function getUserRelation(int $currentUserId, int $profileUserId, EntityManagerInterface $em): JsonResponse

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

    public function getPersonalData(

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

    #[Route('/terms-and-conditions/{userId}', name: 'chamilo_core_social_terms')]

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

    public function getLegalTerms(

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

    public function user(

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

    #[Route('/user-relation/{currentUserId}/{profileUserId}', name: 'chamilo_core_social_get_user_relation')]

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

    #[Route('/online-status', name: 'chamilo_core_social_get_online_status', methods: ['POST'])]

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

    #[Route('/personal-data/{userId}', name: 'chamilo_core_social_personal_data')]

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

    public function addUsersToGroup(Request $request, int $groupId, UsergroupRepository $usergroupRepository): JsonResponse

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

    public function getInvitationsCount(

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

    #[Route('/search', name: 'chamilo_core_social_search')]

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

    public function checkTermsRestrictions(

Closing brace must be on a line by itself
Open

    ) {}

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

    #[Route('/groups/{userId}', name: 'chamilo_core_social_groups')]

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

    public function getGroups(

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

    #[Route('/invite-friends/{userId}/{groupId}', name: 'chamilo_core_social_invite_friends')]

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

    #[Route('/invitations/{userId}', name: 'chamilo_core_social_invitations')]

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly UserHelper $userHelper,

Closing brace must be on a line by itself
Open

    ) {}

There are no issues that match your filters.

Category
Status