open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Security/Authorization/Voter/AbstractPerimeterVoter.php

Summary

Maintainability
A
35 mins
Test Coverage

Function getAgglomeratedPerimeter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getAgglomeratedPerimeter(UserInterface $user, $entityType)
    {
        if (false === $this->hasCachedPerimeters($user, $entityType)) {
            $cachedPerimeter = $this->perimeterManager->createPerimeter($entityType);
            foreach ($user->getGroups() as $group) {
Severity: Minor
Found in Backoffice/Security/Authorization/Voter/AbstractPerimeterVoter.php - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Call to method getGroups from undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open

            foreach ($user->getGroups() as $group) {

Call to method getId from undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open

            $this->cachedPerimeters[$user->getId()][$entityType] = $cachedPerimeter;

Parameter $decisionManager has undeclared type \Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
Open

    public function __construct(AccessDecisionManagerInterface $decisionManager, PerimeterManager $perimeterManager)

Call to method getId from undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open

        $userId = $user->getId();

Parameter $user has undeclared type \OpenOrchestra\UserBundle\Model\UserInterface
Open

    protected function hasCachedPerimeters(UserInterface $user, $entityType)

Call to method getId from undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open

        return $this->cachedPerimeters[$user->getId()][$entityType];

Parameter $user has undeclared type \OpenOrchestra\UserBundle\Model\UserInterface
Open

    protected function getAgglomeratedPerimeter(UserInterface $user, $entityType)

Parameter $user has undeclared type \OpenOrchestra\UserBundle\Model\UserInterface
Open

    protected function isSubjectInPerimeter($subjectKey, UserInterface $user, $entityType)

There are no issues that match your filters.

Category
Status