Fix the issues reported by phpcs

Created on 19 April 2023, over 1 year ago
Updated 18 August 2024, 4 months ago

Problem/Motivation

Getting following error/warnings.

FILE: /var/www/html/modules/contrib/textarea_limit/css/textarea_limit.css
---------------------------------------------------------------------------
FOUND 8 ERRORS AFFECTING 2 LINES
---------------------------------------------------------------------------
1 | ERROR | [x] Opening brace should be the last content on the line
1 | ERROR | [x] Expected 1 space after colon in style definition; 0 found
1 | ERROR | [x] Closing brace of class definition must be on new line
2 | ERROR | [x] Opening brace should be the last content on the line
2 | ERROR | [x] Expected 1 space after colon in style definition; 0 found
2 | ERROR | [x] Each style definition must be on a line by itself
2 | ERROR | [x] Expected 1 space after colon in style definition; 0 found
2 | ERROR | [x] Closing brace of class definition must be on new line
---------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/textarea_limit/README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------
3 | WARNING | Line exceeds 80 characters; contains 246 characters
7 | WARNING | Line exceeds 80 characters; contains 94 characters
11 | WARNING | Line exceeds 80 characters; contains 143 characters
14 | WARNING | Line exceeds 80 characters; contains 113 characters
15 | WARNING | Line exceeds 80 characters; contains 129 characters
----------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/textarea_limit/src/Form/LimitTextSettingsForm.php
----------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------
1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
2 | ERROR | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/textarea_limit/src/TextareaLimitConstants.php
------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------
19 | ERROR | [x] The closing brace for the class must have an empty line before it
------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/textarea_limit/src/TextareaLimitCallbacks.php
---------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------
5 | WARNING | [x] Unused use statement
---------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------

Time: 1.39 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/textarea_limit/

Proposed resolution

Above error/warnings need to be fixed.

šŸ“Œ Task
Status

Needs review

Version

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

Comments & Activities

  • Issue created by @samit.310@gmail.com
  • šŸ‡®šŸ‡³India samit.310@gmail.com

    Above errors/warnings has been fixed.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India Ashutosh Ahirwal India

    Hi I have test your patch it get apply cleanly but having some other issue too.

    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml web/modules/custom/textarea_limit

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/textarea_limit/textarea_limit.module
    ------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------
    10 | 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
    ------------------------------------------------------------------------------------------------------------------------------

    Time: 122ms; Memory: 10MB

    Providing patch with remaining issue fixes with #2.

  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 10.0.7 + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    Patch Failed to Apply
  • šŸ‡®šŸ‡³India Anjali Mehta

    Hello @Ashutosh Ahirwal
    Tested #3355065-3.patch on Drupal 9.5 and php version 8.1. Patch applied cleanly. But getting a warning and error on running the phpcs. Adding screenshot for Your references. Please have a look.
    Thank You for your support.

  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 10.0.7 + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    Patch Failed to Apply
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I applied patch #3 into the module and I noticed it fixes all the PHPCS issues.

    āžœ  textarea_limit git:(3.x) curl https://www.drupal.org/files/issues/2023-06-19/3355065-3_0.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3662  100  3662    0     0   7981      0 --:--:-- --:--:-- --:--:--  8083
    patching file README.md
    patching file 'css/textarea_limit.css'
    patching file 'src/Form/LimitTextSettingsForm.php'
    patching file 'src/TextareaLimitCallbacks.php'
    patching file 'src/TextareaLimitConstants.php'
    patching file textarea_limit.module
    āžœ  textarea_limit git:(3.x) āœ— ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml textarea_limit 
    āžœ  contrib git:(main) āœ— 
    

    RTBC +1 from me

Production build 0.71.5 2024