Fix the errors/warnings reported by PHP_CodeSniffer

Created on 16 March 2024, 9 months ago

Problem/Motivation

Running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml shows the following errors/warnings which should be fixed.

FILE: web/modules/contrib/braintree_api/modules/braintree_api_test/src/Form/WebhookNotificationTestForm.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------
 10 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
------------------------------------------------------------------------------------------------------------------------------------------


FILE: web/modules/contrib/braintree_api/src/Controller/BraintreeApiWebhook.php
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 1 WARNING AFFECTING 4 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 16 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
 67 | ERROR   | The $_POST super global must not be accessed directly; inject the request.stack service and use $stack->getCurrentRequest()->request->get("bt_signature") instead
 67 | ERROR   | The $_POST super global must not be accessed directly; inject the request.stack service and use $stack->getCurrentRequest()->request->get("bt_payload") instead
 70 | ERROR   | The $_POST super global must not be accessed directly; inject the request.stack service and use $stack->getCurrentRequest()->request->get("bt_signature") instead
 70 | ERROR   | The $_POST super global must not be accessed directly; inject the request.stack service and use $stack->getCurrentRequest()->request->get("bt_payload") instead
 74 | ERROR   | The $_POST super global must not be accessed directly; inject the request.stack service and use $stack->getCurrentRequest()->request->get("bt_signature") instead
 74 | ERROR   | The $_POST super global must not be accessed directly; inject the request.stack service and use $stack->getCurrentRequest()->request->get("bt_payload") instead
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: web/modules/contrib/braintree_api/src/Form/BraintreeApiAdminForm.php
------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------
  18 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
 174 | WARNING | Only string literals should be passed to t() where possible
 179 | WARNING | Only string literals should be passed to t() where possible
------------------------------------------------------------------------------------------------------------------


FILE: web/modules/contrib/braintree_api/src/BraintreeApiService.php
-----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
 11 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
-----------------------------------------------------------------------------------------------------------------

Time: 92ms; Memory: 10MB

🐛 Bug report
Status

Needs work

Version

4.0

Component

Code

Created by

🇺🇦Ukraine andrii momotov

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

Merge Requests

Comments & Activities

  • Issue created by @andrii momotov
  • Issue was unassigned.
  • Status changed to Needs review 9 months ago
  • 🇺🇦Ukraine andrii momotov

    Fixed the errors/warnings reported by PHP_CodeSniffer.
    Please review. Thanks!

  • Status changed to Needs work 7 months ago
  • 🇮🇳India dev16.addweb

    Hi, I have tested MR and found below issue

    modules/custom/braintree_api/
    
    FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/braintree_api/src/Controller/BraintreeApiWebhook.php
    -------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------
     10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\braintree_api\BraintreeApiService.
    -------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/braintree_api/src/Form/BraintreeApiAdminForm.php
    ---------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------
     10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
    ---------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 144ms; Memory: 10MB
    
  • Status changed to Needs review 7 months ago
  • 🇮🇳India vinmayiswamy

    Hi @silvi.addweb, thanks for the MR.

    I've tested MR !4 on Drupal 10.2.x
    The MR is applied Cleanly...

    Test Result:
    The phpcs issues were fixed after the updated changes.

    RTBC+1

  • 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.

  • 🇨🇦Canada shaundychko

    Thank you all for your help.

Production build 0.71.5 2024