GroupBundle/EventSubscriber/GroupPerimeterSubscriber.php
Function postSubmit
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
public function postSubmit(FormEvent $event)
{
if (($group = $event->getData()) instanceof GroupInterface) {
$isSiteAdmin = $group->hasRole(ContributionRoleInterface::SITE_ADMIN);
$siteId = $group->getSite()->getSiteId();
- 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
Avoid assigning values to variables in if clauses and the like (line '40', column '14'). Open
Open
public function postSubmit(FormEvent $event)
{
if (($group = $event->getData()) instanceof GroupInterface) {
$isSiteAdmin = $group->hasRole(ContributionRoleInterface::SITE_ADMIN);
$siteId = $group->getSite()->getSiteId();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Parameter $event
has undeclared type \Symfony\Component\Form\FormEvent
Open
Open
public function postSubmit(FormEvent $event)
- Create a ticketCreate a ticket
- Exclude checks
Call to method findOneBySiteId
from undeclared class \OpenOrchestra\ModelInterface\Repository\SiteRepositoryInterface
Open
Open
$site = $this->siteRepository->findOneBySiteId($node->getSiteId());
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant PATH_UPDATED
from undeclared class \OpenOrchestra\ModelInterface\NodeEvents
Open
Open
NodeEvents::PATH_UPDATED => 'updateNodeInPerimeter',
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ENTITY_TYPE
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
NodeInterface::ENTITY_TYPE,
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ENTITY_TYPE
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
NodeInterface::ENTITY_TYPE,
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant NODE_HARD_DELETED
from undeclared class \OpenOrchestra\ModelInterface\NodeEvents
Open
Open
NodeEvents::NODE_HARD_DELETED => 'removeNodeFromPerimeter',
- Create a ticketCreate a ticket
- Exclude checks
Parameter $siteRepository
has undeclared type \OpenOrchestra\ModelInterface\Repository\SiteRepositoryInterface
Open
Open
public function __construct(GroupRepositoryInterface $groupRepository, SiteRepositoryInterface $siteRepository)
- Create a ticketCreate a ticket
- Exclude checks
Call to method getData
from undeclared class \Symfony\Component\Form\FormEvent
Open
Open
if (($group = $event->getData()) instanceof GroupInterface) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method findOneBySiteId
from undeclared class \OpenOrchestra\ModelInterface\Repository\SiteRepositoryInterface
Open
Open
$site = $this->siteRepository->findOneBySiteId($node->getSiteId());
- Create a ticketCreate a ticket
- Exclude checks
Call to method getNode
from undeclared class \OpenOrchestra\ModelInterface\Event\NodeEvent
Open
Open
$node = $event->getNode();
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ENTITY_TYPE
from undeclared class \OpenOrchestra\ModelInterface\Model\SiteInterface
Open
Open
$perimeter->setType(SiteInterface::ENTITY_TYPE);
- Create a ticketCreate a ticket
- Exclude checks
Class implements undeclared interface \Symfony\Component\EventDispatcher\EventSubscriberInterface
Open
Open
class GroupPerimeterSubscriber implements EventSubscriberInterface
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ENTITY_TYPE
from undeclared class \OpenOrchestra\ModelInterface\Model\SiteInterface
Open
Open
$items = !is_null($group->getPerimeter(SiteInterface::ENTITY_TYPE)) ? $group->getPerimeter(SiteInterface::ENTITY_TYPE)->getItems() : array();
- Create a ticketCreate a ticket
- Exclude checks
Parameter $event
has undeclared type \OpenOrchestra\ModelInterface\Event\NodeEvent
Open
Open
public function updateNodeInPerimeter(NodeEvent $event)
- Create a ticketCreate a ticket
- Exclude checks
Call to method getNode
from undeclared class \OpenOrchestra\ModelInterface\Event\NodeEvent
Open
Open
$node = $event->getNode();
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant POST_SUBMIT
from undeclared class \Symfony\Component\Form\FormEvents
Open
Open
FormEvents::POST_SUBMIT => 'postSubmit',
- Create a ticketCreate a ticket
- Exclude checks
Parameter $event
has undeclared type \OpenOrchestra\ModelInterface\Event\NodeEvent
Open
Open
public function removeNodeFromPerimeter(NodeEvent $event)
- Create a ticketCreate a ticket
- Exclude checks
Call to method getPreviousPath
from undeclared class \OpenOrchestra\ModelInterface\Event\NodeEvent
Open
Open
$event->getPreviousPath(),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 153 characters Open
Open
$items = !is_null($group->getPerimeter(SiteInterface::ENTITY_TYPE)) ? $group->getPerimeter(SiteInterface::ENTITY_TYPE)->getItems() : array();
- Create a ticketCreate a ticket
- Exclude checks