Running PHPCS shows the warnings/errors in attached file, which should be fixed.

CommentFileSizeAuthor
chosen.txt9.2 KBggh

Issue fork chosen-3513892

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

ggh created an issue. See original summary.

ggh’s picture

Assigned: ggh » Unassigned
Status: Active » Needs review

MR Raised

bhupesh_upadhyay’s picture

Assigned: Unassigned » bhupesh_upadhyay

It looks like there are few issues that needs to be fixed.

FILE: /var/www/html/drupal10_contro/web/modules/contrib/chosen/src/ChosenFormRender.php
---------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------------------
38 | ERROR | Type hint "array" missing for $element
125 | ERROR | Type hint "array" missing for $element
143 | ERROR | Type hint "array" missing for $element
---------------------------------------------------------------------------------------

FILE: /var/www/html/drupal10_contro/web/modules/contrib/chosen/modules/chosen_field/src/Plugin/Field/FieldWidget/ChosenFieldWidget.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
25 | ERROR | [x] Missing class doc comment
--------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupal10_contro/web/modules/contrib/chosen/modules/chosen_field/tests/src/Functional/ChosenFieldWidgetsTest.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------------------------------------------------------------
40 | ERROR | Class property $card_1 should use lowerCamel naming without underscores
47 | ERROR | Class property $card_2 should use lowerCamel naming without underscores
94 | ERROR | The array declaration extends to column 101 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupal10_contro/web/modules/contrib/chosen/modules/chosen_lib/src/Commands/ChosenLibCommands.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
151 | ERROR | The array declaration extends to column 91 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupal10_contro/web/modules/contrib/chosen/chosen.module
-------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
-------------------------------------------------------------------------------------
19 | WARNING | Global constants should not be used, move it to a class or interface
20 | WARNING | Global constants should not be used, move it to a class or interface
21 | WARNING | Global constants should not be used, move it to a class or interface
22 | WARNING | Global constants should not be used, move it to a class or interface
-------------------------------------------------------------------------------------

bhupesh_upadhyay’s picture

Status: Needs review » Needs work

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

schillerm’s picture

Hi, I reviewed !MR18 and got some warnings and errors.. see below..

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml web/modules/contrib/chosen

FILE: ...-11-3513892/web/modules/contrib/chosen/modules/chosen_field/tests/src/Functional/ChosenFieldWidgetsTest.php
-----------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------
40 | ERROR | Class property $card_1 should use lowerCamel naming without underscores
47 | ERROR | Class property $card_2 should use lowerCamel naming without underscores
-----------------------------------------------------------------------------------------------------------------

FILE: /home/laptopuser/Documents/Test2/Dev-11-3513892/web/modules/contrib/chosen/chosen.module
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------------------------------
19 | WARNING | Global constants should not be used, move it to a class or interface
20 | WARNING | Global constants should not be used, move it to a class or interface
21 | WARNING | Global constants should not be used, move it to a class or interface
22 | WARNING | Global constants should not be used, move it to a class or interface
----------------------------------------------------------------------------------------------

So I fixed these errors locally and retested, no phpcs issues.

To fix these errors I created a new simple class for the constants called ChosenConstants.php and moved the constants in there. Also renamed the $card_1 and $card_2 variables.

It looked like The source branch (3513892-fix-issues-reported) was 4 commits behind the target branch (5.0.x). So I did a git rebase 5.0.x on my local branch to bring those commits in.

I then retested and also ran the phpunit tests. The phpunit test ChosenFieldWidgetsTest.php was failing due to me changing the $card_1 and $card_2 variables. I fixed this but it is also failing due to other things, like when it gets to these lines ..

$this->card1->setSetting('allowed_values', []);
$this->card1->setSetting('allowed_values_function', 'options_test_allowed_values_callback');

What is the etiquette with this .. should I fix phpunit tests as well?

nagy.balint’s picture

Hi!

If you can fix phpunit in a separate issue that would be awesome!

I can commit it quickly and then we can return to this.

nagy.balint’s picture

Seems like phpcs is still failing.

mdranove’s picture

Status: Needs work » Needs review

yeah looks like there was an error that phpcs was not catching locally? Weird. Anyway, fixed it.

schillerm’s picture

Hi, I just retested and phpcs is now passing all tests. +1 for RTBC from me.

  • nagy.balint committed d4ea009c on 5.0.x authored by ggh
    [#3513892] feat: Fix issues reported by PHPCS
    
    By: ggh
    By:...
nagy.balint’s picture

Status: Needs review » Fixed

Thanks!

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

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

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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