VSVverkeerskunde/gvq-api

View on GitHub
src/Contest/Forms/ContestFormType.php

Summary

Maintainability
B
4 hrs
Test Coverage

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

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        /** @var TranslatorInterface $translator */
        $translator = $options['translator'];

Severity: Major
Found in src/Contest/Forms/ContestFormType.php - About 3 hrs to fix

    Method newContestParticipationFromData has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            UuidFactoryInterface $uuidFactory,
            Year $year,
            Language $language,
            QuizChannel $channel,
            Email $email,
    Severity: Minor
    Found in src/Contest/Forms/ContestFormType.php - About 45 mins to fix

      The method buildForm() has 105 lines of code. Current threshold is set to 100. Avoid really long methods.
      Open

          public function buildForm(FormBuilderInterface $builder, array $options)
          {
              /** @var TranslatorInterface $translator */
              $translator = $options['translator'];
      
      
      Severity: Minor
      Found in src/Contest/Forms/ContestFormType.php by phpmd

      The class ContestFormType has a coupling between objects value of 20. Consider to reduce the number of dependencies under 13.
      Open

      class ContestFormType extends AbstractType
      {
          /**
           * @inheritdoc
           */
      Severity: Minor
      Found in src/Contest/Forms/ContestFormType.php by phpmd

      CouplingBetweenObjects

      Since: 1.1.0

      A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

      Example

      class Foo {
          /**
           * @var \foo\bar\X
           */
          private $x = null;
      
          /**
           * @var \foo\bar\Y
           */
          private $y = null;
      
          /**
           * @var \foo\bar\Z
           */
          private $z = null;
      
          public function setFoo(\Foo $foo) {}
          public function setBar(\Bar $bar) {}
          public function setBaz(\Baz $baz) {}
      
          /**
           * @return \SplObjectStorage
           * @throws \OutOfRangeException
           * @throws \InvalidArgumentException
           * @throws \ErrorException
           */
          public function process(\Iterator $it) {}
      
          // ...
      }

      Source https://phpmd.org/rules/design.html#couplingbetweenobjects

      Define a constant instead of duplicating this literal "message" 5 times.
      Open

                                      'message' => $translator->trans('Field.empty'),
      Severity: Critical
      Found in src/Contest/Forms/ContestFormType.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Define a constant instead of duplicating this literal "constraints" 6 times.
      Open

                          'constraints' => $this->createTextConstraint($translator),
      Severity: Critical
      Found in src/Contest/Forms/ContestFormType.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Define a constant instead of duplicating this literal "Field.empty" 5 times.
      Open

                                      'message' => $translator->trans('Field.empty'),
      Severity: Critical
      Found in src/Contest/Forms/ContestFormType.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Define a constant instead of duplicating this literal "association" 5 times.
      Open

              if ($options['association']) {
      Severity: Critical
      Found in src/Contest/Forms/ContestFormType.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Define a constant instead of duplicating this literal "label" 4 times.
      Open

                          'label' => $translator->trans('Contest.18years'),
      Severity: Critical
      Found in src/Contest/Forms/ContestFormType.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      There are no issues that match your filters.

      Category
      Status