Problem/Motivation

Running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml shows the following errors/warnings which should be fixed.


FILE: web/modules/contrib/taxonomy_protect/taxonomy_protect.module
-------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------
 1 | ERROR | [x] Missing file doc comment
-------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------


FILE: web/modules/contrib/taxonomy_protect/taxonomy_protect.install
--------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------
  1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
 11 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------


FILE: web/modules/contrib/taxonomy_protect/src/Form/TaxonomyProtectAdminSettingsForm.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------------------------------
  3 | ERROR   | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
 14 | ERROR   | [x] Missing class doc comment
 30 | ERROR   | [x] Missing function doc comment
 31 | WARNING | [ ] Vocabulary::loadMultiple calls should be avoided in classes, use dependency injection instead
 44 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
-----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------

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

Andrii Momotov created an issue. See original summary.

andrii momotov’s picture

Assigned: Unassigned » andrii momotov

andrii momotov’s picture

Assigned: andrii momotov » Unassigned
Status: Needs work » Needs review

Fixed the errors/warnings reported by PHP_CodeSniffer.
Please review. Thanks!

clarkssquared’s picture

Status: Needs review » Needs work

Hi

I applied MR !3 but there are still many PHPCS issues that needs to be resolved.

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

FILE: ...s/d9/d9-local/web/modules/contrib/taxonomy_protect/taxonomy_protect.module
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] Missing file doc comment
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ...d9/d9-local/web/modules/contrib/taxonomy_protect/taxonomy_protect.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: .../d9/d9-local/web/modules/contrib/taxonomy_protect/taxonomy_protect.install
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ...les/contrib/taxonomy_protect/src/Form/TaxonomyProtectAdminSettingsForm.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
 32 | WARNING | Vocabulary::loadMultiple calls should be avoided in classes,
    |         | use dependency injection instead
 45 | WARNING | \Drupal calls should be avoided in classes, use dependency
    |         | injection instead
--------------------------------------------------------------------------------

Time: 236ms; Memory: 10MB

➜  contrib git:(master) ✗ cd taxonomy_protect 
➜  taxonomy_protect git:(master) ✗ curl https://git.drupalcode.org/project/taxonomy_protect/-/merge_requests/3.diff | patch -p1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4166    0  4166    0     0   4991      0 --:--:-- --:--:-- --:--:--  5025
patching file 'src/Form/TaxonomyProtectAdminSettingsForm.php'
2 out of 3 hunks failed--saving rejects to 'src/Form/TaxonomyProtectAdminSettingsForm.php.rej'
patching file taxonomy_protect.install
patching file taxonomy_protect.module
➜  taxonomy_protect git:(master) ✗ ..
➜  contrib git:(master) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml taxonomy_protect

FILE: ...s/d9/d9-local/web/modules/contrib/taxonomy_protect/taxonomy_protect.module
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] Missing file doc comment
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ...d9/d9-local/web/modules/contrib/taxonomy_protect/taxonomy_protect.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: ...les/contrib/taxonomy_protect/src/Form/TaxonomyProtectAdminSettingsForm.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
 32 | WARNING | Vocabulary::loadMultiple calls should be avoided in classes,
    |         | use dependency injection instead
--------------------------------------------------------------------------------

Time: 95ms; Memory: 10MB

➜  contrib git:(master) ✗ 
andrii momotov’s picture

Hi @clarkssquared
You are doing something wrong. I've checked several times and it doesn't show any more warnings or errors.

For example, in your message, the first error says:

FILE: ...s/d9/d9-local/web/modules/contrib/taxonomy_protect/taxonomy_protect.module
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] Missing file doc comment
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Please look at my MR:
https://git.drupalcode.org/project/taxonomy_protect/-/merge_requests/3/d...

So you'll see, I added a doc comment to the taxonomy_protect.module file.
Thanks!

jasjeet kaur brar’s picture

Hiiee Andrii, These issues are already been taken care of in another ticket by me which was added by you for GitLab CI.
Can you please confirm from that ticket? And Thanks.

jasjeet kaur brar’s picture

Status: Needs work » Needs review
riddhi.addweb’s picture

StatusFileSize
new159.25 KB

I tried to apply the patch [MR3], but it failed when applied. Attaching a screenshot for the same.

riddhi.addweb’s picture

Status: Needs review » Needs work

  • jrb committed dd987891 on 2.1.x
    fix: #3426884 Fix the errors/warnings reported by PHP_CodeSniffer
    
    By:...
jrb’s picture

Status: Needs work » 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.