open-orchestra/open-orchestra-cms-bundle

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

Summary

Maintainability
A
3 hrs
Test Coverage

Avoid using static access to class '\OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration' in method 'listAction'.
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

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

    public function listAction(Request $request)

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

                $this->dispatchEvent(WorkflowProfileEvents::WORKFLOW_PROFILE_DELETE, new WorkflowProfileEvent($workflowProfile));

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

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

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

                $this->dispatchEvent(WorkflowProfileEvents::WORKFLOW_PROFILE_DELETE, new WorkflowProfileEvent($workflowProfile));

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\WorkflowProfileController::get
Open

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

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

        $workflowProfile = $this->get('open_orchestra_model.repository.workflow_profile')->find($workflowProfileId);

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\WorkflowProfileController::get
Open

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

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

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

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

            if ($this->isGranted(ContributionActionInterface::DELETE, $workflowProfile)) {

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

            $this->dispatchEvent(WorkflowProfileEvents::WORKFLOW_PROFILE_DELETE, new WorkflowProfileEvent($workflowProfile));

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

class WorkflowProfileController extends BaseController

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

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

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

        if ($workflowProfile instanceof WorkflowProfileInterface) {

Reference to constant WORKFLOW_PROFILE_DELETE from undeclared class \OpenOrchestra\ModelInterface\WorkflowProfileEvents
Open

                $this->dispatchEvent(WorkflowProfileEvents::WORKFLOW_PROFILE_DELETE, new WorkflowProfileEvent($workflowProfile));

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

    public function deleteAction($workflowProfileId)

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

        return array();

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

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

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

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

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

            $this->dispatchEvent(WorkflowProfileEvents::WORKFLOW_PROFILE_DELETE, new WorkflowProfileEvent($workflowProfile));

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

            $request->getContent(),

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

    public function listAction(Request $request)

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

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

Reference to constant WORKFLOW_PROFILE_DELETE from undeclared class \OpenOrchestra\ModelInterface\WorkflowProfileEvents
Open

            $this->dispatchEvent(WorkflowProfileEvents::WORKFLOW_PROFILE_DELETE, new WorkflowProfileEvent($workflowProfile));

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

    public function deleteWorkflowProfilesAction(Request $request)

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

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

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

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

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 deleteWorkflowProfilesAction(Request $request)

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

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

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

    public function listAction(Request $request)
    {
        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, WorkflowProfileInterface::ENTITY_TYPE);
        $mapping = array(
            'label' => 'labels'
ApiBundle/Controller/KeywordController.php on lines 54..70
WorkflowAdminBundle/Controller/Api/StatusController.php on lines 38..54

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

Avoid excessively long variable names like $workflowProfileRepository. Keep variable name length under 20.
Open

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

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Line exceeds 120 characters; contains 125 characters
Open

            $this->dispatchEvent(WorkflowProfileEvents::WORKFLOW_PROFILE_DELETE, new WorkflowProfileEvent($workflowProfile));

Line exceeds 120 characters; contains 139 characters
Open

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

Line exceeds 120 characters; contains 126 characters
Open

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

Line exceeds 120 characters; contains 129 characters
Open

                $this->dispatchEvent(WorkflowProfileEvents::WORKFLOW_PROFILE_DELETE, new WorkflowProfileEvent($workflowProfile));

There are no issues that match your filters.

Category
Status