Fix the issues reported by phpcs

Created on 9 May 2023, about 1 year ago
Updated 22 March 2024, 3 months ago

Problem/Motivation

vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig web/modules/contrib/list_formatter/

FILE: /var/www/html/vbd9/web/modules/contrib/list_formatter/src/Tests/OutputTest.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
46 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd9/web/modules/contrib/list_formatter/src/Plugin/ListFormatterPluginManager.php
-----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------
51 | WARNING | Unused variable $id.
-----------------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd9/web/modules/contrib/list_formatter/src/Plugin/list_formatter/TextList.php
--------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------
34 | WARNING | Unused variable $delta.
49 | WARNING | Unused variable $delta.
--------------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd9/web/modules/contrib/list_formatter/src/Plugin/list_formatter/TaxonomyList.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
73 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd9/web/modules/contrib/list_formatter/src/Plugin/list_formatter/OptionsList.php
-----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------
37 | WARNING | Unused variable $delta.
-----------------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd9/web/modules/contrib/list_formatter/src/Plugin/list_formatter/LinkList.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
45 | WARNING | Unused variable $delta.
80 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
81 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
86 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd9/web/modules/contrib/list_formatter/src/Plugin/list_formatter/EntityReferenceList.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
36 | WARNING | Unused variable $delta.
92 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
93 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd9/web/modules/contrib/list_formatter/READ.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
9 | WARNING | Line exceeds 80 characters; contains 81 characters
----------------------------------------------------------------------

Time: 1.18 secs; Memory: 14MB

Steps to reproduce

Proposed resolution

Run:

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

Remaining tasks

User interface changes

API changes

Data model changes

šŸ“Œ Task
Status

Needs work

Version

2.0

Component

Code

Created by

šŸ‡®šŸ‡³India dineshkumarbollu

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 @dineshkumarbollu
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • šŸ‡®šŸ‡³India dineshkumarbollu

    HI

    I fix the phpcs issues except Unused variable $delta. and also change the file READ.md to README.md

    Please Review

    Thanks

  • Status changed to Needs work about 1 year ago
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi dineshkumarbollu,

    I applied your patch #2 to List Formatter module against version 8.x-2.x-dev and confirmed that most of the PHPCS errors were fixed except for the Unused variable $delta. However, I cannot see the README.md after applying the patch, instead it only removes the READ.md file.

    Kindly check please the screenshots attached for your reference.

    Thank you.

  • šŸ‡®šŸ‡³India dineshkumarbollu

    Hi

    It my mistake while creating patch git doesn't track the new file i will provide new patch

  • Status changed to Needs review about 1 year ago
  • Merge request !12coding standards issues ā†’ (Open) created by dineshkumarbollu
  • šŸ‡®šŸ‡³India dineshkumarbollu

    Created MR for this issue please review.

    Thanks

  • Status changed to Needs work about 1 year ago
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi dineshkumarbollu

    I applied your patch #5 and confirmed that README.md replaced READ.md, but moving the status to needs work for the remaining PHPCS error regarding the Unused variable $delta for the maintainer's assessment if the remaining issue must be fixed or not.

    Thank you.

  • Status changed to Needs review about 1 year ago
  • šŸ‡®šŸ‡³India dineshkumarbollu

    Hi clarkssquared

    Please review the MR!12, patch creating some issues.

    Thanks

  • Status changed to Needs work 4 months ago
  • šŸ‡®šŸ‡³India Preethy_ray

    Hi ,
    Applied the MR!12 and found few errors and warning.

  • šŸ‡®šŸ‡³India Yashaswi18

    Hello, I cloned the repository, checked out to the branch '3358999-phpcs-issues' and ran the command "phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig",found no phpcs issues or warnings left. Attaching the screenshot.

  • Status changed to Needs review 3 months ago
  • Status changed to Needs work 3 months ago
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I applied the MR !12 and there are two files that the patch fails to apply, and there are two PHPCS issue that were flagged. I will also move this to needs work because the MR was blocked maybe fix the merge conflict issues.

    āžœ  list_formatter git:(ade7e9f) curl https://git.drupalcode.org/project/list_formatter/-/merge_requests/12.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 11654    0 11654    0     0  23425      0 --:--:-- --:--:-- --:--:-- 23686
    patching file READ.md
    patching file 'src/Plugin/Field/FieldFormatter/ListFormatter.php'
    patching file 'src/Plugin/ListFormatterPluginManager.php'
    1 out of 2 hunks failed--saving rejects to 'src/Plugin/ListFormatterPluginManager.php.rej'
    patching file 'src/Plugin/list_formatter/EntityReferenceList.php'
    patching file 'src/Plugin/list_formatter/LinkList.php'
    patching file 'src/Plugin/list_formatter/OptionsList.php'
    patching file 'src/Plugin/list_formatter/TaxonomyList.php'
    patching file 'src/Plugin/list_formatter/TextList.php'
    patching file 'src/Tests/OutputTest.php'
    1 out of 1 hunks failed--saving rejects to 'src/Tests/OutputTest.php.rej'
    āžœ  list_formatter git:(ade7e9f) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml list_formatter 
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/list_formatter/src/Tests/OutputTest.php
    ----------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------
     45 | WARNING | Unused variable $delta.
    ----------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/list_formatter/src/Plugin/ListFormatterPluginManager.php
    ---------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------
     51 | WARNING | Unused variable $id.
    ---------------------------------------------------------------------------------------------------------------------------------
    
    Time: 414ms; Memory: 12MB
    
    āžœ  contrib git:(master) āœ— 
    
Production build 0.69.0 2024