Drupal Coding Standards Issues | phpcs

Created on 1 February 2023, almost 2 years ago
Updated 8 July 2024, 5 months ago

Problem/Motivation

Getting following error/warnings

FILE: C:\xampp\htdocs\abc\drupal\modules\public_preview\README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------
2 | WARNING | Line exceeds 80 characters; contains 105 characters
5 | WARNING | Line exceeds 80 characters; contains 105 characters
6 | WARNING | Line exceeds 80 characters; contains 91 characters
7 | WARNING | Line exceeds 80 characters; contains 83 characters
9 | WARNING | Line exceeds 80 characters; contains 100 characters
----------------------------------------------------------------------

FILE: ...upal\modules\public_preview\src\Controller\PreviewController.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
17 | WARNING | The class short comment should describe what the
| | class does and not simply repeat the class name
----------------------------------------------------------------------

FILE: ...\abc\drupal\modules\public_preview\src\Form\PreviewLinksForm.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
23 | WARNING | The class short comment should describe what the
| | class does and not simply repeat the class name
276 | WARNING | Exceptions should not be translated
----------------------------------------------------------------------

Steps to reproduce

Run following command

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

Proposed resolution

Above error/warnings need to be fixed.

🐛 Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

🇮🇳India Charchil Khandelwal

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

Merge Requests

Comments & Activities

  • Issue created by @Charchil Khandelwal
  • @charchil-khandelwal opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India Charchil Khandelwal

    Created MR for this issue.
    Please review.

  • 🇮🇳India riddhi.addweb

    I have applied the patch cleanly and Run the command but still, there are some errors.
    please check the ScreenShots for the same.

    FILE: /var/www/html/web/drupal10/web/modules/contrib/public_preview/src/Controller/PreviewController.php
    --------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------
    57 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    --------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------

    FILE: /var/www/html/web/drupal10/web/modules/contrib/public_preview/src/Model/Preview.php
    -------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------
    70 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    -------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------

  • Status changed to Needs work 5 months ago
  • Assigned to hetal.solanki
  • 🇮🇳India hetal.solanki

    I have checked coding standard. There are some errors. Below we have mentioned errors.

    FILE: /var/www/html/drupal-contribution-d10/web/modules/contrib/public_preview-3338166/README.md
    ------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
    ------------------------------------------------------------------------------------------------
    2 | WARNING | Line exceeds 80 characters; contains 105 characters
    5 | WARNING | Line exceeds 80 characters; contains 105 characters
    6 | WARNING | Line exceeds 80 characters; contains 91 characters
    7 | WARNING | Line exceeds 80 characters; contains 83 characters
    9 | WARNING | Line exceeds 80 characters; contains 100 characters
    ------------------------------------------------------------------------------------------------

    FILE: /var/www/html/drupal-contribution-d10/web/modules/contrib/public_preview-3338166/src/Controller/PreviewController.php
    ---------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
    ---------------------------------------------------------------------------------------------------------------------------------------
    17 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
    133 | WARNING | [x] '@todo: Add previewer service, and move this function there.' should match the format '@todo Fix problem X here.'
    153 | WARNING | [x] '@todo: Add previewer service, and move this function there.' should match the format '@todo Fix problem X here.'
    175 | WARNING | [x] '@todo: Add previewer service, and move this function there.' should match the format '@todo Fix problem X here.'
    ---------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------------

    FILE: /var/www/html/drupal-contribution-d10/web/modules/contrib/public_preview-3338166/src/Model/Preview.php
    ------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AFFECTING 4 LINES
    ------------------------------------------------------------------------------------------------------------
    6 | ERROR | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
    108 | ERROR | [x] Use null coalesce operator instead of ternary operator.
    109 | ERROR | [x] Use null coalesce operator instead of ternary operator.
    110 | ERROR | [x] Use null coalesce operator instead of ternary operator.
    ------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------

    FILE: /var/www/html/drupal-contribution-d10/web/modules/contrib/public_preview-3338166/src/Storage/PreviewStorage.php
    ---------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------------------------------
    9 | ERROR | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
    10 | ERROR | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
    ---------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------

    FILE: /var/www/html/drupal-contribution-d10/web/modules/contrib/public_preview-3338166/src/Form/PreviewLinksForm.php
    --------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 4 WARNINGS AFFECTING 5 LINES
    --------------------------------------------------------------------------------------------------------------------------------------------
    17 | ERROR | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
    24 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
    201 | WARNING | [x] '@todo: Maybe add this https://www.drupal.org/project/clipboardjs ' should match the format '@todo Fix problem X here.'
    236 | WARNING | [x] '@todo: The hash should be unique,' should match the format '@todo Fix problem X here.'
    277 | WARNING | [ ] Exceptions should not be translated
    --------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------------

  • Merge request !4Coding Standard issue fix → (Open) created by hetal.solanki
  • Issue was unassigned.
  • Status changed to Needs review 5 months ago
  • Status changed to RTBC 5 months ago
  • 🇮🇳India dev16.addweb

    Hi,

    I've tested the MR ! 4 and it applied successfully, no phpcs issues were found after applying MR. Also, I've attached screenshots for the same.

Production build 0.71.5 2024