Problem/Motivation

There is a files need to fixed with coding standards.
Here is the command : -
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,yml web/modules/contrib/config_pages/

Result :-

FILE: ...rojects/d9/d9-local/web/modules/contrib/config_pages/config_pages.info.yml
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | WARNING | Remove "project" from the info file, it will be added by
   |         | drupal.org packaging automatically
 1 | WARNING | Remove "datestamp" from the info file, it will be added by
   |         | drupal.org packaging automatically
 1 | WARNING | Remove "version" from the info file, it will be added by
   |         | drupal.org packaging automatically
--------------------------------------------------------------------------------


FILE: ...dules/contrib/config_pages/src/Plugin/Condition/ConfigPagesValueAccess.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
--------------------------------------------------------------------------------
 217 | WARNING | Unused variable $cp_type.
 217 | WARNING | Unused variable $data_type.
--------------------------------------------------------------------------------


FILE: .../web/modules/contrib/config_pages/src/Controller/ConfigPagesController.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
 169 | WARNING | \Drupal calls should be avoided in classes, use dependency
     |         | injection instead
--------------------------------------------------------------------------------


FILE: ...s/d9/d9-local/web/modules/contrib/config_pages/src/ConfigPagesTypeForm.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
 118 | WARNING | \Drupal calls should be avoided in classes, use dependency
     |         | injection instead
--------------------------------------------------------------------------------

Time: 858ms; Memory: 12MB

Steps to reproduce

Run PHPCS on Config Pages module.

Proposed resolution

Fixed the coding standards.

Remaining tasks

Submit the patch either MR .

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

Chandansha created an issue. See original summary.

chandansha’s picture

Status: Active » Needs review

fixed all issue. But still there are some issues left.
Please have a look.

FILE: /home/chandansha/docker/testd10/web/modules/issue/config_pages-3424331/src/ConfigPagesTypeForm.php
--------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------
 118 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
--------------------------------------------------------------------------------------------------------


FILE: /home/chandansha/docker/testd10/web/modules/issue/config_pages-3424331/src/Controller/ConfigPagesController.php
---------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------
 169 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------------------------------

Time: 547ms; Memory: 12MB
clarkssquared’s picture

Status: Needs review » Needs work

Hi

I applied MR !36 and I confirmed that it fixes most of the PHPCS issues stated above, but since there are few remaining PHPCS issues I will move this ticket to needs work so that all PHPCS issues will be resolved.

➜  config_pages git:(master) ✗ curl https://git.drupalcode.org/project/config_pages/-/merge_requests/36.diff | patch -p1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 25607    0 25607    0     0  46401      0 --:--:-- --:--:-- --:--:-- 47071
patching file config_pages.module
patching file 'src/Command/GetValueCommand.php'
patching file 'src/Command/SetValueCommand.php'
patching file 'src/ConfigPagesAccessControlHandler.php'
patching file 'src/ConfigPagesContextBase.php'
patching file 'src/ConfigPagesContextManager.php'
patching file 'src/ConfigPagesForm.php'
patching file 'src/ConfigPagesListBuilder.php'
patching file 'src/ConfigPagesPermissions.php'
patching file 'src/ConfigPagesTypeForm.php'
patching file 'src/ConfigPagesTypeListBuilder.php'
patching file 'src/Controller/ConfigPagesController.php'
patching file 'src/Entity/ConfigPages.php'
patching file 'src/Entity/ConfigPagesType.php'
patching file 'src/Form/ConfigPagesClearConfirmationForm.php'
patching file 'src/Plugin/Block/ConfigPagesBlock.php'
patching file 'src/Plugin/Condition/ConfigPagesValueAccess.php'
1 out of 3 hunks failed--saving rejects to 'src/Plugin/Condition/ConfigPagesValueAccess.php.rej'
patching file 'tests/src/Functional/ClearConfigPageTest.php'
patching file 'tests/src/Functional/DeleteConfigPageTypeTest.php'
➜  config_pages git:(master) ✗ ..
➜  contrib git:(master) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml config_pages 

FILE: ...rojects/d9/d9-local/web/modules/contrib/config_pages/config_pages.info.yml
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | WARNING | Remove "project" from the info file, it will be added by
   |         | drupal.org packaging automatically
 1 | WARNING | Remove "datestamp" from the info file, it will be added by
   |         | drupal.org packaging automatically
 1 | WARNING | Remove "version" from the info file, it will be added by
   |         | drupal.org packaging automatically
--------------------------------------------------------------------------------


FILE: ...dules/contrib/config_pages/src/Plugin/Condition/ConfigPagesValueAccess.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
--------------------------------------------------------------------------------
 217 | WARNING | Unused variable $cp_type.
 217 | WARNING | Unused variable $data_type.
--------------------------------------------------------------------------------


FILE: .../web/modules/contrib/config_pages/src/Controller/ConfigPagesController.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
 169 | WARNING | \Drupal calls should be avoided in classes, use dependency
     |         | injection instead
--------------------------------------------------------------------------------


