Fix the issues reported by PHP_CodeSniffer

Created on 21 September 2024, 2 months ago
Updated 22 September 2024, 2 months ago

Problem/Motivation

FILE: liqpay\liqpay.info.yml
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
-------------------------------------------------------------------------------------------------------------

FILE: liqpay\README.md
--------------------------------------------------------------------------------------------------------------------------------
FOUND 15 ERRORS AFFECTING 7 LINES
--------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
4 | ERROR | [x] Missing function doc comment
4 | ERROR | [ ] Invalid function name, expected h_oo_k_liqpay_payment_params_alter but found HOOK_liqpay_payment_params_alter
4 | ERROR | [x] Expected 1 space before opening brace; found 0
5 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
5 | ERROR | [x] Whitespace found at end of line
11 | ERROR | [x] Expected 1 space after "<"; 0 found
11 | ERROR | [x] Expected 1 space before "?"; 0 found
11 | ERROR | [x] Expected 1 space after "?"; 0 found
12 | ERROR | [x] Missing function doc comment
12 | ERROR | [ ] Invalid function name, expected h_oo_k_liqpay_api_alter but found HOOK_liqpay_api_alter
12 | ERROR | [x] Expected 1 blank line before function; 0 found
12 | ERROR | [x] Expected 1 space before opening brace; found 0
14 | ERROR | [x] Expected 1 blank line after function; 0 found
15 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 13 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------

FILE: liqpay\src\Controller\LiqpayPages.php
-------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
-------------------------------------------------------------------------------------------------------------
8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Url.
57 | WARNING | [ ] Only string literals should be passed to t() where possible
102 | ERROR | [x] Use null coalesce operator instead of ternary operator.
204 | WARNING | [ ] Only string literals should be passed to t() where possible
-------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------

FILE: liqpay\src\Form\PaymentForm.php
---------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------
8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\liqpay\API\LiqPayApi.
---------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------

FILE: liqpay\src\LiqPay.php
-----------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------
124 | WARNING | Only string literals should be passed to t() where possible
-----------------------------------------------------------------------------

FILE: liqpay\src\Plugin\Basket\Payment\BasketLiqpay.php
------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------
7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\liqpay\Controller\LiqpayPages.
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------

Steps to reproduce

Run phpcs command to get the drupal coding standard issues.

Proposed resolution

Many of the issues can be fixed by running the phpcbf command. For the remaining ones, we will need to manually address and then commit these changes before pushing them.

📌 Task
Status

Needs work

Version

1.4

Component

Code

Created by

🇺🇸United States sunil jolapara 3265 Summitrun Drive, Independence, KY, 41051

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.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇺🇸United States sunil jolapara 3265 Summitrun Drive, Independence, KY, 41051
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇳India lavanyatalwar

    Working on the suggested changes.

  • 🇮🇳India lavanyatalwar

    Hey @sunil jolapara, @avpaderno,
    As I see there are multiple other phpcs errors in the file. Should I resolve them aswell?
    Also you suggested to remove the doc comments from readme.md file, but when I remove those comments, I encounter phpcs errors stating

    ----------------------------------------------------------------------
      3 | ERROR | Missing short description in doc comment
     16 | ERROR | Doc comment is empty
    ----------------------------------------------------------------------
    

    Kindly suggest.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    In a README file, documentation comments are not mandatory. Those errors/warnings are not even shown by GitLab CI.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇳India lavanyatalwar

    Okay I'll work upon it.
    Also @avpaderno what should I keep the default title in line 124 Liqpay.php and line 57 of LiqpayPages.php (if the string in argument is empty).
    Should I keep the title as 'default title' only ?

  • 🇮🇳India lavanyatalwar

    Heyy @avpaderno,
    I have fixed the comments you dropped on the MR but now I am not clear about the following warnings of phpcs

    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     124 | WARNING | Only string literals should be passed to t() where possible
         |         | (Drupal.Semantics.FunctionT.NotLiteralString)
    --------------------------------------------------------------------------------
    FILE: ...y-3475949/web/modules/custom/liqpay-3475949/src/Controller/LiqpayPages.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     57 | WARNING | Only string literals should be passed to t() where possible
        |         | (Drupal.Semantics.FunctionT.NotLiteralString)
    --------------------------------------------------------------------------------
    

    If you could guide me , I would be highly obiliged since I am quite new to drupal community.

  • 🇮🇳India lavanyatalwar

    Heyy @avpaderno, @sunil jolapara,
    I have fixed the phpcs issues that were asked to be resolved and the phpcs pipeline has passed.
    Kindly check and merge :)

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇳India lavanyatalwar

    @avpaderno
    Worked upon the suggested changes.
    Kindly check

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
Production build 0.71.5 2024