Fix the issues reported by phpcs

Created on 21 February 2024, 10 months ago
Updated 12 September 2024, 3 months ago

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,info,txt,md,yml,twig modules/contrib/breadcrumbs_field/

Result : -

FILE: /home/chandansha/docker/testd10/web/modules/custom/breadcrumbs_field/breadcrumbs_field.module
---------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------
 55 | ERROR | [x] Expected 1 newline at end of file; 3 found
---------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------


FILE: /home/chandansha/docker/testd10/web/modules/custom/breadcrumbs_field/README.md
------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------
 3 | WARNING | Line exceeds 80 characters; contains 126 characters
 4 | WARNING | Line exceeds 80 characters; contains 97 characters
------------------------------------------------------------------------------------


FILE: /home/chandansha/docker/testd10/web/modules/custom/breadcrumbs_field/src/Form/SettingsForm.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 16 ERRORS AND 1 WARNING AFFECTING 16 LINES
--------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] The PHP open tag must be followed by exactly one blank line
  5 | WARNING | [x] Unused use statement
  7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
 17 | ERROR   | [ ] Missing member variable doc comment
 19 | ERROR   | [x] Missing function doc comment
 20 | ERROR   | [x] Opening brace should be on the same line as the declaration
 25 | ERROR   | [x] Missing function doc comment
 26 | ERROR   | [x] Opening brace should be on the same line as the declaration
 27 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 29 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 31 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 47 | ERROR   | [ ] Missing short description in doc comment
 48 | ERROR   | [ ] Description for the @return value is missing
 48 | ERROR   | [x] Data types in @return tags need to be fully namespaced
 51 | ERROR   | [x] Opening brace should be on the same line as the declaration
 73 | ERROR   | [x] Expected 1 space after "=>"; 0 found
 83 | ERROR   | [x] Expected 1 space after "=>"; 0 found
--------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 14 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/chandansha/docker/testd10/web/modules/custom/breadcrumbs_field/src/Field/BreadcrumbsJsonLdItemList.php
------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------
  7 | WARNING | [x] Unused use statement
 11 | WARNING | [x] Unused use statement
 12 | WARNING | [x] Unused use statement
 12 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal.
 12 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------


FILE: /home/chandansha/docker/testd10/web/modules/custom/breadcrumbs_field/src/Plugin/Field/FieldType/BreadcrumbsJsonLdItem.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------------
  8 | WARNING | [x] Unused use statement
 26 | ERROR   | [x] Expected 1 newline at end of file; 2 found
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------


FILE: /home/chandansha/docker/testd10/web/modules/custom/breadcrumbs_field/config/install/breadcrumbs_field.settings.yml
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
 3 | ERROR | [x] Expected 1 newline at end of file; 5 found
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

Time: 100ms; Memory: 10MB

Steps to reproduce

Run PHPCS on breadcrumbs_field module.

Proposed resolution

Fixed the coding standards.

Remaining tasks

Submit the patch either MR .

šŸ“Œ Task
Status

Needs review

Component

Code

Created by

šŸ‡®šŸ‡³India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan

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

Merge Requests

Comments & Activities

  • Issue created by @prem suthar
  • šŸ‡®šŸ‡³India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan

    I have Fixed the all PHPCS error's And Warning Please review it.

  • Status changed to Needs review 10 months ago
  • šŸ‡®šŸ‡³India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan
  • šŸ‡®šŸ‡³India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan
  • First commit to issue fork.
  • Merge request !1Resolve #3422855 "Phpcs" ā†’ (Open) created by sakthi_dev
  • Status changed to Needs work 4 months ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @sakthi_dev,

    I applied MR!1, it was applied smoothly, and fixed most of the phpcs issues.

    I encounter only 1 issue after I run phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml.

    āžœ  breadcrumbs_field git:(1.x) curl https://git.drupalcode.org/project/breadcrumbs_field/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  7257    0  7257    0     0  15297      0 --:--:-- --:--:-- --:--:-- 15310
    patching file README.md
    patching file breadcrumbs_field.module
    patching file config/install/breadcrumbs_field.settings.yml
    patching file src/Field/BreadcrumbsJsonLdItemList.php
    patching file src/Form/SettingsForm.php
    patching file src/Plugin/Field/FieldType/BreadcrumbsJsonLdItem.php
    āžœ  breadcrumbs_field git:(1.x) āœ— ..
    āžœ  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml breadcrumbs_field
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/breadcrumbs_field/src/Form/SettingsForm.php
    ----------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------
     3 | ERROR | [x] Expected strict_types=1, found strict_types = 1.
    ----------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------
    
    Time: 154ms; Memory: 10MB
    
    āžœ  contrib

    Thank you.

  • Status changed to Needs review 3 months ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi,

    Please review MR!1. Thank you.

Production build 0.71.5 2024