Suggestions on code formatting and add grumphp

Created on 24 June 2021, over 3 years ago
Updated 5 February 2024, 10 months ago

I propose to:
1. Add grumphp (to make it easier to run PHPCS locally)
2. Run PHPCS in the Drupal CI.
See https://www.drupal.org/drupalorg/docs/drupal-ci/using-coderphpcs-in-drup...
I believe the phpcs.xml I added is compatible with the Drupal CI
3. Remove old/deprecated PHPCS annotations
See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignorin...

Note: Before PHP_CodeSniffer version 3.2.0, use // @codingStandardsIgnoreFile instead of // phpcs:ignoreFile. The @codingStandards syntax is deprecated and will be removed in PHP_CodeSniffer version 4.0.

Drupal 8 uses PHPCS 3.6.0 so we should use phpcs:ignore, phpcs:disable and phpcs:enable
4. Remove un-necessary newlines in the code (this is of course debatable but I tried to be reasonable)
5. Improve and/or fix any remaining PHPCS / code formatting issues.

📌 Task
Status

Needs work

Version

1.0

Component

Code

Created by

🇧🇪Belgium herved

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Merge request !1Resolve #3220633 "Suggestions on code" → (Open) created by herved
  • 🇮🇳India saranyamariappan

    Hi,

    I Will be working on it.

  • Issue was unassigned.
  • 🇮🇳India saranyamariappan

    MR has been created after fixing PHPCS errors. Please review.

  • Status changed to Needs work 10 months ago
  • Hi, I reviewed the MR and found many phpcs issues while running the command
    phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml tmgmt_cdt/
    So, changing the status to Needs work

  • Create a patch to fix the phpcs errors.
    These errors are remaining:

    $ phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml tmgmt_cdt/
    
    FILE: C:\Users\Nisha\tmgmt_cdt\src\TmgmtCdtApi.php
    -----------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------
     1415 | ERROR | [x] Closing brace indented incorrectly; expected 4 spaces, found 2
    -----------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------
    
    
    FILE: C:\Users\Nisha\tmgmt_cdt\src\TmgmtCdtFormatHelper.php
    -------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    -------------------------------------------------------------------------------
     134 | WARNING | Code after the THROW statement on line 133 cannot be executed
     140 | WARNING | Code after the THROW statement on line 139 cannot be executed
    -------------------------------------------------------------------------------
    
    

    Thankyou.

  • First commit to issue fork.
Production build 0.71.5 2024