open-orchestra/open-orchestra-cms-bundle

View on GitHub
WorkflowAdminBundle/Controller/Api/StatusController.php

Summary

Maintainability
A
3 hrs
Test Coverage

Avoid using static access to class '\OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration' in method 'listTableAction'.
Open

        $configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

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

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::dispatchEvent
Open

                $this->dispatchEvent(StatusEvents::STATUS_DELETE, new StatusEvent($status));

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::get
Open

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

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::denyAccessUnlessGranted
Open

        $this->denyAccessUnlessGranted(ContributionActionInterface::DELETE, $status);

Returning type array{} but deleteAction() is declared to return \Symfony\Component\HttpFoundation\Response
Open

        return array();

Possibly zero references to use statement for classlike/namespace Api (\OpenOrchestra\BaseApiBundle\Controller\Annotation)
Open

use OpenOrchestra\BaseApiBundle\Controller\Annotation as Api;

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::denyAccessUnlessGranted
Open

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

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::get
Open

        if (!$this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $status)) {

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::get
Open

        $status = $this->get('open_orchestra_model.repository.status')->find($statusId);

Call to method generateFromRequest from undeclared class \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

        $configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);

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

    public function deleteStatusesAction(Request $request)

Reference to constant STATUS_DELETE from undeclared class \OpenOrchestra\ModelInterface\StatusEvents
Open

        $this->dispatchEvent(StatusEvents::STATUS_DELETE, new StatusEvent($status));

Class extends undeclared class \OpenOrchestra\BaseApiBundle\Controller\BaseController
Open

class StatusController extends BaseController

Call to method getContent from undeclared class \Symfony\Component\HttpFoundation\Request
Open

            $request->getContent(),

Reference to constant STATUS_DELETE from undeclared class \OpenOrchestra\ModelInterface\StatusEvents
Open

                $this->dispatchEvent(StatusEvents::STATUS_DELETE, new StatusEvent($status));

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::isGranted
Open

        return $this->isGranted(ContributionActionInterface::DELETE, $status)

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\WorkflowAdminBundle\Controller\Api\StatusController::get
Open

        return $this->get('open_orchestra_api.transformer_manager')->transform('status_collection', $status);

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

    public function listTableAction(Request $request)

Call to method get from undeclared class \Symfony\Component\HttpFoundation\Request
Open

        $format = $request->get('_format', 'json');

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::get
Open

        $facade = $this->get('jms_serializer')->deserialize(

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::get
Open

        $statuses = $this->get('open_orchestra_api.transformer_manager')->reverseTransform('status_collection', $facade);

@throws annotation of deleteAction has suspicious class type \OpenOrchestra\WorkflowAdminBundle\Exceptions\HttpException\StatusNotDeletableException, which does not extend Error/Exception
Open

    public function deleteAction($statusId)

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::get
Open

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

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::get
Open

            && $this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $status);

Return type of listTableAction() is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    public function listTableAction(Request $request)

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

    public function deleteAction($statusId)

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

                $this->dispatchEvent(StatusEvents::STATUS_DELETE, new StatusEvent($status));

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::get
Open

        $status = $this->get('open_orchestra_model.repository.status')->findNotOutOfWorkflow();

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

    protected function isDeleteGranted(StatusInterface $status)

Return type of listAction() is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    public function listAction()

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

    public function deleteStatusesAction(Request $request)

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::get
Open

        $statusRepository = $this->get('open_orchestra_model.repository.status');

Returning type array{} but deleteStatusesAction() is declared to return \Symfony\Component\HttpFoundation\Response
Open

        return array();

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

        $this->dispatchEvent(StatusEvents::STATUS_DELETE, new StatusEvent($status));

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::get
Open

        $facade = $this->get('open_orchestra_api.transformer_manager')->transform('status_collection', $collection);

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::getParameter
Open

            $this->getParameter('open_orchestra_workflow_admin.facade.status_collection.class'),

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Controller\Api\StatusController::dispatchEvent
Open

        $this->dispatchEvent(StatusEvents::STATUS_DELETE, new StatusEvent($status));

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

    public function listTableAction(Request $request)
    {
        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, StatusInterface::ENTITY_TYPE);
        $mapping = array(
            'label' => 'labels'
Severity: Major
Found in WorkflowAdminBundle/Controller/Api/StatusController.php and 2 other locations - About 3 hrs to fix
ApiBundle/Controller/KeywordController.php on lines 54..70
WorkflowAdminBundle/Controller/Api/WorkflowProfileController.php on lines 35..51

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

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 121 characters
Open

        $statuses = $this->get('open_orchestra_api.transformer_manager')->reverseTransform('status_collection', $facade);

Line exceeds 120 characters; contains 131 characters
Open

            && $this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $status);

Line exceeds 120 characters; contains 131 characters
Open

        if (!$this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $status)) {

There are no issues that match your filters.

Category
Status