Workflow/Security/Authorization/Voter/AbstractWorkflowVoter.php
Function userCanUpdateToStatus
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function userCanUpdateToStatus(UserInterface $user, StatusInterface $status, $subject)
{
/** @var GroupInterface $group */
foreach ($user->getGroups() as $group) {
$entityType = $this->getSubjectEntityType($subject);
- Read upRead up
- Create a ticketCreate a ticket
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
Parameter $subject
has undeclared type \OpenOrchestra\ModelInterface\Model\StatusableInterface
Open
Open
abstract protected function isInPerimeter($subject, UserInterface $user);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $fromStatus
has undeclared type \OpenOrchestra\ModelInterface\Model\StatusInterface
Open
Open
protected function voteForSuperAdmin(StatusInterface $fromStatus, StatusInterface $toStatus) {
- Create a ticketCreate a ticket
- Exclude checks
Parameter $subject
has undeclared type \OpenOrchestra\ModelInterface\Model\StatusableInterface
Open
Open
protected function getSubjectEntityType($subject)
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\Workflow\Security\Authorization\Voter\AbstractWorkflowVoter::getSupportedClasses
Open
Open
foreach ($this->getSupportedClasses() as $supportedClass) {
- Create a ticketCreate a ticket
- Exclude checks
Parameter $subject
has undeclared type \OpenOrchestra\ModelInterface\Model\StatusableInterface
Open
Open
protected function userCanUpdateToStatus(UserInterface $user, StatusInterface $status, $subject)
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \OpenOrchestra\ModelInterface\Model\StatusableInterface
Open
Open
if ($subject instanceof StatusableInterface && $subject instanceof $supportedClass) {
- Create a ticketCreate a ticket
- Exclude checks
Expected @param annotation for decisionManager
to be before the @param annotation for perimeterManager
Open
Open
* @param PerimeterManager $perimeterManager
- Create a ticketCreate a ticket
- Exclude checks
Call to method hasTransition
from undeclared class \OpenOrchestra\ModelInterface\Repository\WorkflowProfileRepositoryInterface
Open
Open
return $this->workflowRepository->hasTransition($fromStatus, $toStatus);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $user
has undeclared type \OpenOrchestra\UserBundle\Model\UserInterface
Open
Open
protected function userCanUpdateToStatus(UserInterface $user, StatusInterface $status, $subject)
- Create a ticketCreate a ticket
- Exclude checks
Parameter $decisionManager
has undeclared type \Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
Open
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Argument 2 (toStatus)
is string
but \OpenOrchestra\Workflow\Security\Authorization\Voter\AbstractWorkflowVoter::voteForSuperAdmin()
takes \OpenOrchestra\ModelInterface\Model\StatusInterface
defined at /code/Workflow/Security/Authorization/Voter/AbstractWorkflowVoter.php:119
Open
Open
return $this->voteForSuperAdmin($subject->getStatus(), $attribute);
- Create a ticketCreate a ticket
- Exclude checks
Argument 2 (status)
is string
but \OpenOrchestra\Workflow\Security\Authorization\Voter\AbstractWorkflowVoter::userCanUpdateToStatus()
takes \OpenOrchestra\ModelInterface\Model\StatusInterface
defined at /code/Workflow/Security/Authorization/Voter/AbstractWorkflowVoter.php:142
Open
Open
return $this->userCanUpdateToStatus($user, $attribute, $subject);
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ENTITY_TYPE
from undeclared class \OpenOrchestra\ModelInterface\Model\StatusableInterface
Open
Open
return $subject::ENTITY_TYPE;
- Create a ticketCreate a ticket
- Exclude checks
Parameter $status
has undeclared type \OpenOrchestra\ModelInterface\Model\StatusInterface
Open
Open
protected function userCanUpdateToStatus(UserInterface $user, StatusInterface $status, $subject)
- Create a ticketCreate a ticket
- Exclude checks
Call to method getStatus
from undeclared class \OpenOrchestra\ModelInterface\Model\StatusableInterface
Open
Open
if ($profile->hasTransition($subject->getStatus(), $status)) {
- Create a ticketCreate a ticket
- Exclude checks
Parameter $user
has undeclared type \OpenOrchestra\UserBundle\Model\UserInterface
Open
Open
abstract protected function isInPerimeter($subject, UserInterface $user);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $toStatus
has undeclared type \OpenOrchestra\ModelInterface\Model\StatusInterface
Open
Open
protected function voteForSuperAdmin(StatusInterface $fromStatus, StatusInterface $toStatus) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method getUser
from undeclared class \Symfony\Component\Security\Core\Authentication\Token\TokenInterface
Open
Open
$user = $token->getUser();
- Create a ticketCreate a ticket
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param StatusInterface StatusInterface $toStatus':
after StatusInterface,
did not see an element name (will guess based on comment order) Open
Open
* @param StatusInterface StatusInterface $toStatus
- Create a ticketCreate a ticket
- Exclude checks
Call to method getGroups
from undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open
Open
foreach ($user->getGroups() as $group) {
- Create a ticketCreate a ticket
- Exclude checks
Possibly zero references to use statement for classlike/namespace GroupInterface
(\OpenOrchestra\Backoffice\Model\GroupInterface)
Open
Open
use OpenOrchestra\Backoffice\Model\GroupInterface;
- Create a ticketCreate a ticket
- Exclude checks
Parameter $workflowRepository
has undeclared type \OpenOrchestra\ModelInterface\Repository\WorkflowProfileRepositoryInterface
Open
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Parameter $token
has undeclared type \Symfony\Component\Security\Core\Authentication\Token\TokenInterface
Open
Open
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
- Create a ticketCreate a ticket
- Exclude checks
Avoid excessively long variable names like $supportedAttributeClass. Keep variable name length under 20. Open
Open
foreach ($this->getSupportedAttributes() as $supportedAttributeClass) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Blank line found at start of control structure Open
Open
if ($profile->hasTransition($subject->getStatus(), $status)) {
- Create a ticketCreate a ticket
- Exclude checks
Opening brace should be on a new line Open
Open
protected function voteForSuperAdmin(StatusInterface $fromStatus, StatusInterface $toStatus) {
- Create a ticketCreate a ticket
- Exclude checks
No space found after comma in function call Open
Open
parent::__construct($decisionManager,$perimeterManager);
- Create a ticketCreate a ticket
- Exclude checks