open-orchestra/open-orchestra-media-admin-bundle

View on GitHub

Showing 67 of 89 total issues

Method getConfigTreeBuilder has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Severity: Major
Found in MediaAdminBundle/DependencyInjection/Configuration.php - About 3 hrs to fix

Method load has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

MediaUploadView has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class MediaUploadView extends OrchestraView
{
    /**
     * @inheritdoc
     */

Method buildForm has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('format', 'choice', array(
                'choices'      => $this->getChoices(),
Severity: Major
Found in MediaAdminBundle/Form/Type/MediaImageType.php - About 2 hrs to fix

Method testConfig has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testConfig(
        $file,
        $tmpDir,
        array $alternatives,
        array $thumbnail,

Method buildForm has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $formats = $this->getFormats();
        $allowAdd = true;
        if (isset($options['disabled']) && $options['disabled']) {
Severity: Minor
Found in MediaAdminBundle/GenerateForm/Strategies/GalleryStrategy.php - About 1 hr to fix

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

    protected function getChoices()
    {
        $choices = array();

        if ($this->authorizationChecker->isGranted(ContributionRoleInterface::PLATFORM_ADMIN)) {
Severity: Minor
Found in MediaAdminBundle/Form/Type/SiteForFolderChoiceType.php - About 1 hr 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 addMediaFieldType has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function addMediaFieldType(ContainerBuilder $container)
    {
        $fieldTypes = array_merge(
            $container->getParameter('open_orchestra_backoffice.field_types'),
            array(

Function getConnectedUserMediaPerimeter has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getConnectedUserMediaPerimeter($siteId)
    {
        $user = $this->get('security.token_storage')->getToken()->getUser();
        if ($user->hasRole(ContributionRoleInterface::PLATFORM_ADMIN)
            || $user->hasRole(ContributionRoleInterface::DEVELOPER)
Severity: Minor
Found in MediaAdminBundle/Controller/Api/MediaController.php - About 1 hr 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 testUpdatePath has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testUpdatePath()
    {
        $parentFolderId = 'parent';
        $grandParentPath = '/';
        $parentPath = 'parentPath';
Severity: Minor
Found in MediaAdmin/Tests/EventSubscriber/FolderSubscriberTest.php - About 1 hr to fix

Method load has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function load(ObjectManager $manager)
    {
        $logoOrchestra = $this->generateMedia(
            'logo-orchestra.png',
            'mediaFolder-transparentImages',
Severity: Minor
Found in MediaAdminBundle/DataFixtures/MongoDB/LoadMediaData.php - About 1 hr to fix

Method updatePath has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function updatePath(FolderEvent $event)
    {
        $folder = $event->getFolder();

        $parentFolder = $folder->getParent();
Severity: Minor
Found in MediaAdmin/EventSubscriber/FolderSubscriber.php - About 1 hr to fix

Method newAction has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function newAction(Request $request, $parentId=null)
    {
        $folderClass = $this->getParameter('open_orchestra_media.document.media_folder.class');
        $folder = new $folderClass();
        if (!is_null($parentId)) {
Severity: Minor
Found in MediaAdminBundle/Controller/Admin/FolderController.php - About 1 hr to fix

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

    public function setUp()
    {
        parent::setUp();

        Phake::when($this->mediaStorageManager)->exists('format1-' . $this->fullMediaFileSystemName)->thenReturn(true);
Severity: Minor
Found in MediaAdmin/Tests/FileAlternatives/Strategies/ImageStrategyTest.php - About 1 hr to fix

Method buildForm has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $siteId = null;
        if ($builder->getData() instanceof MediaInterface) {
            $siteId = $builder->getData()->getSiteId();
Severity: Minor
Found in MediaAdminBundle/Form/Type/MediaBaseType.php - About 1 hr to fix

Method load has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function load(ObjectManager $manager)
    {
        $site =  $this->getReference('site2');

        $rootImages = new MediaFolder();
Severity: Minor
Found in MediaAdminBundle/DataFixtures/MongoDB/LoadFolderData.php - About 1 hr to fix

Method transform has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function transform($mixed, array $params = array())
    {
        $facade = $this->newFacade();

        $facade->id = $mixed->getId();
Severity: Minor
Found in MediaAdminBundle/Transformer/MediaTransformer.php - About 1 hr to fix

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

    public function setUp()
    {
        $repository = Phake::mock('OpenOrchestra\Media\Repository\FolderRepositoryInterface');
        Phake::when($repository)->findFolderTree(Phake::anyParameters())->thenReturn(
            array (

Method provideConfig has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function provideConfig()
    {
        return array(
            array(
                'empty',

Method buildForm has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('id', 'text', array(
            'label' => 'open_orchestra_backoffice.form.block.id',
            'constraints' => new NotBlank(),
Severity: Minor
Found in MediaAdminBundle/GenerateForm/Strategies/SlideshowStrategy.php - About 1 hr to fix
Severity
Category
Status
Source
Language