open-orchestra/open-orchestra-cms-bundle

View on GitHub
BackofficeBundle/Controller/NodeController.php

Summary

Maintainability
B
6 hrs
Test Coverage

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

    public function newAction(Request $request, $siteId, $language, $parentId, $order)
    {
        $order = (int) $order;
        $nodeManager = $this->get('open_orchestra_backoffice.manager.node');
        $nodeRepository = $this->get('open_orchestra_model.repository.node');
Severity: Minor
Found in BackofficeBundle/Controller/NodeController.php - About 1 hr to fix

Method formAction has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function formAction(Request $request, $siteId, $nodeId, $language, $version)
    {
        $nodeRepository = $this->get('open_orchestra_model.repository.node');
        if (null === $version) {
            $node = $nodeRepository->findInLastVersion($nodeId, $language, $siteId);
Severity: Minor
Found in BackofficeBundle/Controller/NodeController.php - About 1 hr to fix

Function newAction has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function newAction(Request $request, $siteId, $language, $parentId, $order)
    {
        $order = (int) $order;
        $nodeManager = $this->get('open_orchestra_backoffice.manager.node');
        $nodeRepository = $this->get('open_orchestra_model.repository.node');
Severity: Minor
Found in BackofficeBundle/Controller/NodeController.php - About 55 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 formAction has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function formAction(Request $request, $siteId, $nodeId, $language, $version)
Severity: Minor
Found in BackofficeBundle/Controller/NodeController.php - About 35 mins to fix

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

    public function newAction(Request $request, $siteId, $language, $parentId, $order)
Severity: Minor
Found in BackofficeBundle/Controller/NodeController.php - About 35 mins to fix

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

    public function createForm($type, $data = null, array $options = array(), $editionRole = null, StatusInterface $status = null)
Severity: Minor
Found in BackofficeBundle/Controller/NodeController.php - About 35 mins to fix

Function formAction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function formAction(Request $request, $siteId, $nodeId, $language, $version)
    {
        $nodeRepository = $this->get('open_orchestra_model.repository.node');
        if (null === $version) {
            $node = $nodeRepository->findInLastVersion($nodeId, $language, $siteId);
Severity: Minor
Found in BackofficeBundle/Controller/NodeController.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 '45', column '23').
Open

            throw new \UnexpectedValueException();

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

The method formAction uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $node = $nodeRepository->findVersionNotDeleted($nodeId, $language, $siteId, $version);
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Expected @param annotation for language to be before the @param annotation for version
Open

     * @param string  $version

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

    public function formAction(Request $request, $siteId, $nodeId, $language, $version)

Checking instanceof against undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

        if (!$node instanceof NodeInterface) {

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open

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

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

use Sensio\Bundle\FrameworkExtraBundle\Configuration as Config;

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

    public function formAction(Request $request, $siteId, $nodeId, $language, $version)

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open

            $this->get('object_manager')->flush();

Reference to constant NODE_UPDATE from undeclared class \OpenOrchestra\ModelInterface\NodeEvents
Open

            $this->dispatchEvent(NodeEvents::NODE_UPDATE, new NodeEvent($node));

Call to method __construct from undeclared class \OpenOrchestra\ModelInterface\Event\NodeEvent
Open

            $nodesEvent[] = new NodeEvent($node);

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open

            $message = $this->get('translator')->trans('open_orchestra_backoffice.form.node.success');

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open

        $nodeRepository = $this->get('open_orchestra_model.repository.node');

Call to method __construct from undeclared class \OpenOrchestra\ModelInterface\Event\NodeEvent
Open

            $this->dispatchEvent(NodeEvents::NODE_UPDATE, new NodeEvent($node));

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open

            $message = $this->get('translator')->trans('open_orchestra_backoffice.form.node.success');

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open

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

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

        return $this->renderAdminForm($form);

Parameter $status has undeclared type \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

    public function createForm($type, $data = null, array $options = array(), $editionRole = null, StatusInterface $status = null)

Return type of createForm() is undeclared type \Symfony\Component\Form\Form
Open

    public function createForm($type, $data = null, array $options = array(), $editionRole = null, StatusInterface $status = null)

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

        if ($form->isValid()) {

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

        $form->handleRequest($request);

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

        if ($form->isValid()) {

Parameter $type has undeclared type \Symfony\Component\Form\FormTypeInterface
Open

    public function createForm($type, $data = null, array $options = array(), $editionRole = null, StatusInterface $status = null)

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::isGranted
Open

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

Reference to constant NODE_CREATION from undeclared class \OpenOrchestra\ModelInterface\NodeEvents
Open

                $this->dispatchEvent(NodeEvents::NODE_CREATION, $nodeEvent);

Call to method isBlockedEdition from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

        if (null !== $status && $status->isBlockedEdition()) {

Call to method getTemplate from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

        $template = $node->getTemplate();

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open

                $node = $this->get('open_orchestra_backoffice.manager.node')->initializeAreasNode($node);

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::generateUrl
Open

        $url = $this->generateUrl('open_orchestra_backoffice_node_new', array(

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

        $form->handleRequest($request);

Argument 2 (event) is \OpenOrchestra\ModelInterface\Event\NodeEvent but \OpenOrchestra\BackofficeBundle\Controller\NodeController::dispatchEvent() takes \Symfony\Component\EventDispatcher\Event defined at /code/BackofficeBundle/Controller/AbstractAdminController.php:81
Open

                $this->dispatchEvent(NodeEvents::NODE_CREATION, $nodeEvent);

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

                Response::HTTP_CREATED,

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::denyAccessUnlessGranted
Open

        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, $node);

Call to method getTemplate from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

            if ($template !== $node->getTemplate()) {

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

    public function newAction(Request $request, $siteId, $language, $parentId, $order)

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::denyAccessUnlessGranted
Open

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

Argument 2 (event) is \OpenOrchestra\ModelInterface\Event\NodeEvent but \OpenOrchestra\BackofficeBundle\Controller\NodeController::dispatchEvent() takes \Symfony\Component\EventDispatcher\Event defined at /code/BackofficeBundle/Controller/AbstractAdminController.php:81
Open

            $this->dispatchEvent(NodeEvents::NODE_UPDATE, new NodeEvent($node));

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

        return $this->renderAdminForm($form);

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open

        $nodeManager = $this->get('open_orchestra_backoffice.manager.node');

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

            $response = new Response(

Argument 2 (data) is \OpenOrchestra\ModelInterface\Model\NodeInterface but \OpenOrchestra\BackofficeBundle\Controller\NodeController::createForm() takes null defined at /code/BackofficeBundle/Controller/NodeController.php:173
Open

        $form = $this->createForm('oo_node', $node, $options, ContributionActionInterface::EDIT, $node->getStatus());

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

    public function newAction(Request $request, $siteId, $language, $parentId, $order)

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::generateUrl
Open

        $url = $this->generateUrl('open_orchestra_backoffice_node_form', array(

Call to method getStatus from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

        $form = $this->createForm('oo_node', $node, $options, ContributionActionInterface::EDIT, $node->getStatus());

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open

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

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open

        $nodeRepository = $this->get('open_orchestra_model.repository.node');

Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open

            $languages = $this->get('open_orchestra_backoffice.context_backoffice_manager')->getSiteLanguages();

Call to method __construct from undeclared class \OpenOrchestra\ModelInterface\Event\NodeEvent
Open

                    $nodesEvent[] = new NodeEvent($translatedNode);

Line exceeds 120 characters; contains 152 characters
Open

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

Line exceeds 120 characters; contains 130 characters
Open

    public function createForm($type, $data = null, array $options = array(), $editionRole = null, StatusInterface $status = null)

There are no issues that match your filters.

Category
Status