Drupal Coding Standards Issues | phpcs

Created on 16 February 2023, over 1 year ago
Updated 19 August 2024, 3 months ago

Problem/Motivation

Getting following error/warnings.

FILE: /var/www/html/modules/contrib/permission_spreadsheet/tests/src/Functional/ExportFormTest.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
41 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/permission_spreadsheet/tests/src/Functional/FormTestBase.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
47 | ERROR | The array declaration extends to column 104 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/permission_spreadsheet/tests/src/Functional/ImportFormTest.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
78 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
80 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/permission_spreadsheet/src/RoleLoaderTrait.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------
23 | ERROR | [x] Expected "\Generator\Drupal\user\Entity\Role" but found "\Generator<\Drupal\user\Entity\Role>" for function return type
------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/permission_spreadsheet/src/Form/ImportForm.php
--------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
--------------------------------------------------------------------------------------------------------------------------------------------
105 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
142 | ERROR | [ ] The array declaration extends to column 94 (the limit is 80). The array content should be split up over multiple lines
144 | ERROR | [ ] The array declaration extends to column 92 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/permission_spreadsheet/src/PhpSpreadsheetHelperTrait.php
--------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------
23 | ERROR | Type hint "\PhpOffice\PhpSpreadsheet\Spreadsheet" missing for $spreadsheet
--------------------------------------------------------------------------------------------

Time: 7.9 secs; Memory: 6MB

Steps to reproduce

Run following command

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/permission_spreadsheet/

Proposed resolution

Above error/warnings need to be fixed.

📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇳India samit.310@gmail.com

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 @samit.310@gmail.com
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India samit.310@gmail.com

    Above error/warnings are fixed.

  • 🇮🇳India Ranjit1032002

    I had Reviewed the patch and it's working as expected mentioned in comment #2

  • Status changed to RTBC over 1 year ago
  • First commit to issue fork.
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Reviewed and Tested patch provided in #2.

    urvasi@urvasi-Inspiron-15-3552:/var/www/html/contribution/drupal/web/modules/contrib/permission_spreadsheet-3342226$ git apply -v 3342226-2.patch
    Checking patch src/Form/ImportForm.php...
    Checking patch src/PhpSpreadsheetHelperTrait.php...
    Checking patch src/RoleLoaderTrait.php...
    Checking patch tests/src/Functional/ExportFormTest.php...
    Checking patch tests/src/Functional/FormTestBase.php...
    Checking patch tests/src/Functional/ImportFormTest.php...
    Applied patch src/Form/ImportForm.php cleanly.
    Applied patch src/PhpSpreadsheetHelperTrait.php cleanly.
    Applied patch src/RoleLoaderTrait.php cleanly.
    Applied patch tests/src/Functional/ExportFormTest.php cleanly.
    Applied patch tests/src/Functional/FormTestBase.php cleanly.
    Applied patch tests/src/Functional/ImportFormTest.php cleanly.

    Applied smoothly, LGTM

    RTBC++

    Committing the changes to help the maintainers.

  • Status changed to Fixed 3 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024