open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Form/Type/SiteAliasType.php

Summary

Maintainability
C
7 hrs
Test Coverage

Method buildForm has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('scheme', 'choice', array(
                'choices' => $this->schemeChoices,
Severity: Major
Found in Backoffice/Form/Type/SiteAliasType.php - About 3 hrs to fix

Method configureOptions has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            array(
                'data_class' => $this->siteAliasClass,
Severity: Minor
Found in Backoffice/Form/Type/SiteAliasType.php - About 1 hr to fix

Avoid unused parameters such as '$form'.
Open

    public function buildView(FormView $view, FormInterface $form, array $options)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$options'.
Open

    public function buildView(FormView $view, FormInterface $form, array $options)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$options'.
Open

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

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Reference to instance property vars from undeclared class \Symfony\Component\Form\FormView
Open

        $data = $view->vars['columns']['language']['data'];
Severity: Minor
Found in Backoffice/Form/Type/SiteAliasType.php by phan

Parameter $view has undeclared type \Symfony\Component\Form\FormView
Open

    public function buildView(FormView $view, FormInterface $form, array $options)
Severity: Minor
Found in Backoffice/Form/Type/SiteAliasType.php by phan

Reference to constant SCHEME_HTTPS from undeclared class \OpenOrchestra\ModelInterface\Model\SchemeableInterface
Open

            SchemeableInterface::SCHEME_HTTPS => 'open_orchestra_backoffice.scheme.https'
Severity: Critical
Found in Backoffice/Form/Type/SiteAliasType.php by phan

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

        $resolver->setDefaults(
Severity: Critical
Found in Backoffice/Form/Type/SiteAliasType.php by phan

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

    public function configureOptions(OptionsResolver $resolver)
Severity: Minor
Found in Backoffice/Form/Type/SiteAliasType.php by phan

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

    public function buildForm(FormBuilderInterface $builder, array $options)
Severity: Minor
Found in Backoffice/Form/Type/SiteAliasType.php by phan

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

class SiteAliasType extends AbstractType
Severity: Critical
Found in Backoffice/Form/Type/SiteAliasType.php by phan

Parameter $form has undeclared type \Symfony\Component\Form\FormInterface
Open

    public function buildView(FormView $view, FormInterface $form, array $options)
Severity: Minor
Found in Backoffice/Form/Type/SiteAliasType.php by phan

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

        $builder
Severity: Critical
Found in Backoffice/Form/Type/SiteAliasType.php by phan

Reference to constant SCHEME_HTTP from undeclared class \OpenOrchestra\ModelInterface\Model\SchemeableInterface
Open

            SchemeableInterface::SCHEME_HTTP => 'open_orchestra_backoffice.scheme.http',
Severity: Critical
Found in Backoffice/Form/Type/SiteAliasType.php by phan

Reference to instance property vars from undeclared class \Symfony\Component\Form\FormView
Open

        $view->vars['columns']['language']['data'] = (array_key_exists($data, $this->frontLanguages)) ? $this->frontLanguages[$data] : '';
Severity: Minor
Found in Backoffice/Form/Type/SiteAliasType.php by phan

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        $resolver->setDefaults(
            array(
                'data_class' => $this->siteAliasClass,
                'columns' => array('domain', 'language', 'prefix'),
                'group_enabled' => true,
Severity: Major
Found in Backoffice/Form/Type/SiteAliasType.php and 1 other location - About 3 hrs to fix
Backoffice/Tests/Form/Type/SiteAliasTypeTest.php on lines 67..101

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

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

The closing brace for the class must go on the next line after the body
Open

}

Line exceeds 120 characters; contains 138 characters
Open

        $view->vars['columns']['language']['data'] = (array_key_exists($data, $this->frontLanguages)) ? $this->frontLanguages[$data] : '';

There are no issues that match your filters.

Category
Status