Drupal Coding Standards Issues | phpcs

Created on 24 January 2023, about 2 years ago
Updated 15 July 2024, 9 months ago

Problem/Motivation

Getting Following errors/warnings

$ phpcs --standard=Drupal appointment_time_slots

FILE: ...pointment_time_slots\src\Plugin\Field\FieldFormatter\TimeSlotFormatter.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ...p\task\appointment_time_slots\src\Plugin\Field\FieldType\TimeSlotField.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ...ask\appointment_time_slots\src\Plugin\Field\FieldWidget\TimeSlotWidget.php
--------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found
    |       |     "\r\n"
 42 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 71 | ERROR | [x] Use null coalesce operator instead of ternary operator.
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 462ms; Memory: 8MB

Proposed resolution

Fix the errors and warnings.

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇮🇳India jay jangid Jaipur

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

Comments & Activities

  • Issue created by @jay jangid
  • @jay-jangid opened merge request.
  • 🇮🇳India jay jangid Jaipur

    Created MR , please review.

    Thank you.

  • Status changed to Needs work 9 months ago
  • 🇮🇳India riddhi.addweb

    I applied the patch but after applying the Patch, there are errors still displayed. Attaching the SS for the same.

    FILE: /var/www/html/web/Drupal_9.5/web/modules/contrib/appointment_time_slots/appointment_time_slots.module
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
     9 | WARNING | [x] Unused use statement
     9 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Utility\Html.
    -------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/Drupal_9.5/web/modules/contrib/appointment_time_slots/src/Plugin/Field/FieldWidget/TimeSlotWidget.php
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
    -----------------------------------------------------------------------------------------------------------------------------
       9 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Ajax\AjaxResponse.
      86 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
     101 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
    -----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/Drupal_9.5/web/modules/contrib/appointment_time_slots/src/Plugin/Field/FieldType/TimeSlotField.php
    -------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------
     8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\FieldStorageDefinitionInterface.
    -------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------------------
Production build 0.71.5 2024