open-orchestra/open-orchestra-cms-bundle

View on GitHub
GroupBundle/Controller/Admin/GroupController.php

Summary

Maintainability
B
6 hrs
Test Coverage

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

    public function newAction(Request $request)
    {
        $groupClass = $this->getParameter('open_orchestra_user.document.group.class');
        /** @var GroupInterface $group */
        $group = new $groupClass();
Severity: Minor
Found in GroupBundle/Controller/Admin/GroupController.php - About 1 hr to fix

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::get
Open

        $group->setSite($this->get('open_orchestra_model.repository.site')->findOneBySiteId($siteId));

Call to method __construct from undeclared class \Symfony\Component\HttpFoundation\Response
Open

            $response = new Response(

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::denyAccessUnlessGranted
Open

        $this->denyAccessUnlessGranted(ContributionActionInterface::EDIT, $group);

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::generateUrl
Open

            'action' => $this->generateUrl('open_orchestra_group_form', array(

Call to method handleRequest from undeclared class \Symfony\Component\Form\Form
Open

        $form->handleRequest($request);

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::denyAccessUnlessGranted
Open

        $this->denyAccessUnlessGranted(ContributionActionInterface::CREATE, $group);

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::get
Open

            $documentManager = $this->get('object_manager');

Return type of formAction() is undeclared type \Symfony\Component\HttpFoundation\Response
Open

    public function formAction(Request $request, $groupId)

Argument 2 (event) is \OpenOrchestra\UserBundle\Event\GroupEvent but \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::dispatchEvent() takes \Symfony\Component\EventDispatcher\Event defined at /code/BackofficeBundle/Controller/AbstractAdminController.php:81
Open

            $this->dispatchEvent(GroupEvents::GROUP_UPDATE, new GroupEvent($group));

Call to method handleRequest from undeclared class \Symfony\Component\Form\Form
Open

        $form->handleRequest($request);

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::get
Open

            $message = $this->get('translator')->trans('open_orchestra_group.form.group.new.success');

Call to method __construct from undeclared class \OpenOrchestra\UserBundle\Event\GroupEvent
Open

            $this->dispatchEvent(GroupEvents::GROUP_CREATE, new GroupEvent($group));

Call to method __construct from undeclared class \OpenOrchestra\UserBundle\Event\GroupEvent
Open

            $this->dispatchEvent(GroupEvents::GROUP_UPDATE, new GroupEvent($group));

Argument 1 (form) is \Symfony\Component\Form\Form but \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::renderAdminForm() takes \Symfony\Component\Form\FormInterface defined at /code/BackofficeBundle/Controller/AbstractAdminController.php:58
Open

        return $this->renderAdminForm($form);

Return type of newAction() is undeclared type \Symfony\Component\HttpFoundation\Response
Open

    public function newAction(Request $request)

Possibly zero references to use statement for classlike/namespace Config (\Sensio\Bundle\FrameworkExtraBundle\Configuration)
Open

use Sensio\Bundle\FrameworkExtraBundle\Configuration as Config;

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::isGranted
Open

            'delete_button' => $this->isGranted(ContributionActionInterface::DELETE, $group)

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::getParameter
Open

        $groupClass = $this->getParameter('open_orchestra_user.document.group.class');

Argument 2 (data) is object but \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::createForm() takes null defined at /code/BackofficeBundle/Controller/AbstractAdminController.php:94
Open

        $form = $this->createForm('oo_group', $group, array(

Argument 2 (event) is \OpenOrchestra\UserBundle\Event\GroupEvent but \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::dispatchEvent() takes \Symfony\Component\EventDispatcher\Event defined at /code/BackofficeBundle/Controller/AbstractAdminController.php:81
Open

            $this->dispatchEvent(GroupEvents::GROUP_CREATE, new GroupEvent($group));

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

use OpenOrchestra\Backoffice\Model\GroupInterface;

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::get
Open

        $message = $this->get('translator')->trans('open_orchestra_group.form.group.edit.success');

Reference to constant GROUP_UPDATE from undeclared class \OpenOrchestra\UserBundle\GroupEvents
Open

            $this->dispatchEvent(GroupEvents::GROUP_UPDATE, new GroupEvent($group));

Reference to constant HTTP_CREATED from undeclared class \Symfony\Component\HttpFoundation\Response
Open

                Response::HTTP_CREATED,

Parameter $request has undeclared type \Symfony\Component\HttpFoundation\Request
Open

    public function formAction(Request $request, $groupId)

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::get
Open

        $siteId = $this->get('open_orchestra_backoffice.context_backoffice_manager')->getSiteId();

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::generateUrl
Open

            'action'   => $this->generateUrl('open_orchestra_group_new'),

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::get
Open

            $this->get('session')->getFlashBag()->add('success', $message);

Argument 1 (form) is \Symfony\Component\Form\Form but \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::renderAdminForm() takes \Symfony\Component\Form\FormInterface defined at /code/BackofficeBundle/Controller/AbstractAdminController.php:58
Open

        return $this->renderAdminForm($form);

Call to method isValid from undeclared class \Symfony\Component\Form\Form
Open

        if ($form->isValid()) {

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::get
Open

            'enable_delete_button' => $this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(ContributionActionInterface::DELETE, $group),

Argument 1 (form) is \Symfony\Component\Form\Form but \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::handleForm() takes \Symfony\Component\Form\FormInterface defined at /code/BackofficeBundle/Controller/AbstractAdminController.php:29
Open

        if ($this->handleForm($form, $message)) {

Reference to constant GROUP_CREATE from undeclared class \OpenOrchestra\UserBundle\GroupEvents
Open

            $this->dispatchEvent(GroupEvents::GROUP_CREATE, new GroupEvent($group));

Parameter $request has undeclared type \Symfony\Component\HttpFoundation\Request
Open

    public function newAction(Request $request)

Call to undeclared method \OpenOrchestra\GroupBundle\Controller\Admin\GroupController::get
Open

        $group = $this->get('open_orchestra_user.repository.group')->find($groupId);

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

    public function formAction(Request $request, $groupId)
    {
        $group = $this->get('open_orchestra_user.repository.group')->find($groupId);
        $this->denyAccessUnlessGranted(ContributionActionInterface::EDIT, $group);

Severity: Major
Found in GroupBundle/Controller/Admin/GroupController.php and 1 other location - About 5 hrs to fix
WorkflowAdminBundle/Controller/Admin/StatusController.php on lines 29..48

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 202.

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

Line exceeds 120 characters; contains 127 characters
Open

                array('Content-type' => 'text/plain; charset=utf-8', 'groupId' => $group->getId(), 'name' => $group->getName())

Line exceeds 120 characters; contains 157 characters
Open

            'enable_delete_button' => $this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(ContributionActionInterface::DELETE, $group),

There are no issues that match your filters.

Category
Status