open-orchestra/open-orchestra-media-bundle

View on GitHub

Showing 29 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function testRenderMedia($image, $url, $alt, $id = '', $class = '', $style = '')
    {
        Phake::when($this->media)->getName()->thenReturn($image);

        parent::testRenderMedia($image, $url, $alt);
Severity: Major
Found in Media/Tests/DisplayMedia/Strategies/DefaultStrategyTest.php and 1 other location - About 3 hrs to fix
Media/Tests/DisplayMedia/Strategies/PdfStrategyTest.php on lines 35..57

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 150.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function testRenderMedia($image, $url, $alt, $id = '', $class = '', $style = '')
    {
        Phake::when($this->media)->getName()->thenReturn($image);

        parent::testRenderMedia($image, $url, $alt);
Severity: Major
Found in Media/Tests/DisplayMedia/Strategies/PdfStrategyTest.php and 1 other location - About 3 hrs to fix
Media/Tests/DisplayMedia/Strategies/DefaultStrategyTest.php on lines 35..57

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 150.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php

namespace OpenOrchestra\Media\Tests\BBcode;

use OpenOrchestra\Media\BBcode\MediaCodeDefinition;
Severity: Minor
Found in Media/Tests/BBcode/MediaCodeDefinitionTest.php and 1 other location - About 40 mins to fix
Media/Tests/BBcode/MediaWithoutFormatCodeDefinitionTest.php on lines 1..41

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 93.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    public function renderMedia(MediaInterface $media, array $options)
    {
        $options = $this->validateOptions($options, __METHOD__);

        return $this->render(
Severity: Minor
Found in Media/DisplayMedia/Strategies/AudioStrategy.php and 2 other locations - About 40 mins to fix
Media/DisplayMedia/Strategies/DefaultStrategy.php on lines 28..42
Media/DisplayMedia/Strategies/PdfStrategy.php on lines 30..44

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 93.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php

namespace OpenOrchestra\Media\Tests\BBcode;

use OpenOrchestra\Media\BBcode\MediaWithoutFormatCodeDefinition;
Severity: Minor
Found in Media/Tests/BBcode/MediaWithoutFormatCodeDefinitionTest.php and 1 other location - About 40 mins to fix
Media/Tests/BBcode/MediaCodeDefinitionTest.php on lines 1..41

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 93.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language