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

  1. Clone the repo
  2. cd field_group
  3. 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 FILES

Remaining tasks

User interface changes

API changes

Data model changes

Command icon 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

ismaelromero created an issue. See original summary.

ismaelromero’s picture

Status: Active » Needs review
a.aaronjake’s picture

Status: Needs review » Reviewed & tested by the community

Hi @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

solideogloria’s picture

Status: Reviewed & tested by the community » Needs work

The function doc comments need to be updated to match the changes.

ekes made their first commit to this issue’s fork.

ekes’s picture

Status: Needs work » Needs review
solideogloria’s picture

PHPUnit failed in the pipeline. Is this the cause?

liam morland made their first commit to this issue’s fork.

liam morland’s picture

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

ressa’s picture

Issue tags: +PHP 8.4

Thanks for working on this, just tagging with PHP 8.4, to easier follow along.

mlncn’s picture

Status: Needs review » Reviewed & tested by the community

Works 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!)

musa.thomas’s picture

The 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)

liam morland’s picture

This 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).

grevil made their first commit to this issue’s fork.

anybody’s picture

Status: Reviewed & tested by the community » Needs work
grevil’s picture

Status: Needs work » Reviewed & tested by the community

LGTM! 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).

grevil’s picture

Status: Reviewed & tested by the community » Fixed
anybody’s picture

Reopened to finally also fix eslint in 3490746-fix-eslint

anybody changed the visibility of the branch 8.x-3.x to hidden.

anybody changed the visibility of the branch 4.x to hidden.

anybody changed the visibility of the branch 3490746-fix-coding-standard to hidden.

grevil’s picture

Title: Fix coding standard » Fix ESLint coding standards
anybody’s picture

Status: Active » Needs work
Issue tags: -PHP 8.4 +Novice

apso changed the visibility of the branch 8.x-3.x to active.

apso changed the visibility of the branch 8.x-3.x to hidden.

vinodhini.e made their first commit to this issue’s fork.

vinodhini.e’s picture

Status: Needs work » Needs review
liam morland’s picture

Status: Needs review » Needs work

There are still issues raised by eslint.

anybody’s picture

Title: Fix ESLint coding standards » Fix ESLint, phpcs, phpstan coding standards

Would be great to finally get this one resolved and pipeline green! :) Anyone?

anybody’s picture

Title: Fix ESLint, phpcs, phpstan coding standards » Fix ESLint, phpstan coding standards

anybody changed the visibility of the branch 3490746-fix-eslint to hidden.

anybody’s picture

Title: Fix ESLint, phpstan coding standards » Fix ESLint, phpcs, phpstan, cspell coding standards
scott_euser’s picture

Assigned: Unassigned » scott_euser

Sure I can have a quick look and see what I can easily sort

lrwebks’s picture

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

lrwebks’s picture

https://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.

anybody’s picture

@lrwebks for these two cases I'd suggest something like:

/**
 * @phpstan-ignore-next-line DrupalSqlBase is removed in Drupal 12 and has no replacement.
 */
class ...

As we don't have D12 support yet and will want to keep these migrations for 4.x-dev.

scott_euser’s picture

Assigned: scott_euser » Unassigned

Okay go for it, will stop what I was doing, didn't get very far yet anyways

lrwebks’s picture

Alright @scott_euser, thank you for the effort nonetheless!

lrwebks’s picture

I 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.once for example. Could anyone take a look at what is the best to do here?

anybody’s picture

Nice other fixes @lrwebks! Maybe @scott_euser can take over now for eslint? We're very close to the finish line! :)

lrwebks’s picture

Status: Needs work » Needs review
lrwebks’s picture

Thanks, @scott_euser for fixing ESLint!

scott_euser’s picture

Status: Needs review » Reviewed & tested by the community

Feedback was addressed now, is this good to go now @anybody or anything else you need first?

anybody’s picture

Status: Reviewed & tested by the community » Fixed

Thank you all VERY much! Let's merge this :)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • anybody committed 9dd5c102 on 4.x
    feat: #3490746 Fix ESLint, phpstan coding standards  By: ismaelromero By...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

grevil’s picture

Issue tags: -Novice

We 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).

grevil’s picture

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

grevil’s picture

grevil’s picture

Ok, 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.

scott_euser’s picture

I think that's what I had originally fixed, but not able to check at the moment