Backoffice/EventSubscriber/ContentSearchSubscriber.php
Method addFormType
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function addFormType(FormEvent $event)
{
$form = $event->getForm();
$data = $event->getData();
$event->setData($data);
- Create a ticketCreate a ticket
Function addFormType
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function addFormType(FormEvent $event)
{
$form = $event->getForm();
$data = $event->getData();
$event->setData($data);
- 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
The method addFormType() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
Open
protected function addFormType(FormEvent $event)
{
$form = $event->getForm();
$data = $event->getData();
$event->setData($data);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Parameter $event
has undeclared type \Symfony\Component\Form\FormEvent
Open
Open
public function postSetData(FormEvent $event)
- Create a ticketCreate a ticket
- Exclude checks
Class implements undeclared interface \Symfony\Component\EventDispatcher\EventSubscriberInterface
Open
Open
class ContentSearchSubscriber implements EventSubscriberInterface
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant POST_SET_DATA
from undeclared class \Symfony\Component\Form\FormEvents
Open
Open
FormEvents::POST_SET_DATA => 'postSetData',
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant PRE_SUBMIT
from undeclared class \Symfony\Component\Form\FormEvents
Open
Open
FormEvents::PRE_SUBMIT => 'preSubmit',
- Create a ticketCreate a ticket
- Exclude checks
Call to method getData
from undeclared class \Symfony\Component\Form\FormEvent
Open
Open
$data = $event->getData();
- Create a ticketCreate a ticket
- Exclude checks
Call to method setData
from undeclared class \Symfony\Component\Form\FormEvent
Open
Open
$event->setData($data);
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant CHOICE_AND
from undeclared class \OpenOrchestra\ModelInterface\Repository\ReadContentRepositoryInterface
Open
Open
array_key_exists('choiceType', $data) && $data['choiceType'] != '' ? $data['choiceType']: ReadContentRepositoryInterface::CHOICE_AND,
- Create a ticketCreate a ticket
- Exclude checks
Parameter $event
has undeclared type \Symfony\Component\Form\FormEvent
Open
Open
public function preSubmit(FormEvent $event)
- Create a ticketCreate a ticket
- Exclude checks
Call to method getForm
from undeclared class \Symfony\Component\Form\FormEvent
Open
Open
$form = $event->getForm();
- Create a ticketCreate a ticket
- Exclude checks
Call to method findOneByContentId
from undeclared class \OpenOrchestra\ModelInterface\Repository\ContentRepositoryInterface
Open
Open
$content = $this->contentRepository->findOneByContentId($contentId);
- Create a ticketCreate a ticket
- Exclude checks
Call to method findByContentTypeAndCondition
from undeclared class \OpenOrchestra\ModelInterface\Repository\ContentRepositoryInterface
Open
Open
$contents = $this->contentRepository->findByContentTypeAndCondition($language, $contentType, $choiceType, $condition, $siteId);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $event
has undeclared type \Symfony\Component\Form\FormEvent
Open
Open
protected function addFormType(FormEvent $event)
- Create a ticketCreate a ticket
- Exclude checks
Parameter $contentRepository
has undeclared type \OpenOrchestra\ModelInterface\Repository\ContentRepositoryInterface
Open
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to method getForm
from undeclared class \Symfony\Component\Form\FormEvent
Open
Open
$form = $event->getForm();
- Create a ticketCreate a ticket
- Exclude checks
Avoid excessively long variable names like $booleanConditionValidator. Keep variable name length under 20. Open
Open
BooleanConditionValidator $booleanConditionValidator,
- 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
Avoid excessively long variable names like $booleanConditionValidator. Keep variable name length under 20. Open
Open
protected $booleanConditionValidator;
- 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
Line exceeds 120 characters; contains 153 characters Open
Open
array_key_exists('choiceType', $data) && $data['choiceType'] != '' ? $data['choiceType']: ReadContentRepositoryInterface::CHOICE_AND,
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 139 characters Open
Open
$contents = $this->contentRepository->findByContentTypeAndCondition($language, $contentType, $choiceType, $condition, $siteId);
- Create a ticketCreate a ticket
- Exclude checks
Multi-line function call not indented correctly; expected 16 spaces but found 20 Open
Open
array_key_exists('keywords', $data) && $data['keywords'] ? $data['keywords']: null));
- Create a ticketCreate a ticket
- Exclude checks
Opening parenthesis of a multi-line function call must be the last content on the line Open
Open
$choices = array_merge($choices, $this->getChoices($data['contentType'],
- Create a ticketCreate a ticket
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
Open
array_key_exists('keywords', $data) && $data['keywords'] ? $data['keywords']: null));
- Create a ticketCreate a ticket
- Exclude checks