Drupal coding standard | phpcs

Created on 27 December 2022, almost 2 years ago
Updated 14 July 2024, 4 months ago

Problem/Motivation

Getting Following errors/warnings

$ phpcs --standard=Drupal files_upload

FILE: C:\Users\Admin\Desktop\task\files_upload\src\Form\FilesUploadForm.php
-----------------------------------------------------------------------------------------------
FOUND 27 ERRORS AFFECTING 15 LINES
-----------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
18 | ERROR | [x] Doc comment short description must end with a full stop
19 | ERROR | [x] There must be exactly one blank line before the tags in a doc comment
19 | ERROR | [ ] Description for the @return value is missing
26 | ERROR | [x] Doc comment short description must end with a full stop
27 | ERROR | [x] There must be exactly one blank line before the tags in a doc comment
27 | ERROR | [ ] Missing parameter comment
28 | ERROR | [ ] Missing parameter comment
28 | ERROR | [x] Data types in @param tags need to be fully namespaced
29 | ERROR | [x] Separate the @param and @return sections by a blank line.
29 | ERROR | [ ] Description for the @return value is missing
63 | ERROR | [x] Doc comment short description must end with a full stop
64 | ERROR | [x] There must be exactly one blank line before the tags in a doc comment
64 | ERROR | [ ] Missing parameter comment
65 | ERROR | [ ] Missing parameter comment
65 | ERROR | [x] Data types in @param tags need to be fully namespaced
66 | ERROR | [x] Separate the @param and @return sections by a blank line.
66 | ERROR | [ ] If there is no return value for a function, there must not be a @return tag.
66 | ERROR | [ ] Description for the @return value is missing
73 | ERROR | [x] Doc comment short description must end with a full stop
74 | ERROR | [x] There must be exactly one blank line before the tags in a doc comment
74 | ERROR | [ ] Missing parameter comment
75 | ERROR | [ ] Missing parameter comment
75 | ERROR | [x] Data types in @param tags need to be fully namespaced
76 | ERROR | [x] Separate the @param and @return sections by a blank line.
76 | ERROR | [ ] If there is no return value for a function, there must not be a @return tag.
76 | ERROR | [ ] Description for the @return value is missing
-----------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 15 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------

Time: 421ms; Memory: 8MB

Proposed resolution

Fix the errors and warnings.

📌 Task
Status

Fixed

Version

1.1

Component

Code

Created by

🇮🇳India noorulshameera

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

Comments & Activities

Not all content is available!

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

  • 🇮🇳India Jay Jangid

    Thanks @noorulshameera for creating patch.
    But after applied Patch ,it shows some erros.

    error: patch failed: files_upload.module:11
    error: files_upload.module: patch does not apply
    error: patch failed: src/Form/FilesUploadForm.php:14
    error: src/Form/FilesUploadForm.php: patch does not apply
    

    Moving it to Need work

  • First commit to issue fork.
  • 🇮🇳India Jay Jangid

    Create Updated Patch Please Review.

    Thank you.

  • Assigned to sourabhjain
  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India sourabhjain

    I will review this.

  • Issue was unassigned.
  • 🇮🇳India sourabhjain

    I have resolved the below mentioned PHPCS issue.

    sourabhjain@LPT-SOURABH files_upload % phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig .
    
    FILE: /Users/sourabhjain/www/drupal/modules/contrib/files_upload/README.md
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------
     14 | WARNING | Line exceeds 80 characters; contains 119 characters
    --------------------------------------------------------------------------
    
    
    FILE: /Users/sourabhjain/www/drupal/modules/contrib/files_upload/files_upload.module
    ------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------
     6 | ERROR | [x] There must be exactly one blank line after the file comment
    ------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------
    
    
    FILE: /Users/sourabhjain/www/drupal/modules/contrib/files_upload/src/Form/FilesUploadForm.php
    ------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 8 WARNINGS AFFECTING 8 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------
      47 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      52 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      93 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      95 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      96 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      97 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     108 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     119 | WARNING | Unused variable $file_name.
    ------------------------------------------------------------------------------------------------------------------------------------------

    Please review it.

  • Assigned to Charchil Khandelwal
  • 🇮🇳India Charchil Khandelwal

    Thanks @sourabhjain , patch #10 applied cleanly, all errors and warnings are fixed.
    Moving to RTBC.

  • Issue was unassigned.
  • Status changed to RTBC almost 2 years ago
  • Assigned to radheymkumar
  • Status changed to Fixed 4 months ago
  • 🇮🇳India radheymkumar Jaipur, Rajasthan, India
  • Status changed to Fixed 4 months ago
  • 🇮🇳India radheymkumar Jaipur, Rajasthan, India
Production build 0.71.5 2024