FILE: ...s/d9/d9-local/web/modules/contrib/config_pages/src/ConfigPagesTypeForm.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
 118 | WARNING | \Drupal calls should be avoided in classes, use dependency
     |         | injection instead
--------------------------------------------------------------------------------

Time: 858ms; Memory: 12MB

➜  contrib git:(master) ✗ 
zkhan.aamir’s picture

Issue summary: View changes

Issue summary updated.

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

sakthi_dev’s picture

Status: Needs work » Needs review
StatusFileSize
new28.39 KB

Fixed the remaining issues. Please review.

yashaswi18’s picture

Hello, I checked out to the branch '3424331-fix-the-issues' and ran the command phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,yml.

Found no errors or warnings remaining.

paraderojether’s picture

Status: Needs review » Needs work

Hi sakthi_dev,

I reviewed MR!36, and the MR is not applied cleanly I tried git apply -v and patch -p1 but I'm getting the error shown below:

jetherparadero@PrometSources-MacBook-Pro config_pages % curl https://git.drupalcode.org/project/config_pages/-/merge_requests/36.diff | patch -p1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 29496    0 29496    0     0  39377      0 --:--:-- --:--:-- --:--:-- 39698
patching file config_pages.module
patching file 'src/Command/GetValueCommand.php'
patching file 'src/Command/SetValueCommand.php'
patching file 'src/ConfigPagesAccessControlHandler.php'
patching file 'src/ConfigPagesContextBase.php'
patching file 'src/ConfigPagesContextManager.php'
patching file 'src/ConfigPagesForm.php'
patching file 'src/ConfigPagesListBuilder.php'
patching file 'src/ConfigPagesPermissions.php'
patching file 'src/ConfigPagesTypeForm.php'
patching file 'src/ConfigPagesTypeListBuilder.php'
patching file 'src/Controller/ConfigPagesController.php'
patching file 'src/Entity/ConfigPages.php'
patching file 'src/Entity/ConfigPagesType.php'
patching file 'src/Form/ConfigPagesClearConfirmationForm.php'
patching file 'src/Plugin/Block/ConfigPagesBlock.php'
patching file 'src/Plugin/Condition/ConfigPagesValueAccess.php'
1 out of 3 hunks failed--saving rejects to 'src/Plugin/Condition/ConfigPagesValueAccess.php.rej'
patching file 'tests/src/Functional/ClearConfigPageTest.php'
patching file 'tests/src/Functional/DeleteConfigPageTypeTest.php'
jetherparadero@PrometSources-MacBook-Pro config_pages % cd ..
jetherparadero@PrometSources-MacBook-Pro contrib % phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml config_pages


FILE: /Users/jetherparadero/Distributions/drupalorgissues/web/modules/contrib/config_pages/src/Plugin/Condition/ConfigPagesValueAccess.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------
 217 | WARNING | Unused variable $cp_type.
 217 | WARNING | Unused variable $data_type.
------------------------------------------------------------------------------------------------------------------------------------------

Time: 952ms; Memory: 12MB

Kindly check and advise, please.
Thank you.

sakthi_dev’s picture

I couldn't find the variables in the file. Could you please reverify it once please?

chandansha’s picture

Status: Needs work » Needs review
StatusFileSize
new27.85 KB

I checked module i could not find any phpcs issue.
below share image kindly check.
@all Thanks for Review.

clarkssquared’s picture

Status: Needs review » Needs work

Hi

I apply the updated MR !36 into the module and it applied successfully, but when I try to execute the PHPCS command, I can also see the same phpcs issue that comment #9

➜  config_pages git:(master) ✗ curl https://git.drupalcode.org/project/config_pages/-/merge_requests/36.diff | patch -p1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 29496    0 29496    0     0  28574      0 --:--:--  0:00:01 --:--:-- 28917
patching file config_pages.module
patching file 'src/Command/GetValueCommand.php'
patching file 'src/Command/SetValueCommand.php'
patching file 'src/ConfigPagesAccessControlHandler.php'
patching file 'src/ConfigPagesContextBase.php'
patching file 'src/ConfigPagesContextManager.php'
patching file 'src/ConfigPagesForm.php'
patching file 'src/ConfigPagesListBuilder.php'
patching file 'src/ConfigPagesPermissions.php'
patching file 'src/ConfigPagesTypeForm.php'
patching file 'src/ConfigPagesTypeListBuilder.php'
patching file 'src/Controller/ConfigPagesController.php'
patching file 'src/Entity/ConfigPages.php'
patching file 'src/Entity/ConfigPagesType.php'
patching file 'src/Form/ConfigPagesClearConfirmationForm.php'
patching file 'src/Plugin/Block/ConfigPagesBlock.php'
patching file 'src/Plugin/Condition/ConfigPagesValueAccess.php'
1 out of 3 hunks failed--saving rejects to 'src/Plugin/Condition/ConfigPagesValueAccess.php.rej'
patching file 'tests/src/Functional/ClearConfigPageTest.php'
patching file 'tests/src/Functional/DeleteConfigPageTypeTest.php'
➜  config_pages git:(master) ✗ ..
➜  contrib git:(master) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml
ERROR: You must supply at least one file or directory to process.

