Fix the errors/warnings reported by PHP_CodeSniffer

Created on 15 January 2024, 5 months ago
Updated 2 April 2024, 3 months ago

Problem/Motivation

When running the module code against Drupal coding standards based on Drupal standard, the module shows errors

Steps to reproduce

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

Report:

FILE: /home/contribution/drupal/web/modules/contrib/email_validate/email_validate.module
------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------------------------------
 24 | WARNING | [ ] Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar()
    |         |     for xyz-bar.html.twig.", "* Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or "* Implements hook_foo_BAR_ID_bar() for block
    |         |     templates."
 26 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
 34 | ERROR   | [x] Expected 1 space after closing parenthesis; found 0
------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: /home/contribution/drupal/web/modules/contrib/email_validate/src/Form/EmailValidateForm.php
--------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
--------------------------------------------------------------------------------------------------
  95 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 101 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 117 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 118 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
--------------------------------------------------------------------------------------------------

šŸ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

šŸ‡®šŸ‡³India realsp

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @realsp
  • Assigned to realsp
  • Merge request !1Fixed phpcs issues in files ā†’ (Merged) created by realsp
  • Issue was unassigned.
  • Status changed to Needs review 5 months ago
  • šŸ‡®šŸ‡³India realsp

    I've fixed the phpcs issues, Please review the MR.
    Thank you.

  • Status changed to Needs work 5 months ago
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I applied your MR !1 and I noticed that there are still many PHPCS issues in the module

    āžœ  email_validate git:(master) āœ— curl https://git.drupalcode.org/project/email_validate/-/merge_requests/1.diff | pa
    tch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3873    0  3873    0     0   8017      0 --:--:-- --:--:-- --:--:--  8119
    patching file 'src/Form/EmailValidateForm.php'
    āžœ  email_validate git:(master) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml email_validate
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/email_validate/README.md
    -------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
    -------------------------------------------------------------------------------------------------
      1 | WARNING | Line exceeds 80 characters; contains 121 characters
      2 | WARNING | Line exceeds 80 characters; contains 110 characters
     19 | WARNING | Line exceeds 80 characters; contains 119 characters
     31 | WARNING | Line exceeds 80 characters; contains 84 characters
    -------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/email_validate/email_validate.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/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/email_validate/email_validate.module
    --------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
    --------------------------------------------------------------------------------------------------------------------
     24 | WARNING | [ ] Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for
        |         |     xyz_bar().",, "* Implements hook_foo_BAR_ID_bar() for xyz-bar.html.twig.", "* Implements
        |         |     hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or "* Implements hook_foo_BAR_ID_bar() for block
        |         |     templates."
     26 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
     34 | ERROR   | [x] Expected 1 space after closing parenthesis; found 0
    --------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------
    
    Time: 302ms; Memory: 10MB
    
  • Assigned to realsp
  • šŸ‡·šŸ‡ŗRussia _cosmos_ Izhevsk

    Thanks for your contribution, guys!
    When you fix these notices I will create the new release

  • Issue was unassigned.
  • Status changed to Needs review 5 months ago
  • šŸ‡®šŸ‡³India realsp

    Hi @clarkssquared, Thank you for sharing the remaining phpcs issues, The errors in .info file can be ignored as they are added automatically (These lines are not being added in the forked branch). Please review the MR, Thank you.

  • Status changed to Needs work 5 months ago
  • šŸ‡·šŸ‡ŗRussia zniki.ru

    I left feedback in the MR, set to NW.
    Please update IS - renew the phpcs report.
    Suggested command to run phpcs
    phpcs --standard=Drupal,DrupalPractice --extensions=php,inc,module,install,info,test,profile,theme

  • Assigned to realsp
  • Issue was unassigned.
  • Status changed to Needs review 5 months ago
  • šŸ‡®šŸ‡³India realsp

    Thanks @Nikolay Shapovalov, I've made changes in the MR as per your suggestions, Please review the updated MR.
    Thank you.

  • Status changed to Needs work 5 months ago
  • šŸ‡·šŸ‡ŗRussia zniki.ru

    Thanks, please update phpcs report in the IS, and check my feedback at the MR.

  • Status changed to Needs review 5 months ago
  • Status changed to RTBC 5 months ago
  • šŸ‡·šŸ‡ŗRussia zniki.ru

    Great job, thanks for your effort.

  • Status changed to Fixed 3 months ago
  • šŸ‡·šŸ‡ŗRussia _cosmos_ Izhevsk

    Well guys,
    Thanks a lot for your time, all fixes was applied in new 1.0.5 release of the module.
    Checking out the commits https://git.drupalcode.org/project/email_validate/-/commits/1.0.x?ref_ty...

  • Status changed to Fixed 3 months ago
  • šŸ‡·šŸ‡ŗRussia _cosmos_ Izhevsk
Production build 0.69.0 2024