open-orchestra/open-orchestra-cms-bundle

View on GitHub
ApiBundle/Controller/KeywordController.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

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

class KeywordController extends BaseController
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

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

        $keyword = $request->get('term');
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

Returning type array{term:mixed} but checkAction() is declared to return \Symfony\Component\HttpFoundation\Response
Open

        return array('term' => $keyword);

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

        return array();

Call to undeclared method \OpenOrchestra\ApiBundle\Controller\KeywordController::denyAccessUnlessGranted
Open

        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, KeywordInterface::ENTITY_TYPE);
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

Call to undeclared method \OpenOrchestra\ApiBundle\Controller\KeywordController::get
Open

        $repository = $this->get('open_orchestra_model.repository.keyword');
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

Call to undeclared method \OpenOrchestra\ApiBundle\Controller\KeywordController::dispatchEvent
Open

                $this->dispatchEvent(KeywordEvents::KEYWORD_DELETE, new KeywordEvent($keyword));
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

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

            $request->getContent(),
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

Reference to constant KEYWORD_DELETE from undeclared class \OpenOrchestra\ModelInterface\KeywordEvents
Open

                $this->dispatchEvent(KeywordEvents::KEYWORD_DELETE, new KeywordEvent($keyword));
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

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

                $this->dispatchEvent(KeywordEvents::KEYWORD_DELETE, new KeywordEvent($keyword));
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

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

    public function deleteKeywordsAction(Request $request)

Call to undeclared method \OpenOrchestra\ApiBundle\Controller\KeywordController::isGranted
Open

            if ($this->isGranted(ContributionActionInterface::DELETE, $keyword) &&
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

Call to undeclared method \OpenOrchestra\ApiBundle\Controller\KeywordController::get
Open

        $suppressSpecialCharacter = $this->get('open_orchestra_model.helper.suppress_special_character');
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

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

        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, KeywordInterface::ENTITY_TYPE);
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

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

        $configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

Call to undeclared method \OpenOrchestra\ApiBundle\Controller\KeywordController::get
Open

        $facade = $this->get('open_orchestra_api.transformer_manager')->transform('keyword_collection', $collection);
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

Call to undeclared method \OpenOrchestra\ApiBundle\Controller\KeywordController::get
Open

        $keywords = $this->get('open_orchestra_api.transformer_manager')->reverseTransform('keyword_collection', $facade);
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

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

    public function listAction(Request $request)

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\ApiBundle\Controller\KeywordController::getParameter
Open

            $this->getParameter('open_orchestra_api.facade.keyword_collection.class'),
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

Call to undeclared method \OpenOrchestra\ApiBundle\Controller\KeywordController::get
Open

        $keywordRepository = $this->get('open_orchestra_model.repository.keyword');
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

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\ApiBundle\Controller\KeywordController::get
Open

        $facade = $this->get('jms_serializer')->deserialize(
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

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

    public function checkAction(Request $request)

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

    public function checkAction(Request $request)

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

    public function deleteKeywordsAction(Request $request)

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

        $format = $request->get('_format', 'json');
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

Call to undeclared method \OpenOrchestra\ApiBundle\Controller\KeywordController::get
Open

                $this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $keyword)
Severity: Critical
Found in ApiBundle/Controller/KeywordController.php by phan

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

    public function listAction(Request $request)

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

    public function listAction(Request $request)
    {
        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, KeywordInterface::ENTITY_TYPE);
        $mapping = array(
            'label' => 'label'
Severity: Major
Found in ApiBundle/Controller/KeywordController.php and 2 other locations - About 3 hrs to fix
WorkflowAdminBundle/Controller/Api/StatusController.php on lines 38..54
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

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

        $suppressSpecialCharacter = $this->get('open_orchestra_model.helper.suppress_special_character');

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

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

Line exceeds 120 characters; contains 132 characters
Open

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

There are no issues that match your filters.

Category
Status