open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Form/Type/Component/KeywordsChoiceType.php

Summary

Maintainability
A
35 mins
Test Coverage

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

        CsvToReferenceKeywordTransformer $csvToReferenceKeywordTransformer,
        ConditionToReferenceKeywordTransformer $conditionToReferenceKeywordTransformer,
        KeywordRepositoryInterface $keywordRepository,
        RouterInterface $router,
        AuthorizationCheckerInterface $authorizationChecker
Severity: Minor
Found in Backoffice/Form/Type/Component/KeywordsChoiceType.php - About 35 mins to fix

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

        else {
            $builder->addModelTransformer($this->csvToReferenceKeywordTransformer);
        }

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

Parameter $router has undeclared type \Symfony\Component\Routing\RouterInterface
Open

    public function __construct(

Call to method findAll from undeclared class \OpenOrchestra\ModelInterface\Repository\KeywordRepositoryInterface
Open

        $keywords = $this->keywordRepository->findAll();

Parameter $keywordRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\KeywordRepositoryInterface
Open

    public function __construct(

Call to method isGranted from undeclared class \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
Open

        $isGranted = $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, KeywordInterface::ENTITY_TYPE);

Class extends undeclared class \Symfony\Component\Form\AbstractType
Open

class KeywordsChoiceType extends AbstractType

Parameter $authorizationChecker has undeclared type \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
Open

    public function __construct(

Suspicious array access to \Symfony\Component\OptionsResolver\Options
Open

                $default['class'] = $options['is_condition'] ? 'select-boolean' : 'select2';

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

        $isGranted = $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, KeywordInterface::ENTITY_TYPE);

Call to method addModelTransformer from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open

            $builder->addModelTransformer($this->conditionToReferenceKeywordTransformer);

Call to method generate from undeclared class \Symfony\Component\Routing\RouterInterface
Open

                    'data-check' => $this->router->generate('open_orchestra_api_check_keyword', array()),

Parameter $options has undeclared type \Symfony\Component\OptionsResolver\Options
Open

            'attr' => function(Options $options) use ($isGranted) {

Suspicious array access to \Symfony\Component\OptionsResolver\Options
Open

                return array_replace($default, $options['new_attr']);

Call to method setDefaults from undeclared class \Symfony\Component\OptionsResolver\OptionsResolver
Open

        $resolver->setDefaults(array(

Parameter $resolver has undeclared type \Symfony\Component\OptionsResolver\OptionsResolver
Open

    public function configureOptions(OptionsResolver $resolver)

Call to method addModelTransformer from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open

            $builder->addModelTransformer($this->csvToReferenceKeywordTransformer);

Parameter $builder has undeclared type \Symfony\Component\Form\FormBuilderInterface
Open

    public function buildForm(FormBuilderInterface $builder, array $options)

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

    protected $csvToReferenceKeywordTransformer;

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

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

    protected $conditionToReferenceKeywordTransformer;

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

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

        ConditionToReferenceKeywordTransformer $conditionToReferenceKeywordTransformer,

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

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

        CsvToReferenceKeywordTransformer $csvToReferenceKeywordTransformer,

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

There must be a single space between the closing parenthesis and the opening brace of a multi-line function declaration; found 0 spaces
Open

    ){

Expected 1 space after FUNCTION keyword; 0 found
Open

            'attr' => function(Options $options) use ($isGranted) {

Line exceeds 120 characters; contains 128 characters
Open

        $isGranted = $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, KeywordInterface::ENTITY_TYPE);

Expected 1 space after closing brace; newline found
Open

        }

There are no issues that match your filters.

Category
Status