Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
This issue was found while working on #2824935: Fix Squiz.ControlStructures.SwitchDeclaration coding standard.
Drupal\field\Plugin\migrate\process\d7\FieldInstanceDefaults::transform() contains a switch
statement with only a default
statement. This violates the Squiz.ControlStructures.SwitchDeclaration coding standard: SWITCH statements must contain at least one CASE statement.
This issue is fixed separately, since it allows for discussion regarding the migration system rather than coding standards.
Proposed resolution
Refactor the code to remove the switch statement.
Remaining tasks
- Write a patch
- Review
- Commit
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2972045-2.patch | 780 bytes | idebr |
Comments
Comment #2
idebr CreditAttribution: idebr at ezCompany commentedAttached patch removes the
switch
statement, since all actions result in the same return value. The first widget type that requires special processing can add the switch statement, or use an if-statement like the email_textfield does in the file.Comment #3
borisson_This looks very good, a nice simplification. I don't feel confident enough about the migration system to RTBC this issue.
Comment #4
jofitz CreditAttribution: jofitz at ComputerMinds commentedA nice, straightforward fix.
Comment #5
alexpottThere's no bug here per se so changing to a task.
Committed 7c6d444 and pushed to 8.6.x. Thanks!