Fix Issue Reported by phpcs

Created on 31 January 2024, 11 months ago
Updated 30 May 2024, 7 months ago

Problem/Motivation

Fix all the issues reported by PHPCS for Drupal and DrupalPractice Coding Standards

Steps to reproduce

Run Command - vendor/bin/phpcs --standard=Drupal,DrupalPractice instagram_feed_by_username

Proposed resolution

Fixing all issues mentioned -
FILE: /var/www/drupal/dummy/web/modules/custom/instagram_feed_by_username/src/InstagramFeedByUsernameService.php
--------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is GuzzleHttp\ClientInterface.
--------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------

FILE: /var/www/drupal/dummy/web/modules/custom/instagram_feed_by_username/src/Plugin/Field/FieldType/InstagramFeedByUsernameField.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------
8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\StringTranslation\TranslatableMarkup.
------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/drupal/dummy/web/modules/custom/instagram_feed_by_username/src/Plugin/Field/FieldFormatter/InstagramFeedByUsernameFieldFormatter.php
---------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\FieldItemListInterface.
---------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------------

šŸ“Œ Task
Status

RTBC

Version

1.1

Component

Code

Created by

šŸ‡®šŸ‡³India ighosh

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 @ighosh
  • Status changed to Needs review 11 months ago
  • šŸ‡®šŸ‡³India ighosh

    Made changes. Please review and let me know in case of any concerns. https://git.drupalcode.org/project/instagram_feed_by_username/-/merge_re...

  • First commit to issue fork.
  • Status changed to Needs work 11 months ago
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I applied MR !4 and I noticed that there is 1 file that the patch didn't apply properly,

    This is the PHPCS results from my terminal

    āžœ  instagram_feed_by_username git:(master) āœ— curl https://git.drupalcode.org/project/instagram_feed_by_username/-/merge_requests/4.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3390    0  3390    0     0   5595      0 --:--:-- --:--:-- --:--:--  5707
    patching file instagram_feed_by_username.module
    No such line 39 in input file, ignoring
    1 out of 1 hunks failed--saving rejects to instagram_feed_by_username.module.rej
    patching file 'src/InstagramFeedByUsernameService.php'
    patching file 'src/Plugin/Field/FieldFormatter/InstagramFeedByUsernameFieldFormatter.php'
    patching file 'src/Plugin/Field/FieldType/InstagramFeedByUsernameField.php'
    āžœ  instagram_feed_by_username git:(master) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml instagram_feed_by_username
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/instagram_feed_by_username/instagram_feed_by_username.info.yml
    ---------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------
     1 | WARNING | File has mixed line endings; this may cause incorrect results
     1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
     1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
     1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    ---------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 307ms; Memory: 10MB
    
    āžœ  contrib git:(master) āœ—
  • šŸ‡®šŸ‡³India Shreyas gowda

    NO phpcs errors or warnings found

  • Issue was unassigned.
  • Status changed to Needs review 10 months ago
  • šŸ‡®šŸ‡³India zkhan.aamir

    Hi,

    MR #3 applied successfully.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/instagram_feed_by_username (1.0.x)
    $ curl https://git.drupalcode.org/project/instagram_feed_by_username/-/merge_requests/4.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3390    0  3390    0     0   9310      0 --:--:-- --:--:-- --:--:--  9338
    patching file instagram_feed_by_username.module
    patching file src/InstagramFeedByUsernameService.php
    patching file src/Plugin/Field/FieldFormatter/InstagramFeedByUsernameFieldFormatter.php
    patching file src/Plugin/Field/FieldType/InstagramFeedByUsernameField.php
    

    No issues remianing.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules
    $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml instagram_feed_by_username/
    
    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules
    $
    
    
  • Status changed to Needs work 7 months ago
  • šŸ‡®šŸ‡³India dev16.addweb

    I have checked and found some indentation issues remaining.

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

    Hi @silvi.addweb,

    I applied MR!4 and it was applied smoothly.

    However, when I still encountered some issues when I run phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml.

    āžœ  instagram_feed_by_username git:(main) āœ— curl https://git.drupalcode.org/project/instagram_feed_by_username/-/merge_requests/4.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4721    0  4721    0     0   8946      0 --:--:-- --:--:-- --:--:--  8958
    patching file instagram_feed_by_username.module
    Hunk #1 FAILED at 40.
    1 out of 1 hunk FAILED -- saving rejects to file instagram_feed_by_username.module.rej
    patching file src/InstagramFeedByUsernameService.php
    patching file src/Plugin/Field/FieldFormatter/InstagramFeedByUsernameFieldFormatter.php
    patching file src/Plugin/Field/FieldType/InstagramFeedByUsernameField.php
    patching file src/Plugin/Field/FieldWidget/InstagramFeedByUsernameFieldWidget.php
    āžœ  instagram_feed_by_username git:(main) āœ— ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml instagram_feed_by_username
    
    FILE: /Users/interns/Demo-site/drupal-orgissue/web/modules/contrib/instagram_feed_by_username/instagram_feed_by_username.info.yml
    ---------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------
     1 | WARNING | File has mixed line endings; this may cause incorrect results
     1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
     1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
     1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    ---------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-orgissue/web/modules/contrib/instagram_feed_by_username/src/Plugin/Field/FieldWidget/InstagramFeedByUsernameFieldWidget.php
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
     35 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-orgissue/web/modules/contrib/instagram_feed_by_username/src/Plugin/Field/FieldType/InstagramFeedByUsernameField.php
    ---------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------------------------
     33 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    ---------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 164ms; Memory: 10MB
    
    āžœ  contrib git:(main) āœ—

    Thank you.

  • šŸ‡®šŸ‡³India ighosh

    Hi @cleavinjosh. MR Updated. Please check and let us know. Thanks!

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

    Hi @IGhosh,

    I applied MR!4 and I encountered a failure.

    āžœ  instagram_feed_by_username git:(main) āœ— curl https://git.drupalcode.org/project/instagram_feed_by_username/-/merge_requests/4.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4723    0  4723    0     0   9000      0 --:--:-- --:--:-- --:--:--  9013
    patching file instagram_feed_by_username.module
    Hunk #1 FAILED at 40.
    1 out of 1 hunk FAILED -- saving rejects to file instagram_feed_by_username.module.rej
    patching file src/InstagramFeedByUsernameService.php
    patching file src/Plugin/Field/FieldFormatter/InstagramFeedByUsernameFieldFormatter.php
    patching file src/Plugin/Field/FieldType/InstagramFeedByUsernameField.php
    patching file src/Plugin/Field/FieldWidget/InstagramFeedByUsernameFieldWidget.php
    āžœ  instagram_feed_by_username git:(main) āœ—

    After I run phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml, I encountered less issues compared my last test.

    āžœ  instagram_feed_by_username git:(main) āœ— ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml instagram_feed_by_username
    
    FILE: /Users/interns/Demo-site/drupal-orgissue/web/modules/contrib/instagram_feed_by_username/instagram_feed_by_username.info.yml
    ---------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------
     1 | WARNING | File has mixed line endings; this may cause incorrect results
     1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
     1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
     1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    ---------------------------------------------------------------------------------------------------------------------------------
    
    Time: 242ms; Memory: 10MB
    
    āžœ  contrib git:(main) āœ—

    Thank you.

  • šŸ‡®šŸ‡³India ighosh

    Hi @cleavinjosh, I ran the same command and got no issues.

    ghoshishan@ishan-notebook-pro /v/w/d/dummy> ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml web/*/custom/instagram_feed_by_username/
    ghoshishan@ishan-notebook-pro /v/w/d/dummy> 
    

    Could this be because when I worked on this issue, I cloned the module onto the 'custom' folder and not the 'contrib' folder?
    Here is a screenshot of the instagram_feed_by_username.info.yml file -

  • Status changed to RTBC 7 months ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @IGhosh,

    You are correct. Indeed, the issue won't show when I cloned the module and not by using composer.

    I applied MR!4, now, it was applied smoothly and there was no issues shown after I ran phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml.

    āžœ  instagram_feed_by_username git:(1.0.x) curl https://git.drupalcode.org/project/instagram_feed_by_username/-/merge_requests/4.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4723    0  4723    0     0  10215      0 --:--:-- --:--:-- --:--:-- 10222
    patching file instagram_feed_by_username.module
    patching file src/InstagramFeedByUsernameService.php
    patching file src/Plugin/Field/FieldFormatter/InstagramFeedByUsernameFieldFormatter.php
    patching file src/Plugin/Field/FieldType/InstagramFeedByUsernameField.php
    patching file src/Plugin/Field/FieldWidget/InstagramFeedByUsernameFieldWidget.php
    āžœ  instagram_feed_by_username git:(1.0.x) āœ— ..
    āžœ  drupal-org-issues git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml instagram_feed_by_username
    āžœ  drupal-org-issues git:(main) āœ—

    Thank you.

  • šŸ‡®šŸ‡³India ighosh

    Hi @cleavinjosh, thanks for the clarification. Cheers!

Production build 0.71.5 2024