open-orchestra/open-orchestra-media-bundle

View on GitHub

Showing 22 of 29 total issues

Media has 33 functions (exceeds 20 allowed). Consider refactoring.
Open

class Media implements MediaInterface
{
    use BlameableDocument;
    use TimestampableDocument;
    use Keywordable;
Severity: Minor
Found in MediaModelBundle/Document/Media.php - About 4 hrs to fix

Function process has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function process(ContainerBuilder $container)
    {
        $resourcePath = '.';
        foreach ($container->getResources() as $resource) {
            if (!$resource instanceof FileResource) {

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 getConfigTreeBuilder has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('open_orchestra_media_model');

Severity: Minor
Found in MediaModelBundle/DependencyInjection/Configuration.php - About 1 hr to fix

Method setUp has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function setUp()
    {
        $this->media = Phake::mock('OpenOrchestra\Media\Model\MediaInterface');

        $this->defaultStrategy = Phake::mock('OpenOrchestra\Media\DisplayMedia\DisplayMediaInterface');
Severity: Minor
Found in Media/Tests/DisplayMedia/DisplayMediaManagerTest.php - About 1 hr to fix

Method provideFolderForRecord has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function provideFolderForRecord()
    {
        $parentPath    = '/parentPath';
        $folderId      = 'folderId';
        $oldFolderPath = $parentPath . '/oldId';
Severity: Minor
Found in MediaModelBundle/Tests/EventListener/GeneratePathListenerTest.php - About 1 hr to fix

Method testBuildView has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testBuildView()
    {
        $folder0 = Phake::mock($this->folderClass);
        $folder0Id = 'folder0Id';
        $folder0Name = 'folder0Name';
Severity: Minor
Found in MediaModelBundle/Tests/Form/Type/Component/FolderChoiceTypeTest.php - About 1 hr to fix

Method findFolderTree has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function findFolderTree($siteId)
    {
        $qa = $this->createAggregationQuery();
        $qa->match(array('siteId' => $siteId));
        $folders = $qa->getQuery()->aggregate()->toArray();
Severity: Minor
Found in MediaModelBundle/Repository/FolderRepository.php - About 1 hr to fix

Method buildTreeFolders has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function buildTreeFolders(array $folders, $language, $contributionRigth, $depth = 0)
    {
        $lastFolder = end($folders);
        $result = array();
        foreach ($folders as $folder) {
Severity: Minor
Found in MediaModelBundle/Form/Type/Component/FolderChoiceType.php - About 1 hr to fix

Method testRenderMedia has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function testRenderMedia($image, $url, $alt, $id = '', $class = '', $style = '', $width = 0, $height = 0)
Severity: Major
Found in Media/Tests/DisplayMedia/Strategies/VideoStrategyTest.php - About 1 hr to fix

Function buildTreeFolders has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function buildTreeFolders(array $folders, $language, $contributionRigth, $depth = 0)
    {
        $lastFolder = end($folders);
        $result = array();
        foreach ($folders as $folder) {
Severity: Minor
Found in MediaModelBundle/Form/Type/Component/FolderChoiceType.php - About 45 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

Method testRenderMedia has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function testRenderMedia($image, $url, $alt, $id = '', $class = '', $style = '')
Severity: Minor
Found in Media/Tests/DisplayMedia/Strategies/ImageStrategyTest.php - About 45 mins to fix

Method testRenderMedia has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function testRenderMedia($image, $url, $alt, $id = '', $class = '', $style = '')
Severity: Minor
Found in Media/Tests/DisplayMedia/Strategies/AudioStrategyTest.php - About 45 mins to fix

Function setPath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function setPath(LifecycleEventArgs $eventArgs)
    {
        $document = $eventArgs->getDocument();
        if ($document instanceof FolderInterface) {
            $folderRepository = $this->container->get('open_orchestra_media.repository.media_folder');
Severity: Minor
Found in MediaModelBundle/EventListener/GeneratePathListener.php - About 45 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

Method testRenderMedia has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function testRenderMedia($image, $url, $alt, $id = '', $class = '', $style = '')
Severity: Minor
Found in Media/Tests/DisplayMedia/Strategies/DefaultStrategyTest.php - About 45 mins to fix

Method testRenderMedia has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function testRenderMedia($image, $url, $alt, $id = '', $class = '', $style = '')
Severity: Minor
Found in Media/Tests/DisplayMedia/Strategies/PdfStrategyTest.php - About 45 mins to fix

Method testDisplayMediaForWysiwyg has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function testDisplayMediaForWysiwyg($image, $url, $alt, $id = null, $format = null)
Severity: Minor
Found in Media/Tests/DisplayMedia/Strategies/ImageStrategyTest.php - About 35 mins to fix

Method testRecord has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        $method,
        MediaFolderInterface $folder,
        ArrayCollection $children,
        $expectedFolderPath,
        $expectedChildFolderPath
Severity: Minor
Found in MediaModelBundle/Tests/EventListener/GeneratePathListenerTest.php - About 35 mins to fix

Method testDisplayMediaForWysiwyg has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function testDisplayMediaForWysiwyg($image, $url, $alt, $id = null, $format = null)
Severity: Minor
Found in Media/Tests/DisplayMedia/Strategies/AbstractDisplayMediaStrategyTest.php - About 35 mins to fix

Method testDisplayMediaForWysiwyg has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function testDisplayMediaForWysiwyg($image, $url, $alt, $id = null, $format = null)
Severity: Minor
Found in Media/Tests/DisplayMedia/Strategies/AudioStrategyTest.php - About 35 mins to fix

Avoid too many return statements within this method.
Open

            return -1;
Severity: Major
Found in MediaModelBundle/Repository/FolderRepository.php - About 30 mins to fix
Severity
Category
Status
Source
Language