Drupal Coding Standards Issues | phpcs

Created on 28 December 2022, almost 2 years ago
Updated 14 July 2024, 4 months ago

Problem/Motivation

Getting following error/warnings

FILE: ...\htdocs\drupal9.4\d9.4\web\modules\bitly_shortener\css\bitly-shortener.css
--------------------------------------------------------------------------------
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\bitly_shortener\js\bitly-shortener.js
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found
    |       |     "\r\n"
 20 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ...4\d9.4\web\modules\bitly_shortener\src\Form\BitlyShortenerSettingsForm.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"
 13 | WARNING | [ ] The class short comment should describe what the class does
    |         |     and not simply repeat the class name
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ...\d9.4\web\modules\bitly_shortener\src\Plugin\Block\BitlyShortenerBlock.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: ...4\d9.4\web\modules\bitly_shortener\src\Services\BitlyShortenerServices.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"
 11 | WARNING | [ ] The class short comment should describe what the class does
    |         |     and not simply repeat the class name
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ...b\modules\bitly_shortener\src\Services\BitlyShortenerServicesInterface.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"
 7 | WARNING | [ ] The class short comment should describe what the class does
   |         |     and not simply repeat the class name
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ....4\web\modules\bitly_shortener\src\Services\BitlyShortenerTwigServices.php
--------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 4 LINES
--------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found
    |       |     "\r\n"
 38 | ERROR | [ ] Doc comment short description must start with a capital
    |       |     letter
 39 | ERROR | [ ] Doc comment short description must be on a single line,
    |       |     further text should be a separate paragraph
 55 | ERROR | [ ] Doc comment short description must end with a full stop
 55 | ERROR | [ ] Doc comment short description must be on a single line,
    |       |     further text should be a separate paragraph
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 482ms; Memory: 8MB

Proposed resolution

Above error/warnings need to be fixed

📌 Task
Status

Fixed

Version

2.1

Component

Code

Created by

🇮🇳India Jay Jangid

Live updates comments and jobs are added and updated live.
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.

  • @sonal-gyanani opened merge request.
  • Status changed to Needs work 4 months ago
  • 🇮🇳India riddhi.addweb

    I tried both the Patches [Mr7 & #2] but when the #2 patch was applied, it showed some errors. And MR7 was applied cleanly but errors are still not resolved. Also attaching screenshots.

    MR7 Issue:-

    FILE: /var/www/html/web/drupal10/web/modules/contrib/bitly_shortener/bitly_shortener.links.menu.yml
    ---------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------
     5 | ERROR | [x] Expected 1 newline at end of file; 2 found
    ---------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/drupal10/web/modules/contrib/bitly_shortener/src/Plugin/Block/BitlyShortenerBlock.php
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
      8 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\bitly_shortener\Services\BitlyShortenerServicesInterface.
     60 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
     61 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/drupal10/web/modules/contrib/bitly_shortener/src/Services/BitlyShortenerTwigServices.php
    ----------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------
     37 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ----------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/drupal10/web/modules/contrib/bitly_shortener/src/Services/BitlyShortenerServices.php
    ------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------
     68 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/drupal10/web/modules/contrib/bitly_shortener/src/Form/BitlyShortenerSettingsForm.php
    -----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 5 LINES
    -----------------------------------------------------------------------------------------------------------------------------------------
     33 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     34 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     47 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     72 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     84 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     84 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
    -----------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/drupal10/web/modules/contrib/bitly_shortener/css/bitly-shortener.css
    --------------------------------------------------------------------------------------------
    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: /var/www/html/web/drupal10/web/modules/contrib/bitly_shortener/bitly_shortener.info.yml
    ---------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------
     5 | ERROR | [x] Expected 1 newline at end of file; 2 found
    ---------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------

    #2 Patch Error:-

    Checking patch js/bitly-shortener.js...
    error: while searching for:
    function bitlyShortenerOutFunc() {
    let tooltip = document.getElementById("shortener-tooltip-text");
    tooltip.innerHTML = "Copy to clipboard";
    }
    error: patch failed: js/bitly-shortener.js:17
    error: js/bitly-shortener.js: patch does not apply
    Checking patch src/Form/BitlyShortenerSettingsForm.php...
    error: while searching for:
    use Symfony\Component\DependencyInjection\ContainerInterface;

    /**
    * Class BitlyShortenerSettingsForm.
    *
    * @package Drupal\bitly_shortener\Form
    */

    error: patch failed: src/Form/BitlyShortenerSettingsForm.php:7
    error: src/Form/BitlyShortenerSettingsForm.php: patch does not apply
    Checking patch src/Services/BitlyShortenerServices.php...
    error: while searching for:
    use Drupal\Core\Messenger\MessengerInterface;

    /**
    * BitlyShortenerServices.
    */
    class BitlyShortenerServices implements BitlyShortenerServicesInterface {

    error: patch failed: src/Services/BitlyShortenerServices.php:7
    error: src/Services/BitlyShortenerServices.php: patch does not apply
    Checking patch src/Services/BitlyShortenerServicesInterface.php...
    Checking patch src/Services/BitlyShortenerTwigServices.php...
    error: while searching for:

    /**
    * {@inheritdoc}
    * Return your twig function.
    */
    public function getFunctions(): array {

    error: patch failed: src/Services/BitlyShortenerTwigServices.php:36
    error: src/Services/BitlyShortenerTwigServices.php: patch does not apply

  • 🇮🇳India radheymkumar Jaipur, Rajasthan, India

    Fixed

  • Assigned to radheymkumar
  • Status changed to Fixed 4 months ago
  • 🇮🇳India radheymkumar Jaipur, Rajasthan, India
Production build 0.71.5 2024