Fix the issues reported by phpcs

Created on 10 July 2023, 12 months ago
Updated 3 January 2024, 6 months ago

Problem/Motivation

PHPCS reports as follows:

C:\xampp\htdocs\backendassignment\web\modules\contrib>phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig s3fs_cors

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\s3fs_cors\s3fs_cors.install
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 76 | ERROR | [ ] The array declaration extends to column 86 (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\s3fs_cors\s3fs_cors.module
--------------------------------------------------------------------------------------
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\s3fs_cors\s3fs_cors.post_update.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 40 | ERROR | [ ] The array declaration extends to column 94 (the limit is 80). The array content should be split up over multiple lines
 47 | ERROR | [ ] The array declaration extends to column 151 (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\s3fs_cors\src\Controller\AjaxController.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 165 | ERROR | [ ] The array declaration extends to column 90 (the limit is 80). The array content should be split up over multiple lines
 240 | ERROR | [ ] The array declaration extends to column 90 (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\s3fs_cors\src\Element\S3CorsFile.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\s3fs_cors\src\Element\S3fsCorsFile.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AFFECTING 8 LINES
-------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
  16 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Site\Settings.
 105 | ERROR | [ ] The array declaration extends to column 146 (the limit is 80). The array content should be split up over multiple lines
 124 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 125 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 128 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 339 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 389 | ERROR | [ ] The array declaration extends to column 131 (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\s3fs_cors\src\Form\S3fsCorsAdminForm.php
------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
   8 | ERROR | [x] Each PHP statement must be on a line by itself
   9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\StringTranslation\StringTranslationTrait.
  96 | ERROR | [ ] The array declaration extends to column 96 (the limit is 80). The array content should be split up over multiple lines
 119 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\s3fs_cors\src\Plugin\Field\FieldFormatter\S3fsCorsGenericFileFormatter.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\s3fs_cors\src\Plugin\Field\FieldType\S3CorsFileItem.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\s3fs_cors\src\Plugin\Field\FieldType\S3fsCorsFileItem.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\s3fs_cors\src\Plugin\Field\FieldWidget\S3fsCorsFileWidget.php
----------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\FieldItemListInterface.
----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\s3fs_cors\src\Plugin\Field\FieldWidget\S3fsCorsImageWidget.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
   8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\FieldItemListInterface.
 116 | ERROR | [ ] The array declaration extends to column 82 (the limit is 80). The array content should be split up over multiple lines
------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------

Time: 3.35 secs; Memory: 6MB

Steps to reproduce

Run the phpcs command on the module.

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

Comments & Activities

  • Issue created by @sidharth_soman
  • Issue was unassigned.
  • Status changed to Needs review 12 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sidharth_soman Bangalore

    All issues fixed except the array declarations exceeding 80 characters. I'm leaving those as it is for the purposes of readability.

  • Hii @sidharth_soman

    Applied your patch and ran successfully, found warning errors as you mentioned.

    I have Created a patch and solve all the warning errors.

    Please review.

  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines clarkssquared

    Hi Satish_kumar,

    I applied your patch and I confirmed that it fixed all the PHPCS issues, below is the output based in my terminal:

    โžœ  d9-local git:(master) โœ— cd web/modules/contrib/s3fs_cors 
    โžœ  s3fs_cors git:(8.x-1.0-rc5) curl https://www.drupal.org/files/issues/2023-09-25/coding-standard-fixed-issue-3373658-3.patch | git apply -v
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 10138  100 10138    0     0  17052      0 --:--:-- --:--:-- --:--:-- 17241
    Checking patch s3fs_cors.install...
    Checking patch s3fs_cors.post_update.php...
    Checking patch src/Controller/AjaxController.php...
    Checking patch src/Element/S3fsCorsFile.php...
    Checking patch src/Form/S3fsCorsAdminForm.php...
    Checking patch src/Plugin/Field/FieldWidget/S3fsCorsFileWidget.php...
    Checking patch src/Plugin/Field/FieldWidget/S3fsCorsImageWidget.php...
    Applied patch s3fs_cors.install cleanly.
    Applied patch s3fs_cors.post_update.php cleanly.
    Applied patch src/Controller/AjaxController.php cleanly.
    Applied patch src/Element/S3fsCorsFile.php cleanly.
    Applied patch src/Form/S3fsCorsAdminForm.php cleanly.
    Applied patch src/Plugin/Field/FieldWidget/S3fsCorsFileWidget.php cleanly.
    Applied patch src/Plugin/Field/FieldWidget/S3fsCorsImageWidget.php cleanly.
    โžœ  s3fs_cors git:(8.x-1.0-rc5) โœ— export PATH="$PATH:$HOME/.composer/vendor/squizlabs/php_codesniffer/bin"
    
    โžœ  s3fs_cors git:(8.x-1.0-rc5) โœ— ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml s3fs_cors 
    โžœ  contrib git:(master) โœ— 

    Retaining the status to needs review so that others can review your patch. RTBC +1 for me

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom schillerm

    Hi, I applied #3 patch to 1.x-dev version on a D10 site.

    All PHPCS errors are gone except on the PATCHES.txt file.. see below..

    #######################################

    ๐Ÿธ ~/Documents/Sites/D10 phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml web/modules/contrib/s3fs_cors

    FILE: /home/user/Documents/Sites/D10/web/modules/contrib/s3fs_cors/PATCHES.txt
    ------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    ------------------------------------------------------------------------------------
    1 | WARNING | [ ] Line exceeds 80 characters; contains 104 characters
    5 | ERROR | [x] Expected 1 newline at end of file; 3 found
    ------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------

    Time: 107ms; Memory: 10MB

    ###################################

    RTBC +1 from me!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Gautam_105@

    Gautam_105@ โ†’ made their first commit to this issueโ€™s fork.

  • @gautam_105 opened merge request.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Gautam_105@

    Hi sidharth_soman,
    i have fixed PHPCS reported issue and created MR for same . Please review and see attachment .

  • Status changed to RTBC 6 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines paraderojether

    Hi Gautam_105@,

    I reviewed MR!24 and applied it against S3 File System CORS Upload 8.x-1.x-dev with Drupal core version 10.1.7 and confirmed it fixes the issues reported by phpcs.

    I added screenshots for reference.
    Thank you.

Production build 0.69.0 2024