Fix the issues reported by phpcs

Created on 22 May 2023, over 1 year ago
Updated 14 June 2023, over 1 year ago

Problem/Motivation

Module's code contains several Drupal Coding Standards issues. This task is created to fix them.

Steps to reproduce

Run the command:

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

Proposed resolution

Fix the following coding standards issues and upload the patch or create an MR with fixes.

FILE: web\modules\contrib\commerce_order_document\commerce_order_document.info.yml
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
 7 | WARNING | All dependencies must be prefixed with the project name, for
   |         | example "drupal:"
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\commerce_order_document.module
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
--------------------------------------------------------------------------------
 1 | ERROR   | [x] End of line character is invalid; expected "\n" but found
   |         |     "\r\n"
 8 | WARNING | [x] Unused use statement
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\README.md
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
 3 | WARNING | Line exceeds 80 characters; contains 186 characters
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\src\Annotation\CommerceOrderDocument.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\src\Controller\OrderDocumentController.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\src\Entity\EntityWithOrderDocumentInterface.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\src\Entity\OrderDocument.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\src\Entity\OrderDocumentInterface.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\src\EntityPrint\OrderDocumentRenderer.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found
    |         |     "\r\n"
 21 | WARNING | [ ] Line exceeds 80 characters; contains 89 characters
 36 | WARNING | [ ] Line exceeds 80 characters; contains 89 characters
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\src\Event\DocumentEvents.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------



FILE: web\modules\contrib\commerce_order_document\src\Event\FilterOrderDocumentsEvent.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------



FILE: web\modules\contrib\commerce_order_document\src\EventSubscriber\FilterConditionsEventSubscriber.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------



FILE: web\modules\contrib\commerce_order_document\src\EventSubscriber\OrderEventEmailSubscriber.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------



FILE: web\modules\contrib\commerce_order_document\src\Form\OrderDocumentForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
--------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found
    |         |     "\r\n"
 90 | WARNING | [ ] Line exceeds 80 characters; contains 86 characters
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\src\Form\OrderDocumentSendForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------



FILE: web\modules\contrib\commerce_order_document\src\Form\OrderDocumentsForm.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
   1 | ERROR | [x] End of line character is invalid; expected "\n" but found
     |       |     "\r\n"
 122 | ERROR | [x] Whitespace found at end of line
--------------------------------------------------------------------------------



FILE: web\modules\contrib\commerce_order_document\src\OrderDocumentListBuilder.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------



FILE: web\modules\contrib\commerce_order_document\src\OrderDocumentManager.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------



FILE: web\modules\contrib\commerce_order_document\src\OrderDocumentStorage.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\src\OrderDocumentStorageInterface.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_documentsrc\Plugin\Commerce\OrderDocument\DefaultOrderDocument.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found
     |         |     "\r\n"
   8 | WARNING | [x] Unused use statement
 108 | WARNING | [ ] Unused variable $order_profiles.
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\src\Plugin\Commerce\OrderDocument\OrderDocumentBase.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\src\Plugin\Commerce\OrderDocument\OrderDocumentInterface.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------


FILE: web\modules\contrib\commerce_order_document\src\Plugin\Commerce\OrderDocument\Receipt.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------

📌 Task
Status

Needs work

Version

1.0

Component

Code

Created by

🇮🇳India Shanu Chouhan

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

    Here's a patch for it.

  • Status changed to Needs work over 1 year ago
  • 🇵🇭Philippines kenyoOwen

    Hi Shanu Chouhan

    I applied patch#2 and confirmed that phpcs mentioned is fixed except for the info.yml issues. Please see the screenshots attached.

    For your review.
    Thank you.

  • Assigned to imustakim
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    To make the previous comment more explicit, the following change is not correct.

    -  - commerce
    +  - drupal:commerce

    The Commerce Core module is not a Drupal core module.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇨🇦Canada imustakim Canada

    Patch updated.
    These errors are showing up because the constructor description including the class namespace, assuming this can be ignored.
    Please review.

    ❯ phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml,css,js .
    
    FILE: /Users/specbee/Sites/Projects/commerce_order_document/src/Form/OrderDocumentForm.php
    ------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------
     35 | WARNING | Line exceeds 80 characters; contains 84 characters
    ------------------------------------------------------------------------------------------
    
    
    FILE: /Users/specbee/Sites/Projects/commerce_order_document/src/Form/OrderDocumentsForm.php
    -------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------
     40 | WARNING | Line exceeds 80 characters; contains 85 characters
    -------------------------------------------------------------------------------------------
    
    
    FILE: /Users/specbee/Sites/Projects/commerce_order_document/src/Plugin/Commerce/OrderDocument/OrderDocumentBase.php
    -------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------
     103 | WARNING | Line exceeds 80 characters; contains 109 characters
    -------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/specbee/Sites/Projects/commerce_order_document/src/OrderDocumentStorage.php
    ----------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------
     30 | WARNING | Line exceeds 80 characters; contains 81 characters
    ----------------------------------------------------------------------------------------
    
    
    FILE: /Users/specbee/Sites/Projects/commerce_order_document/src/OrderDocumentManager.php
    ----------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------
     19 | WARNING | Line exceeds 80 characters; contains 81 characters
    ----------------------------------------------------------------------------------------
    
    
    FILE: /Users/specbee/Sites/Projects/commerce_order_document/src/EventSubscriber/OrderEventEmailSubscriber.php
    -------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------
     22 | WARNING | Line exceeds 80 characters; contains 100 characters
    -------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/specbee/Sites/Projects/commerce_order_document/src/Event/FilterOrderDocumentsEvent.php
    ---------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------
     30 | WARNING | Line exceeds 80 characters; contains 93 characters
    ---------------------------------------------------------------------------------------------------
    
    Time: 461ms; Memory: 12MB
    
  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States lisastreeter

    Looks like the latest patch still has an incorrect change in the .info file.

    Also, can somebody point me to the Drupal Coding Standards policy that states we need the full class namespace? I'm not seeing that format in any existing Commerce Core code, and personally, I feel like the original is more readable (and doesn't violate the 80 character line limit.)

    For this change:

    -    // First entity should be order document; additional should be orders to be rendered.
    +    // First entity should be order document;
    +    // additional should be orders to be rendered.

    Perhaps we can just reword the original comment instead of breaking it into two separate comments? I think that would look cleaner.

    Also, here:

    -    // Pass the plugin configuration only if the plugin hasn't been changed via #ajax.
    +    // Pass the plugin configuration only ,
    +    // if the plugin hasn't been changed via #ajax.
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Drupal core describes constructors using a phrase similar to the following one.

    Constructs a \Drupal\views\Plugin\views\argument_validator\Entity object.

    As for the comments, I am not sure it is possible to reduce a sentence that is longer than 80 character into a shorter sentence.

  • 🇺🇸United States lisastreeter

    @apaderno Thanks for the example class comment. In that same Core views module, I also see a constructor in class BlockForm extends EntityForm { that does not use the full namespace:

    * Constructs a BlockForm object.

    So core doesn't seem to be consistent in its phrasing. When working within the Commerce ecosystem, I tend to follow the coding standards used within Commerce Core. I read through this document, but wasn't able to find specific guidance:
    https://www.drupal.org/docs/develop/standards/php/api-documentation-and-comment-standards

    One possible shorter sentence for:

    // First entity should be order document; additional should be orders to be rendered.

    // Entities should be order document followed by orders to be rendered.

Production build 0.71.5 2024