SU-SWS/stanford_migrate

View on GitHub
src/Form/StanfordMigrateCsvImportForm.php

Summary

Maintainability
A
1 hr
Test Coverage
A
93%

Method buildForm has 56 lines of code (exceeds 40 allowed). Consider refactoring.
Open

  public function buildForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildForm($form, $form_state);
    $migration_id = $this->entity->id();
    $template_link = Link::fromTextAndUrl($this->t('empty CSV template'), $this->entity->toUrl('csv-template'))
      ->toString();
Severity: Major
Found in src/Form/StanfordMigrateCsvImportForm.php - About 1 hr to fix

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

    class StanfordMigrateCsvImportForm extends EntityForm {
    
      /**
       * Migration plugin instance that matches the migration entity.
       *

    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

    syntax error, unexpected 'protected' (T_PROTECTED), expecting variable (T_VARIABLE)
    Invalid

      public function __construct(protected MigrationPluginManagerInterface $migrationManager, protected StateInterface $state, protected FileUsageInterface $fileUsage, EntityTypeManagerInterface $entityTypeManager) {
    Severity: Critical
    Found in src/Form/StanfordMigrateCsvImportForm.php by phan

    Avoid excessively long variable names like $previously_uploaded_files. Keep variable name length under 20.
    Wontfix

        $previously_uploaded_files = $this->state->get("stanford_migrate.csv.$migration_id", []);

    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

    Doc comment short description must end with a full stop
    Invalid

       * {@inheritDoc}

    Doc comment short description must start with a capital letter
    Invalid

       * {@inheritDoc}

    Doc comment short description must end with a full stop
    Invalid

       * {@inheritDoc}

    Doc comment short description must end with a full stop
    Invalid

       * {@inheritDoc}

    Doc comment short description must start with a capital letter
    Invalid

       * {@inheritDoc}

    Doc comment short description must start with a capital letter
    Invalid

       * {@inheritDoc}

    Doc comment short description must end with a full stop
    Invalid

       * {@inheritDoc}

    Doc comment short description must start with a capital letter
    Invalid

       * {@inheritDoc}

    There are no issues that match your filters.

    Category
    Status