Fix the errors/warnings reported by Php_CodeSniffer

Created on 5 July 2023, about 1 year ago
Updated 12 July 2023, about 1 year ago

Problem/Motivation

PHPCS reports the following errors:

C:\xampp\htdocs\backendassignment\web\modules\contrib>phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig bulk_copy_fields

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\bulk_copy_fields\bulk_copy_fields.install
-----------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------
 1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
-----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\bulk_copy_fields\bulk_copy_fields.module
-----------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 16 | WARNING | [x] 'TODO: tried to do this as suggested at https://www.drupal.org/node/2020549' should match the format '@todo Fix problem X here.'
 22 | WARNING | [x] 'TODO: a hook to utilize on entity type creation is not obvious.' should match the format '@todo Fix problem X here.'
-----------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\bulk_copy_fields\src\BulkCopyFields.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 3 WARNINGS AFFECTING 6 LINES
-------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
   9 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
 100 | ERROR   | [x] Inline comments must start with a capital letter
 100 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 140 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
 141 | WARNING | [x] 'TODO?: Do other entity types need revisions set?' should match the format '@todo Fix problem X here.'
 172 | ERROR   | [x] Concat operator must be surrounded by a single space
 172 | ERROR   | [x] Concat operator must be surrounded by a single space
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\bulk_copy_fields\src\Form\BulkCopyFieldsForm.php
------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 2 WARNINGS AFFECTING 8 LINES
------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 139 | ERROR   | [x] Case breaking statements must be followed by a single blank line
 165 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 191 | ERROR   | [x] Expected 1 space after FOREACH keyword; 0 found
 204 | ERROR   | [x] Case breaking statements must be followed by a single blank line
 250 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 269 | ERROR   | [x] Case breaking statements must be followed by a single blank line
 306 | ERROR   | [x] Case breaking statement indented incorrectly; expected 8 spaces, found 6
------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------

Steps to reproduce

Run the phpcs command on the module.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

RTBC

Version

1.0

Component

Code

Created by

🇮🇳India sidharth_soman Bangalore

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 @sidharth_soman
  • @sidharth_soman opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India sidharth_soman Bangalore

    I have fixed all the issues... including the dependency injection.
    Please review the MR.

  • Status changed to Needs work about 1 year ago
  • @sidharth_soman , still seeing these errors/warning ->

    $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig bulk_copy_fields

    FILE: C:\xampp\htdocs\project\modules\contrib\bulk_copy_fields\bulk_copy_fields.info.yml
    -------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------
    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: C:\xampp\htdocs\project\modules\contrib\bulk_copy_fields\bulk_copy_fields.install
    ---------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------
    1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
    ---------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------

    FILE: C:\xampp\htdocs\project\modules\contrib\bulk_copy_fields\bulk_copy_fields.module
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------
    1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
    9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Database\Database.
    -----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------

    FILE: C:\xampp\htdocs\project\modules\contrib\bulk_copy_fields\src\BulkCopyFields.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"
    9 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
    140 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
    ----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------

    FILE: C:\xampp\htdocs\project\modules\contrib\bulk_copy_fields\src\Form\BulkCopyFieldsForm.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------------------
    1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
    11 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Messenger\MessengerInterface.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------

    FILE: C:\xampp\htdocs\project\modules\contrib\bulk_copy_fields\src\Plugin\Action\BulkCopyFieldsActionBase.php
    ---------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------
    9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\TempStore\PrivateTempStoreFactory.
    ---------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------------

    Time: 319ms; Memory: 12MB

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India Ashutosh Ahirwal India

    I'm Providing new patch with all the fixes.
    please review.

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

    For below issue clone the module from command available in version control menu.
    Project, datestamp, version added by drupal as a info of module when we download any module using composer.

    FILE: C:\xampp\htdocs\project\modules\contrib\bulk_copy_fields\bulk_copy_fields.info.yml
    -------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------
    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
    -------------------------------------------------------------------------------------------------------------

  • Status changed to RTBC about 1 year ago
  • 🇵🇭Philippines clarkssquared

    Hi Ashutosh Ahirwal

    I applied your patch #5 in my local after cloning the module and I confirmed that your patch fixed all the PHPCS errors/warnings.

    Please look at the screenshot attached for your reference

    Thank you.

Production build 0.71.5 2024