Function findUsageReferenceInOtherSite
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function findUsageReferenceInOtherSite($siteId, $entities)
{
$usedOtherSite = array();
$supportedEntities = array(BlockInterface::ENTITY_TYPE, ContentInterface::ENTITY_TYPE);
/** @var UseTrackableInterface $entity */
- 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
Method findUsageReferenceInOtherSite
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function findUsageReferenceInOtherSite($siteId, $entities)
{
$usedOtherSite = array();
$supportedEntities = array(BlockInterface::ENTITY_TYPE, ContentInterface::ENTITY_TYPE);
/** @var UseTrackableInterface $entity */
- Create a ticketCreate a ticket
Function displayUsedReferences
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function displayUsedReferences(SymfonyStyle $io, array $usedReferences)
{
foreach ($usedReferences as $usedReference) {
$entity = $usedReference['entity'];
$io->comment('Entity <info>'.$entity->getName(). ' is used in :');
- 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
Missing class import via use statement (line '140', column '19'). Open
throw new \InvalidArgumentException($type . "ins't supported");
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Call to method createQueryBuilder
from undeclared class \Doctrine\Common\Persistence\ObjectManager
Open
$countEntities = $this->objectManager->createQueryBuilder($entityClass)->getQuery()->count();
- Create a ticketCreate a ticket
- Exclude checks
Possibly zero references to use statement for classlike/namespace UseTrackableInterface
(\OpenOrchestra\ModelInterface\Model\UseTrackableInterface)
Open
use OpenOrchestra\ModelInterface\Model\UseTrackableInterface;
- Create a ticketCreate a ticket
- Exclude checks
Call to method newLine
from undeclared class \Symfony\Component\Console\Style\SymfonyStyle
Open
$io->newLine();
- Create a ticketCreate a ticket
- Exclude checks
Call to method text
from undeclared class \Symfony\Component\Console\Style\SymfonyStyle
Open
$io->text(' <comment>Blocks:</comment>');
- Create a ticketCreate a ticket
- Exclude checks
Call to method text
from undeclared class \Symfony\Component\Console\Style\SymfonyStyle
Open
$io->text(' <comment>Contents:</comment>');
- Create a ticketCreate a ticket
- Exclude checks
Call to method text
from undeclared class \Symfony\Component\Console\Style\SymfonyStyle
Open
$io->text(' * Name: <info>'. $content->getContentId() . '</info> Language: <info>'.$content->getLanguage().'</info> Version: <info>'.$content->getVersion().'</info> in site <info>' . $content->getSiteId() . '</info>');
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ENTITY_TYPE
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
$supportedEntities = array(BlockInterface::ENTITY_TYPE, ContentInterface::ENTITY_TYPE);
- Create a ticketCreate a ticket
- Exclude checks
Call to method createQueryBuilder
from undeclared class \Doctrine\Common\Persistence\ObjectManager
Open
$entities = $this->objectManager->createQueryBuilder($entityClass)
- Create a ticketCreate a ticket
- Exclude checks
Parameter $contentRepository
has undeclared type \OpenOrchestra\ModelInterface\Repository\ContentRepositoryInterface
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to method comment
from undeclared class \Symfony\Component\Console\Style\SymfonyStyle
Open
$io->comment('Entity <info>'.$entity->getName(). ' is used in :');
- Create a ticketCreate a ticket
- Exclude checks
Call to method text
from undeclared class \Symfony\Component\Console\Style\SymfonyStyle
Open
$io->text('-----------------------------------------------------------');
- Create a ticketCreate a ticket
- Exclude checks
Parameter $io
has undeclared type \Symfony\Component\Console\Style\SymfonyStyle
Open
public function displayUsedReferences(SymfonyStyle $io, array $usedReferences)
- Create a ticketCreate a ticket
- Exclude checks
Call to method clear
from undeclared class \Doctrine\Common\Persistence\ObjectManager
Open
$this->objectManager->clear();
- Create a ticketCreate a ticket
- Exclude checks
Call to method text
from undeclared class \Symfony\Component\Console\Style\SymfonyStyle
Open
$io->text(' * Name: <info>'. $block->getLabel() . '</info> Language: <info>'.$block->getLanguage().'</info> Type <info>'.$block->getComponent().'</info> in site <info>' . $block->getSiteId() . '</info>');
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ENTITY_TYPE
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$supportedEntities = array(BlockInterface::ENTITY_TYPE, ContentInterface::ENTITY_TYPE);
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ENTITY_TYPE
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
case BlockInterface::ENTITY_TYPE:
- Create a ticketCreate a ticket
- Exclude checks
Parameter $objectManager
has undeclared type \Doctrine\Common\Persistence\ObjectManager
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Parameter $io
has undeclared type \Symfony\Component\Console\Style\SymfonyStyle
Open
protected function displayUsedInBlocks(SymfonyStyle $io, array $blocks)
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ENTITY_TYPE
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
if (BlockInterface::ENTITY_TYPE === $type) {
- Create a ticketCreate a ticket
- Exclude checks
Parameter $blockRepository
has undeclared type \OpenOrchestra\ModelInterface\Repository\BlockRepositoryInterface
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ENTITY_TYPE
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
if (ContentInterface::ENTITY_TYPE === $type) {
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ENTITY_TYPE
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
case ContentInterface::ENTITY_TYPE:
- Create a ticketCreate a ticket
- Exclude checks
Parameter $io
has undeclared type \Symfony\Component\Console\Style\SymfonyStyle
Open
protected function displayUsedInContent(SymfonyStyle $io, array $contents)
- Create a ticketCreate a ticket
- Exclude checks
Avoid variables with short names like $io. Configured minimum length is 3. Open
public function displayUsedReferences(SymfonyStyle $io, array $usedReferences)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $io. Configured minimum length is 3. Open
protected function displayUsedInContent(SymfonyStyle $io, array $contents)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $io. Configured minimum length is 3. Open
protected function displayUsedInBlocks(SymfonyStyle $io, array $blocks)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Line exceeds 120 characters; contains 234 characters Open
$io->text(' * Name: <info>'. $content->getContentId() . '</info> Language: <info>'.$content->getLanguage().'</info> Version: <info>'.$content->getVersion().'</info> in site <info>' . $content->getSiteId() . '</info>');
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 220 characters Open
$io->text(' * Name: <info>'. $block->getLabel() . '</info> Language: <info>'.$block->getLanguage().'</info> Type <info>'.$block->getComponent().'</info> in site <info>' . $block->getSiteId() . '</info>');
- Create a ticketCreate a ticket
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Create a ticketCreate a ticket
- Exclude checks