Problem/Motivation
Currently, the module contains inconsistencies in code formatting that do not adhere to the Drupal Coding Standards (Drupal Coding Standards and DrupalPractice). These inconsistencies make the code less readable and can create challenges during code review, in addition to impacting long-term maintainability.
The motivation for this issue is to align the module's code with the recommended standards, making it easier for the community to contribute and ensuring the code is clearer, more maintainable, and compatible with static analysis tools.
By implementing these changes, the module will better align with the Drupal community’s policies, and the effort required for future updates or reviews will be reduced.
Steps to reproduce
- Clone the repo
- cd field_group
- run
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml,css .
Proposed resolution
Fix reported errors and warnings
PHP CODE SNIFFER REPORT SUMMARY
----------------------------------------------------------------------
FILE ERRORS WARNINGS
----------------------------------------------------------------------
...b/modules/contrib/field_group/coding_standard.txt 1 0
...eb/modules/contrib/field_group/field_group.module 5 0
.../src/Plugin/migrate/destination/d7/FieldGroup.php 2 0
...grate/src/Plugin/migrate/source/d7/FieldGroup.php 1 0
...dules/contrib/field_group/src/FormatterHelper.php 1 0
.../modules/field_group_test/field_group_test.module 1 0
----------------------------------------------------------------------
A TOTAL OF 11 ERRORS AND 0 WARNINGS WERE FOUND IN 6 FILESRemaining tasks
User interface changes
API changes
Data model changes
Issue fork field_group-3490746
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
ismaelromero commentedComment #4
a.aaronjake commentedHi @ismaelromero,
I have checked the pipeline and re-ran the phpcs job. Confirmed no errors remaining and the job suceeded.
Will now move this to RTBC
Thanks,
Jake
Comment #5
solideogloria commentedThe function doc comments need to be updated to match the changes.
Comment #7
ekes commentedComment #8
solideogloria commentedPHPUnit failed in the pipeline. Is this the cause?
Comment #10
liam morlandIt passes on Drupal 11.0 but fails on 11.1 and 10.4. I think there was a change in those two that must be breaking it. I suspect it would also work on 10.3 if it was tested there. This looks like the issue addressed by #3491233: Fix Drupal 10.4 RC1 error with field_ui.js.
Comment #11
ressaThanks for working on this, just tagging with PHP 8.4, to easier follow along.
Comment #12
mlncn commentedWorks great on the 4.x branch! No deprecation warnings, and Field Group still works.
(People who contributed partial fixes to issues closed as duplicates who should get credit when this is fixed include prem suthar, deepali sardana, MrDaleSmith, and nickdickinsonwilde. And solideogloria who is already over here!)
Comment #13
musa.thomasThe diff of issue fork can't be applied to the 3.6 version
The issue Fork 8..x-3 seems to be different of the main issue fork ? what should I apply.
Also got this depreciated but seems not to be resolved by the issue
PHP 8.4 got this depreciated :
Deprecated function : field_group_form_process(): Implicitly marking parameter $form_state as nullable is deprecated, the explicit nullable type must be used instead dans include_once() (/var/www/app/web/core/lib/Drupal/Core/Extension/Extension.php ligne 153)Deprecated function : field_group_field_group_form_process_build_alter(): Implicitly marking parameter $form_state as nullable is deprecated, the explicit nullable type must be used instead dans include_once() (/var/www/app/web/core/lib/Drupal/Core/Extension/Extension.php ligne 153)Message Deprecated function : field_group_fields_nest(): Implicitly marking parameter $vars as nullable is deprecated, the explicit nullable type must be used instead dans include_once() (/var/www/app/web/core/lib/Drupal/Core/Extension/Extension.php ligne 153)Message Deprecated function : field_group_field_layout_fields_nest(): Implicitly marking parameter $vars as nullable is deprecated, the explicit nullable type must be used instead dans include_once() (/var/www/app/web/core/lib/Drupal/Core/Extension/Extension.php ligne 153)Message Deprecated function : field_group_group_save(): Implicitly marking parameter $display as nullable is deprecated, the explicit nullable type must be used instead dans include_once() (/var/www/app/web/core/lib/Drupal/Core/Extension/Extension.php ligne 153)Comment #14
liam morlandThis issue is for fixing coding standards in the 4.x branch.
The "Implicitly marking parameter as nullable is deprecated" message has already been fixed in 4.x. The fix for it in 8.x-3.x is discussed in #3504453: Fix PHP 8.4.x deprecation and other warnings (PHPStan).
Comment #16
anybodyComment #17
grevil commentedLGTM! The PHPUnit failure seems to be related to an ajax tests, which seems to fail randomly. As the test succeeded, right before I added a comment, everything will be fine.
We can tackle the random phpunit failures in a follow-up issue (They also succeed locally).
Comment #18
grevil commentedComment #19
anybodyReopened to finally also fix eslint in 3490746-fix-eslint
Comment #23
grevil commentedComment #24
anybodyComment #29
vinodhini.e commentedComment #30
liam morlandThere are still issues raised by eslint.
Comment #31
anybodyWould be great to finally get this one resolved and pipeline green! :) Anyone?
Comment #32
anybodyComment #35
anybodyComment #36
scott_euser commentedSure I can have a quick look and see what I can easily sort
Comment #37
lrwebks commented@scott_euser sorry I was also working on this locally, have you already started? Just so that we don't both do the same thing for no reason here. If you're already on it right now then go ahead.
Comment #38
lrwebks commentedhttps://www.drupal.org/node/3533564
Well that opens up another can of worms. PHPStan is not keen about the deprecated
DrupalSqlBase. It's really not up to me to decide whether to throw out the migrate classes or rework them differently, so any maintainer feedback would be greatly appreciated so that we may continue here.Comment #39
anybody@lrwebks for these two cases I'd suggest something like:
As we don't have D12 support yet and will want to keep these migrations for 4.x-dev.
Comment #40
scott_euser commentedOkay go for it, will stop what I was doing, didn't get very far yet anyways
Comment #41
lrwebks commentedAlright @scott_euser, thank you for the effort nonetheless!
Comment #42
lrwebks commentedI don't even know what to make of some ESLint fixes that it wants me to do. I don't think that we need function docs for
Drupal.oncefor example. Could anyone take a look at what is the best to do here?Comment #43
anybodyNice other fixes @lrwebks! Maybe @scott_euser can take over now for eslint? We're very close to the finish line! :)
Comment #44
lrwebks commentedComment #45
lrwebks commentedThanks, @scott_euser for fixing ESLint!
Comment #46
scott_euser commentedFeedback was addressed now, is this good to go now @anybody or anything else you need first?
Comment #47
anybodyThank you all VERY much! Let's merge this :)
Comment #51
grevil commentedWe introduced a minor regression here: "this.$regionSelect.val(region);" was replaced with "this.$regionSelect.get(0).value". They don't behave equally "get(0)" could return a nullish value, leading to .value throwing an error.
I'll fix it as part of #3613421: Moving fieldgroup under other fieldgroup from disabled, puts the child fieldgroup in disabled (even though it is unrelated).
Comment #52
grevil commentedReverted them in https://git.drupalcode.org/project/field_group/-/merge_requests/141/diff.... I'll talk with @anybody internally, it would be cleaner to merge the changes seperately.
Not quite sure, why we even changed these parts. They shouldn't be concerned by ESLint and are not really cleaner, as both use jquery.
Comment #53
grevil commentedOk, just applied the fixes through https://git.drupalcode.org/project/field_group/-/commit/6ef9c5c6073b3fc8....
Comment #54
grevil commentedOk, it seems that core now uses the "eslint-plugin-no-jquery" so the eslint job still fails, as this module uses jquery quite a bit. I'll create a follow-up issue for that.
Comment #55
scott_euser commentedI think that's what I had originally fixed, but not able to check at the moment