Fix the errors/warnings reported by Php_CodeSniffer

Created on 5 July 2023, over 1 year ago
Updated 1 February 2024, 11 months ago

Problem/Motivation

PHPCS reports the following errors:

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig phpmail_alter
FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\phpmail_alter\src\Service\DebugService.php
------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 95 | WARNING | [ ] The use of function dsm() is discouraged
------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\phpmail_alter\src\Service\DebugServiceInterface.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: C:\xampp\htdocs\backendassignment\web\modules\contrib\phpmail_alter\src\Service\PhpMail.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 148 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 149 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 253 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

šŸ“Œ Task
Status

RTBC

Version

1.0

Component

Code

Created by

šŸ‡®šŸ‡³India sidharth_soman Bangalore

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 @sidharth_soman
  • Merge request !1Fixed the phpcs issues. ā†’ (Open) created by sidharth_soman
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India sidharth_soman Bangalore

    I have fixed all the issues except the use of dsm(). Leaving it as it is for debugging purposes.

    Please review the MR

  • Assigned to realsp
  • Status changed to Needs work 11 months ago
  • šŸ‡®šŸ‡³India realsp

    Found the following phpcs issues in MR #2,

    FILE: /home/contribution/drupal/web/modules/contrib/phpmail_alter/src/Service/PhpMail.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
     7 | 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
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/contribution/drupal/web/modules/contrib/phpmail_alter/src/Service/DebugService.php
    -----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------------------------
      7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Extension\ModuleHandlerInterface.
     95 | WARNING | [ ] The use of function dsm() is discouraged
    -----------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------
    
  • šŸ‡®šŸ‡³India realsp

    I'll update the MR to fix the remaining phpcs issues.

  • Issue was unassigned.
  • Status changed to Needs review 11 months ago
  • šŸ‡®šŸ‡³India realsp

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

  • Status changed to RTBC 11 months ago
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I applied the MR !1 after commit number 6 and I confirmed that it fixes all the PHPCS issues

    āžœ  phpmail_alter git:(8.x-1.20) curl https://git.drupalcode.org/project/phpmail_alter/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4408    0  4408    0     0   7762      0 --:--:-- --:--:-- --:--:--  7871
    patching file phpmail_alter.services.yml
    patching file 'src/Service/DebugService.php'
    patching file 'src/Service/PhpMail.php'
    āžœ  phpmail_alter git:(8.x-1.20) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml phpmail_alter 
    āžœ  contrib git:(master) āœ— 
    
Production build 0.71.5 2024