Fix the issues reported by phpcs

Created on 5 July 2023, about 1 year ago
Updated 28 June 2024, 3 months ago

GitLab CI reports the following PHP_CodeSniffer warnings/errors, which should be fixed.

FILE: ...72412/web/modules/custom/shopify_app-3372412/src/ShopifyAppPermissions.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
  7 | ERROR | [x] Missing class doc comment
    |       |     (Drupal.Commenting.ClassComment.Missing)
 11 | ERROR | [x] Missing function doc comment
    |       |     (Drupal.Commenting.FunctionComment.Missing)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...y_app-3372412/web/modules/custom/shopify_app-3372412/src/ShopInterface.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 25 | ERROR | [x] Parameter comment must end with a full stop
    |       |     (Drupal.Commenting.FunctionComment.ParamCommentFullStop)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...412/web/modules/custom/shopify_app-3372412/src/PageCache/RequestPolicy.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
 24 | ERROR | [x] Doc comment short description must start with a capital
    |       |     letter (Drupal.Commenting.DocComment.ShortNotCapital)
 27 | ERROR | [x] Parameter comment must end with a full stop
    |       |     (Drupal.Commenting.FunctionComment.ParamCommentFullStop)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ustom/shopify_app-3372412/src/Authentication/ImpersonateShopifyRequest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 36 | ERROR | [x] There must be exactly one blank line before the tags in a doc
    |       |     comment (Drupal.Commenting.DocComment.SpacingBeforeTags)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...72412/web/modules/custom/shopify_app-3372412/src/Access/AppAccessCheck.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
--------------------------------------------------------------------------------
  7 | ERROR   | [x] Use statements should be sorted alphabetically. The first
    |         |     wrong one is Drupal\Core\Routing\Access\AccessInterface.
    |         |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
 61 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
    |         |     (Drupal.Files.LineLength.TooLong)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...pify_app-3372412/web/modules/custom/shopify_app-3372412/shopify_app.module
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 11 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is Drupal\shopify_app\WebhookHandler.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ify_app-3372412/web/modules/custom/shopify_app-3372412/shopify_app.install
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 58 | ERROR | [x] Expected 1 newline at end of file; 0 found
    |       |     (Drupal.Files.EndFileNewline.NoneFound)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
Time: 246ms; Memory: 6MB

 
 

๐Ÿ“Œ Task
Status