Run "phpcs --help" for usage information

➜  contrib git:(master) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml config_pages 

FILE: ...rojects/d9/d9-local/web/modules/contrib/config_pages/config_pages.info.yml
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | WARNING | Remove "project" from the info file, it will be added by
   |         | drupal.org packaging automatically
 1 | WARNING | Remove "datestamp" from the info file, it will be added by
   |         | drupal.org packaging automatically
 1 | WARNING | Remove "version" from the info file, it will be added by
   |         | drupal.org packaging automatically
--------------------------------------------------------------------------------


FILE: ...dules/contrib/config_pages/src/Plugin/Condition/ConfigPagesValueAccess.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
--------------------------------------------------------------------------------
 217 | WARNING | Unused variable $cp_type.
 217 | WARNING | Unused variable $data_type.
--------------------------------------------------------------------------------

Time: 872ms; Memory: 12MB

➜  contrib git:(master) ✗ 

Mohd Sahzad made their first commit to this issue’s fork.

Mohd Sahzad changed the visibility of the branch 3424331-fix-phpcs to hidden.

silvi.addweb made their first commit to this issue’s fork.

silvi.addweb’s picture

Status: Needs work » Needs review

Hi, I have fixed below remaining phpcs issue. Please review.

modules/custom/config_pages

FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/config_pages/src/ConfigPagesForm.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 9 ERRORS AFFECTING 9 LINES
---------------------------------------------------------------------------------------------------------------------------
 91 | ERROR | [x] The first parameter of a multi-line function declaration must be on the line after the opening bracket
 92 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 93 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 94 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 95 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 96 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 97 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 98 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 99 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
---------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------

FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/config_pages/src/Controller/ConfigPagesController.php
--------------------------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 5 LINES
--------------------------------------------------------------------------------------------------------------------------------------------
 83 | ERROR | [x] The first parameter of a multi-line function declaration must be on the line after the opening bracket
 84 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 85 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 86 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 87 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 87 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
--------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------

FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/config_pages/src/Plugin/Block/ConfigPagesBlock.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
 47 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
-----------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/config_pages/src/ConfigPagesTypeForm.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 4 LINES
-------------------------------------------------------------------------------------------------------------------------------
 65 | ERROR | [x] The first parameter of a multi-line function declaration must be on the line after the opening bracket
 66 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 67 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 68 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 68 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------

FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/config_pages/src/ConfigPagesListBuilder.php
----------------------------------------------------------------------------------------------------------------------------------
FOUND 9 ERRORS AFFECTING 7 LINES
----------------------------------------------------------------------------------------------------------------------------------
 46 | ERROR | [x] The first parameter of a multi-line function declaration must be on the line after the opening bracket
 47 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 40
 47 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
 61 | ERROR | [x] The first parameter of a multi-line function declaration must be on the line after the opening bracket
 62 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 63 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 64 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 65 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 65 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------

FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/config_pages/src/ConfigPagesTypeListBuilder.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------------------------------------------------------------
 39 | ERROR | [x] The first parameter of a multi-line function declaration must be on the line after the opening bracket
 40 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 41 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
 41 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
--------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------

Time: 667ms; Memory: 12MB
akashpj’s picture

Status: Needs review » Needs work

Hi, I’ve reviwed MR 36 on Drupal 10.2.x.
The MR applied cleanly.

Few phpcs issues fixed but I still can see the below issues

./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/config_pages

FILE: /Users/apj/projects/doc102/drupal/modules/contrib/config_pages/config_pages.info.yml
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
 1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
 1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
 1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
-------------------------------------------------------------------------------------------------------------


FILE: /Users/apj/projects/doc102/drupal/modules/contrib/config_pages/src/Plugin/Condition/ConfigPagesValueAccess.php
----------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------
 217 | WARNING | Unused variable $cp_type.
 217 | WARNING | Unused variable $data_type.
----------------------------------------------------------------------------------------------------------------------------------

Changing the status back to "Needs work".

Thanks

silvi.addweb’s picture

Status: Needs work » Needs review

Hi,
After applying the MR, I have not found any issues in the ConfigPagesValueAccess.php file.

Here is the command I used to run PHP CodeSniffer:

addweb@addweb-HP-ZBook-15-G2:~$ .config/composer/vendor/squizlabs/php_codesniffer/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml,css,js Drupal8-vagrant/web/web/contribution/lando-d10/web/modules/custom/config_pages/
addweb@addweb-HP-ZBook-15-G2:~$ 

To avoid issues with the info file, please download the module through:
git clone repo-url

Move to "Need review" so other users can review as well.

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

enchufe’s picture

Updated PR branch from origin/8.x-2.x

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

deimos’s picture

I added a basic .gitlab-ci.yml for automatic phpcs checking what might help for task review. Additionally it checks other code styles (for css, js) and run tests.

shumer’s picture

Status: Needs review » Fixed

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.

Status: Fixed » Closed (fixed)

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