Fix the errors/warnings reported by PHP_CodeSniffer

Created on 7 July 2023, 12 months ago
Updated 23 January 2024, 5 months ago

Problem/Motivation

When running the module code against Drupal coding standards based on Drupal standard, the module shows errors

Report:

FILE: /home/contribution/drupal/web/modules/contrib/synprices/src/Plugin/Action/UpdatePricesAction.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 4 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
   7 | WARNING | [x] Unused use statement
   7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Plugin\PluginFormInterface.
  25 | ERROR   | [x] Expected 1 blank line before function; 0 found
  58 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  63 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 107 | WARNING | [ ] Line exceeds 80 characters; contains 84 characters
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/synprices/src/Plugin/Action/RevertSaleAction.php
-----------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------------------------------
  7 | WARNING | [x] Unused use statement
  7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Plugin\PluginFormInterface.
 25 | ERROR   | [x] Expected 1 blank line before function; 0 found
 86 | WARNING | [ ] Line exceeds 80 characters; contains 84 characters
-----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/synprices/src/Controller/SynpricesController.php
-----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------
 16 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
-----------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/synprices/synprices.info.yml
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
 8 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
----------------------------------------------------------------------------------------------

Steps to reproduce

Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,inc,module,install,info,test,profile,theme, md,yml synprices/

📌 Task
Status

RTBC

Version

1.0

Component

Code

Created by

🇮🇳India urvashi_vora Madhya Pradesh, India

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 @urvashi_vora
  • Status changed to Needs work 5 months ago
  • 🇮🇳India Ashutosh Ahirwal India

    Provided patch get applied cleanly but still throwing some error which needs to fix.

    Used command with arguments:-
    ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml web/modules/custom/synprices

    Remaining issue:-
    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/synprices/synprices.info.yml
    -----------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------
    8 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
    -----------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/synprices/assets/gulpfile.js
    -----------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------
    13 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    -----------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/synprices/src/Plugin/Action/UpdatePricesAction.php
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------
    7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Form\FormStateInterface.
    -----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/synprices/src/Plugin/Action/RevertSaleAction.php
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------
    7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Form\FormStateInterface.
    -----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/synprices/src/Controller/SynpricesController.php
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
    16 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    -------------------------------------------------------------------------------------------------------------------------

    Time: 124ms; Memory: 10MB

  • First commit to issue fork.
  • Assigned to realsp
  • 🇮🇳India realsp

    I'll create MR to fix the phpcs issues

  • Merge request !1Resolve #3373218 "Phpcs errors" → (Open) created by realsp
  • Issue was unassigned.
  • Status changed to Needs review 5 months ago
  • 🇮🇳India realsp

    I've fixed the phpcs issues, Please review the MR.
    Thank you.

  • Status changed to Needs work 5 months ago
  • Assigned to realsp
  • Issue was unassigned.
  • 🇮🇳India realsp

    Thanks @Nikolay Shapovalov, I've updated as per your suggestions, Please review the updated MR.
    Thank you.

  • 🇷🇺Russia zniki.ru

    Thanks, I left comment.
    Looks like IS phpcs report is outdated, can you please renew it for current 8.x-1.x branch?

  • 🇮🇳India realsp

    I'll update it

  • Status changed to Needs review 5 months ago
  • Status changed to RTBC 5 months ago
  • 🇷🇺Russia zniki.ru

    Thanks, looks good.

Production build 0.69.0 2024