Drupal Coding Standards Issues | phpcs

Created on 30 January 2023, almost 2 years ago
Updated 15 July 2024, 5 months ago

Problem/Motivation

Getting Following errors/warning

$ phpcs --standard=Drupal existing_values_autocomplete_widget

FILE: ...sting_values_autocomplete_widget\src\Controller\AutocompleteController.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AND 3 WARNINGS AFFECTING 5 LINES
--------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found
    |         |     "\r\n"
  9 | WARNING | [x] Unused use statement
 13 | WARNING | [ ] The class short comment should describe what the class does
    |         |     and not simply repeat the class name
 21 | ERROR   | [x] Expected 1 blank line before function; 0 found
 27 | WARNING | [ ] Line exceeds 80 characters; contains 90 characters
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ...te_widget\src\Plugin\Field\FieldWidget\ExistingAutocompleteFieldWidget.php
--------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found
    |       |     "\r\n"
 83 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 88 | ERROR | [ ] The array declaration extends to column 202 (the limit is
    |       |     80). The array content should be split up over multiple lines
 88 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ...task\existing_values_autocomplete_widget\tests\src\Functional\LoadTest.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
--------------------------------------------------------------------------------

Time: 460ms; Memory: 8MB

Proposed resolution

Fix the errors and warnings.

🐛 Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

🇮🇳India jay jangid Jaipur

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

Merge Requests

Comments & Activities

  • Issue created by @jay jangid
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India jay jangid Jaipur

    Created MR , please review.

    Tahnk you.

  • 🇮🇳India himanshu_jhaloya Indore

    created the patch against MR!7 fix the phpcs issue

  • 🇮🇳India riddhi.addweb

    I have applied the 3337543-2 Patch cleanly but still, there is one error left.
    Please check the Screenshots for the reference.

    FILE: /var/www/html/web/drupal10/web/modules/contrib/existing_values_autocomplete_widget/src/Controller/AutocompleteController.php
    ------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------
    7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Symfony\Component\HttpFoundation\JsonResponse.
    73 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
    ------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------------

    Time: 129ms; Memory: 10MB

  • Status changed to Needs work 5 months ago
  • First commit to issue fork.
  • Status changed to Needs review 5 months ago
  • 🇮🇳India atul_ghate

    I have fixed all the PHPCS issues, but when I checked the functionality of this module for autocomplete suggestions, the suggestion feature was not working and showing an issue in the recent log messages. To confirm whether it is because of my changes, I also tested without any changes on D9 and D10, and still, it was not working, throwing below error.

    Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'f.entity_id' in 'field list': SELECT "f"."entity_id" AS "entity_id", "f"."title" AS "title" FROM "node_field_data" "f" WHERE "title" LIKE :db_condition_placeholder_0 ESCAPE '\\'; Array ( [:db_condition_placeholder_0] => h% ) in Drupal\existing_values_autocomplete_widget\Controller\AutocompleteController->handleAutocomplete() (line 39 of /app/web/modules/contrib/existing_values_autocomplete_widget/src/Controller/AutocompleteController.php).

  • Status changed to RTBC 5 months ago
  • 🇮🇳India riddhi.addweb

    The mentioned phpcs issue is resolved, & I have also checked and it is working as expected. I am attaching the Screenshots & doing RTBC for the same.

  • 🇮🇳India atul_ghate

    Hi @riddhi.addweb I have updated the comment that was irrelevant. Please review once again.

  • Status changed to Needs review 5 months ago
  • Status changed to RTBC 5 months ago
  • 🇮🇳India riddhi.addweb

    @atul_ghate I reviewed the patch and it is working as expected.

    The mentioned phpcs issue is resolved, & I have also checked and it is working as expected. I am attaching the Screenshots & doing RTBC for the same.

Production build 0.71.5 2024