RTBC

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia urvashi_vora Madhya Pradesh, India

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 @urvashi_vora
  • Hi @ urvashi_vora, I have applied your patch and run successfully .

    These are the steps I followed:

    1. Took clone in drupal 10.1.x

    2. Ran this command:

    ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,m
    d,yml,twig modules/contrib/shopify_app/

    3. Applied patch and again ran phpcs command.

    found errors.

    I have fixed that error with phpcbf.

    Ran this command to fix the errors:

    ./vendor/bin/phpcbf --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,m
    d,yml,twig modules/contrib/shopify_app/

    4. Then again checked with phpcs:

    ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,m
    d,yml,twig modules/contrib/shopify_app/

    Found no errors.

    Needs review.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    -          // Not an app proxy request, possible a current session already exists?
    +          // Not app proxy request, possible a current session already exists?
    

    The indefinite article is correct. If a line is longer than 80 characters, it just need to be split in two.
    Anyway, that sentence is not grammatically correct and it should be rewritten. For example, it must be possibly, a current session already exists.

       /**
    -   * constructor.
    +   * Constructor.
        *
        * @param \Drupal\shopify_app\Authentication\ImpersonateShopifyRequest $impersonateShopifyRequest
    -   *   The authentication provider
    +   *   The authentication provider.
        */

    For constructors, the documentation comment is not anymore necessary. If it is added, the description should be Constructs a new [class name] object. where [class name] is the class name, namespace included.

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    Please review.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia aayushDrupal

    Hi @sakthi_dev
    Your patch #4 is fixing some of the issues of #3 but * @param \Drupal\shopify_app\Authentication\ImpersonateShopifyRequest $impersonateShopifyRequest this line is still longer than 80 characters .
    Please check

  • Status changed to Needs work about 1 year ago
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia aayushDrupal

    I have made some changes as mentioned above.
    Please review my patch.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +          // Not an app proxy request, it must be possible, a current session
    +          // already exists.

    That is a comma-split sentence. It is not an proxy request. It is possible that a current session already exists. is better.

    -   * constructor.
    +   * Constructs a new RequestPolicy Object.

    The class namespace is still missing. object is spelled in lowercase letters, since it is not at the beginning of the description.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia aayushDrupal

    Hi apaderno,
    I have fixed errors in this patch as you mentioned.
    Please review.

  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work 4 months ago
  • Hi @aayushamkotia,

    I applied patch #9, it applied successfully but still resulted to 1 error.

    shopify_app git:(1.0.x) curl https://www.drupal.org/files/issues/2023-09-13/comment_errors_fixed_3372412_9.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4493  100  4493    0     0  17969      0 --:--:-- --:--:-- --:--:-- 18878
    patching file README.txt
    patching file config/schema/shopify_app.schema.yml
    patching file shopify_app.install
    patching file shopify_app.module
    patching file src/Access/AppAccessCheck.php
    patching file src/Authentication/ImpersonateShopifyRequest.php
    patching file src/PageCache/RequestPolicy.php
    patching file src/ShopInterface.php
    patching file src/ShopifyAppPermissions.php
    โžœ  shopify_app git:(1.0.x) โœ— cd ..
    โžœ  contrib git:(main) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig shopify_app
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/shopify_app/src/Access/AppAccessCheck.php
    ------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------
     7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Routing\Access\AccessInterface.
    ------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 440ms; Memory: 10MB

    Kindly check

    Thanks,
    Jake

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Success
    4 months ago
    Total: 146s
    #187141
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs review 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Success
    4 months ago
    Total: 177s
    #187167
  • Status changed to Needs work 4 months ago
  • Hi @apaderno,

    Applied your latest changes, it threw more errors than the patch #9

    shopify_app git:(1.0.x) curl https://git.drupalcode.org/project/shopify_app/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  8408    0  8408    0     0  21810      0 --:--:-- --:--:-- --:--:-- 22361
    patching file .gitlab-ci.yml
    patching file shopify_app.install
    patching file shopify_app.module
    patching file src/Access/AppAccessCheck.php
    patching file src/Authentication/ImpersonateShopifyRequest.php
    patching file src/PageCache/RequestPolicy.php
    patching file src/ShopInterface.php
    patching file src/ShopifyAppPermissions.php
    โžœ  shopify_app git:(1.0.x) โœ— cd ..
    โžœ  contrib git:(main) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig shopify_app
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/shopify_app/config/schema/shopify_app.schema.yml
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
     16 | ERROR | [x] Expected 1 newline at end of file; 0 found
    -------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/shopify_app/README.txt
    -----------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------
     1 | ERROR | [x] Expected 1 newline at end of file; 0 found
    -----------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------
    
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/shopify_app/src/Access/AppAccessCheck.php
    -------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------------------------------------------
     12 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Symfony\Component\HttpFoundation\Request.
     61 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
    -------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 604ms; Memory: 10MB

    Kindly check and advise.

    Thanks,
    Jake

  • Status changed to Needs review 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Success
    4 months ago
    Total: 154s
    #187378
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

    silvi.addweb โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

    Fixed all the following issues. Please review.

  • Pipeline finished with Canceled
    3 months ago
    Total: 665s
    #210367
  • Status changed to RTBC 3 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia atul_ghate

    I have reviewed and applied patch cleanly, it resolved all the phpcs issues. (see attached screenshot)

  • Pipeline finished with Failed
    3 months ago
    Total: 171s
    #211127
Production build 0.71.5 2024