Fixing the errors/warnings reported by PHP_CodeSniffer

Created on 4 July 2023, over 1 year ago

Problem/Motivation

Phpcs gives the following errors upon being run on the module:

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\webform_remote_handlers\src\Plugin\WebformHandler\RestWebformHandler.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AND 3 WARNINGS AFFECTING 12 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 221 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
 266 | WARNING | [ ] Potential security problem: SSL peer verification must not be disabled
 298 | ERROR   | [x] Expected 1 space after closing parenthesis; found 0
 301 | ERROR   | [x] Whitespace found at end of line
 301 | ERROR   | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
 364 | ERROR   | [ ] Doc comment is empty
 379 | ERROR   | [ ] Doc comment is empty
 383 | ERROR   | [x] Whitespace found at end of line
 425 | ERROR   | [ ] The array declaration extends to column 94 (the limit is 80). The array content should be split up over multiple lines
 467 | WARNING | [ ] Potential security problem: SSL peer verification must not be disabled
 482 | WARNING | [ ] Exceptions should not be translated
 523 | ERROR   | [ ] The array declaration extends to column 147 (the limit is 80). The array content should be split up over multiple lines
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\webform_remote_handlers\src\Plugin\WebformHandler\SoapWebformHandler.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 234 | ERROR | [ ] The array declaration extends to column 147 (the limit is 80). The array content should be split up over multiple lines
-------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\webform_remote_handlers\tests\src\Functional\WebformRemoteHandlerTest.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\webform_remote_handlers\webform_remote_handlers.module
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 59 | ERROR | [ ] All functions defined in a module file must be prefixed with the module's name, found "_webform_token_get_submission_value_files" but expected
    |       |     "webform_remote_handlers__webform_token_get_submission_value_files"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 2.26 secs; Memory: 8MB

Steps to reproduce

Run the phpcs command on the module.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

šŸ“Œ Task
Status

Needs work

Version

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

    I've fixed all but one issue: 'Potential security problem: SSL peer verification must not be disabled'. I'm leaving this as it is for now since I assume this is a requirement of the module.

    Please review the MR above.

  • Status changed to Needs work 6 months ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @sidharth_soman,

    I applied MR!6, it was not applied smoothly but fixed some of the phpcs issues.

    These are the remaining issues after I ran phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml:

    āžœ  webform_remote_handlers git:(3.x) curl https://git.drupalcode.org/project/webform_remote_handlers/-/merge_requests/6.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 40679    0 40679    0     0  65258      0 --:--:-- --:--:-- --:--:-- 65400
    patching file src/Plugin/WebformHandler/RestWebformHandler.php
    Hunk #1 FAILED at 1.
    1 out of 1 hunk FAILED -- saving rejects to file src/Plugin/WebformHandler/RestWebformHandler.php.rej
    patching file src/Plugin/WebformHandler/SoapWebformHandler.php
    Hunk #1 succeeded at 233 (offset 2 lines).
    patching file webform_remote_handlers.module
    Hunk #1 succeeded at 143 with fuzz 2.
    āžœ  webform_remote_handlers git:(3.x) āœ— ..
    āžœ  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig webform_remote_handlers
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/webform_remote_handlers/tests/src/Functional/WebformRemoteHandlerTest.php
    ------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Tests\webform\Functional\WebformBrowserTestBase.
    ------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/webform_remote_handlers/webform_remote_handlers.module
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     59 | ERROR | All functions defined in a module file must be prefixed with the module's name, found "_webform_token_get_submission_value_files" but expected
        |       | "webform_remote_handlers__webform_token_get_submission_value_files"
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/webform_remote_handlers/src/Plugin/WebformHandler/RestWebformHandler.php
    ----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 6 ERRORS AND 3 WARNINGS AFFECTING 9 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------------
       1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
     230 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
     296 | WARNING | [ ] Potential security problem: SSL peer verification must not be disabled
     323 | ERROR   | [x] Whitespace found at end of line
     330 | ERROR   | [x] list(...) is forbidden, use [...] instead.
     379 | ERROR   | [x] Expected newline after closing brace
     471 | WARNING | [ ] Potential security problem: SSL peer verification must not be disabled
     486 | WARNING | [ ] Exceptions should not be translated
     530 | ERROR   | [ ] The array declaration extends to column 147 (the limit is 120). The array content should be split up over multiple lines
    ----------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/webform_remote_handlers/src/Plugin/WebformHandler/SoapWebformHandler.php
    ---------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------------
     6 | 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/interns/Demo-site/drupal-org-issues/web/modules/contrib/webform_remote_handlers/src/Event/RestRemoteHandlerMessageEvent.php
    ----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 9 ERRORS AFFECTING 8 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------
      8 | ERROR | [x] Missing class doc comment
     24 | ERROR | [ ] Class property $webform_submission should use lowerCamel naming without underscores
     29 | ERROR | [ ] Missing parameter comment
     30 | ERROR | [ ] Missing parameter comment
     40 | ERROR | [ ] Missing parameter comment
     41 | ERROR | [x] Separate the @param and @return sections by a blank line.
     41 | ERROR | [ ] Description for the @return value is missing
     50 | ERROR | [ ] Description for the @return value is missing
     59 | ERROR | [ ] Description for the @return value is missing
    ----------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 341ms; Memory: 14MB
    
    āžœ  contrib

    Moreover, MR!6 is 20 commits behind the target branch.

    Thank you.

  • šŸ‡µšŸ‡¹Portugal joaomarques736

    Hello all,

    It is already fixed in the new release 3.0.6.

    Thanks!

Production build 0.71.5 2024