Fix the issues reported by phpcs

Created on 19 January 2023, almost 2 years ago
Updated 13 February 2024, 9 months ago

Problem/Motivation

Getting Following errors/warnings

$ phpcs --standard=Drupal monix

FILE: D:\xampp\htdocs\drupal9.4\d9.4\web\modules\monix\src\Annotation\Monix.php
--------------------------------------------------------------------------------
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: ...htdocs\drupal9.4\d9.4\web\modules\monix\src\Controller\MonixController.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found
    |       |     "\r\n"
 83 | ERROR | [x] Use null coalesce operator instead of ternary operator.
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ...mpp\htdocs\drupal9.4\d9.4\web\modules\monix\src\Form\MonixSettingsForm.php
--------------------------------------------------------------------------------
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: D:\xampp\htdocs\drupal9.4\d9.4\web\modules\monix\src\MonixPluginBase.php
--------------------------------------------------------------------------------
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: ...p\htdocs\drupal9.4\d9.4\web\modules\monix\src\MonixPluginBaseInterface.php
--------------------------------------------------------------------------------
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: ...:\xampp\htdocs\drupal9.4\d9.4\web\modules\monix\src\MonixPluginManager.php
--------------------------------------------------------------------------------
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: ...p\htdocs\drupal9.4\d9.4\web\modules\monix\src\Plugin\Monix\LastCronRun.php
--------------------------------------------------------------------------------
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: ...pp\htdocs\drupal9.4\d9.4\web\modules\monix\src\Plugin\Monix\ModuleList.php
--------------------------------------------------------------------------------
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: ...pp\htdocs\drupal9.4\d9.4\web\modules\monix\src\Plugin\Monix\TotalUsers.php
--------------------------------------------------------------------------------
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: D:\xampp\htdocs\drupal9.4\d9.4\web\modules\monix\src\Routing\Routes.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found
    |       |     "\r\n"
 64 | ERROR | [ ] The array declaration extends to column 82 (the limit is 80).
    |       |     The array content should be split up over multiple lines
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 509ms; Memory: 8MB

Proposed resolution

Fix the errors and warnings.

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India Jay Jangid

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

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs work over 1 year ago
  • 🇵🇭Philippines clarkssquared

    Hi Jay Jangid

    I applied your MR !2 in my local and it applied cleanly, however, there are still PHPCS errors being flagged,

    contrib git:(master) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml monix

    FILE: /Users/studenttrainees/Projects/drupalorgissues/docroot/modules/contrib/monix/src/MonixPluginManager.php
    --------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------
    48 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    --------------------------------------------------------------------------------------------------------------

    FILE: /Users/studenttrainees/Projects/drupalorgissues/docroot/modules/contrib/monix/src/Controller/MonixController.php
    ----------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
    ----------------------------------------------------------------------------------------------------------------------
    77 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    99 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    100 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ----------------------------------------------------------------------------------------------------------------------

    Time: 210ms; Memory: 10MB

    Please look at the screenshot attached for your reference.

    Thanks

  • Assigned to himanshu_jhaloya
  • 🇮🇳India himanshu_jhaloya Indore

    I will work on this issue.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India himanshu_jhaloya Indore

    created a patch to fix the issue. one is remaining. please reivew

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    I do not have time for a full review, but the following property is already defined in the parent class (ControllerBase) and it does not need to be redefined from this class.

    +  /**
    +   * The configuration factory service.
    +   *
    +   * @var \Drupal\Core\Config\ConfigFactoryInterface
    +   */
    +  protected $configFactory;

    I would suggest to check the changes done to avoid redefining properties the parent classes already define and verify which methods from the parent classes can be used.

  • Assigned to imustakim
  • 🇮🇳India imustakim Ahmedabad
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India imustakim Ahmedabad

    Patch updated.
    Please review.

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +  /**
    +   * The current global container.
    +   *
    +   * @var \Drupal\Component\DependencyInjection\Container
    +   */
    +  protected $container;
    +


    The dependency injection container.
    is a better description, since current global container does not make clear which container that would be.

  • Assigned to imustakim
  • 🇮🇳India imustakim Ahmedabad
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India imustakim Ahmedabad

    Patch updated as per suggestions.
    Please review.

  • Hi, Reviewed the patch at #13 applies cleanly, fixes all the phpcs errors and addresses the comment at #11.
    Thank you!

Production build 0.71.5 2024