open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Command/OrchestraDeleteSiteTools.php

Summary

Maintainability
B
4 hrs
Test Coverage

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 */
Severity: Minor
Found in Backoffice/Command/OrchestraDeleteSiteTools.php - About 2 hrs 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

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 */
Severity: Minor
Found in Backoffice/Command/OrchestraDeleteSiteTools.php - About 1 hr to fix

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 :');
Severity: Minor
Found in Backoffice/Command/OrchestraDeleteSiteTools.php - About 25 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

Missing class import via use statement (line '140', column '19').
Open

        throw new \InvalidArgumentException($type . "ins't supported");

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();

Possibly zero references to use statement for classlike/namespace UseTrackableInterface (\OpenOrchestra\ModelInterface\Model\UseTrackableInterface)
Open

use OpenOrchestra\ModelInterface\Model\UseTrackableInterface;

Call to method newLine from undeclared class \Symfony\Component\Console\Style\SymfonyStyle
Open

            $io->newLine();

Call to method text from undeclared class \Symfony\Component\Console\Style\SymfonyStyle
Open

        $io->text('    <comment>Blocks:</comment>');

Call to method text from undeclared class \Symfony\Component\Console\Style\SymfonyStyle
Open

        $io->text('    <comment>Contents:</comment>');

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>');

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open

        $supportedEntities = array(BlockInterface::ENTITY_TYPE, ContentInterface::ENTITY_TYPE);

Call to method createQueryBuilder from undeclared class \Doctrine\Common\Persistence\ObjectManager
Open

            $entities = $this->objectManager->createQueryBuilder($entityClass)

Parameter $contentRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\ContentRepositoryInterface
Open

    public function __construct(

Call to method comment from undeclared class \Symfony\Component\Console\Style\SymfonyStyle
Open

            $io->comment('Entity <info>'.$entity->getName(). ' is used in :');

Call to method text from undeclared class \Symfony\Component\Console\Style\SymfonyStyle
Open

            $io->text('-----------------------------------------------------------');

Parameter $io has undeclared type \Symfony\Component\Console\Style\SymfonyStyle
Open

    public function displayUsedReferences(SymfonyStyle $io, array $usedReferences)

Call to method clear from undeclared class \Doctrine\Common\Persistence\ObjectManager
Open

            $this->objectManager->clear();

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>');

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        $supportedEntities = array(BlockInterface::ENTITY_TYPE, ContentInterface::ENTITY_TYPE);

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open

                    case BlockInterface::ENTITY_TYPE:

Parameter $objectManager has undeclared type \Doctrine\Common\Persistence\ObjectManager
Open

    public function __construct(

Parameter $io has undeclared type \Symfony\Component\Console\Style\SymfonyStyle
Open

    protected function displayUsedInBlocks(SymfonyStyle $io, array $blocks)

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open

        if (BlockInterface::ENTITY_TYPE === $type) {

Parameter $blockRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\BlockRepositoryInterface
Open

    public function __construct(

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        if (ContentInterface::ENTITY_TYPE === $type) {

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

                    case ContentInterface::ENTITY_TYPE:

Parameter $io has undeclared type \Symfony\Component\Console\Style\SymfonyStyle
Open

    protected function displayUsedInContent(SymfonyStyle $io, array $contents)

Avoid variables with short names like $io. Configured minimum length is 3.
Open

    public function displayUsedReferences(SymfonyStyle $io, array $usedReferences)

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)

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)

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>');

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>');

Expected 0 spaces after opening bracket; newline found
Open

                            if (

There are no issues that match your filters.

Category
Status