Fix PHPCS Reported Issues

Created on 24 November 2023, about 1 year ago
Updated 29 November 2023, 12 months ago

Problem/Motivation

The following phpcs issues were reported on executing the command:
vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /path/to/module

Reported Issues:
FILE: address_phonenumber/src/Element/AddressPhoneNumber.php
----------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------
29 | WARNING | Unused variable $info.
----------------------------------------------------------------------------------------------------------------------

FILE: address_phonenumber/src/Plugin/Field/FieldWidget/AddressPhoneNumberDefaultWidget.php
--------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 1 WARNING AFFECTING 6 LINES
--------------------------------------------------------------------------------------------------------------------------
9 | ERROR | [x] When importing a class with "use", do not include a leading \
10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
| | libphonenumber\NumberParseException.
10 | ERROR | [x] When importing a class with "use", do not include a leading \
23 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
39 | ERROR | [x] Use null coalesce operator instead of ternary operator.
46 | ERROR | [x] Short array syntax must be used to define arrays
47 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------

FILE: address_phonenumber/src/Plugin/Field/FieldFormatter/AddressPhoneNumberDefaultFormatter.php
--------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------
19 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
--------------------------------------------------------------------------------------------------------------------------

FILE: address_phonenumber/src/Plugin/Field/FieldType/AddressPhoneNumberItem.php
--------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------
19 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
--------------------------------------------------------------------------------------------------------------------------

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

šŸ“Œ Task
Status

RTBC

Version

10.0

Component

Code

Created by

šŸ‡®šŸ‡³India keshav patel

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.

Sign in to follow issues

Comments & Activities

  • Issue created by @keshav patel
  • Status changed to Needs review about 1 year ago
  • šŸ‡®šŸ‡³India keshav patel

    The provided patch file "fix_coding_standards-3403971-2.patch" fixes the PHPCS reported issues, please review.

  • Status changed to RTBC 12 months ago
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I applied the patch #2 and I confirmed that it fixes the reported PHPCS issues, the only remaining issues flagged in my terminal is caused when the module is installed via composer.

    āžœ  address_phonenumber git:(master) āœ— curl https://www.drupal.org/files/issues/2023-11-24/fix_coding_standards-3403971-2_0.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3342  100  3342    0     0   6637      0 --:--:-- --:--:-- --:--:--  6751
    patching file 'src/Element/AddressPhoneNumber.php'
    patching file 'src/Plugin/Field/FieldFormatter/AddressPhoneNumberDefaultFormatter.php'
    patching file 'src/Plugin/Field/FieldType/AddressPhoneNumberItem.php'
    patching file 'src/Plugin/Field/FieldWidget/AddressPhoneNumberDefaultWidget.php'
    āžœ  address_phonenumber git:(master) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml address_phonenumber
    
    FILE: ...local/web/modules/contrib/address_phonenumber/address_phonenumber.info.yml
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 2 LINES
    --------------------------------------------------------------------------------
     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
     7 | WARNING | All dependencies must be prefixed with the project name, for
       |         | example "drupal:"
    --------------------------------------------------------------------------------
    
    Time: 213ms; Memory: 10MB
    
    āžœ  contrib git:(master) āœ— 
Production build 0.71.5 2024