Fix the issues reported by phpcs

Created on 25 May 2023, about 1 year ago
Updated 3 June 2023, about 1 year ago

Running shows the following errors/warnings which should be fixed.

FILE: ./fakelogin/fakelogin.services.yml
----------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------
 5 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------

FILE: ./fakelogin/src/Routing/FakeLoginRoutes.php
-------------------------------------------------
FOUND 11 ERRORS AFFECTING 5 LINES
-------------------------------------------------
 20 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
 20 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 1
 20 | ERROR | [x] Expected 1 space after "??"; 0 found
 33 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
 33 | ERROR | [x] Line indented incorrectly; expected at least 6 spaces, found 3
 33 | ERROR | [x] No space found before comment text; expected "// Route options" but found "//Route options"
 33 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 36 | ERROR | [x] Spaces must be used for alignment; tabs are not allowed
 36 | ERROR | [x] Whitespace found at end of line
 42 | ERROR | [x] Expected 1 blank line after function; 0 found
 43 | ERROR | [x] The closing brace for the class must have an empty line before it
-------------------------------------------------
PHPCBF CAN FIX THE 11 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------

FILE: ./fakelogin/src/Routing/RouteSubscriber.php
-------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
-------------------------------------------------
 18 | ERROR | [x] Inline comments must start with a capital letter
 33 | ERROR | [x] Expected 1 newline at end of file; 0 found
 33 | ERROR | [x] The closing brace for the class must have an empty line before it
-------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------

FILE: ./fakelogin/src/Form/FakeLoginForm.php
--------------------------------------------
FOUND 9 ERRORS AND 1 WARNING AFFECTING 6 LINES
--------------------------------------------
 39 | ERROR   | [x] Spaces must be used to indent lines; tabs are not allowed
 39 | ERROR   | [x] Whitespace found at end of line
 47 | ERROR   | [x] Spaces must be used to indent lines; tabs are not allowed
 47 | ERROR   | [x] Whitespace found at end of line
 49 | ERROR   | [ ] The array declaration extends to column 86 (the limit is 80). The array content should be split up over
    |         |     multiple lines
 50 | ERROR   | [x] Spaces must be used to indent lines; tabs are not allowed
 50 | ERROR   | [x] Whitespace found at end of line
 65 | WARNING | [ ] Line exceeds 80 characters; contains 124 characters
 65 | ERROR   | [x] No space found before comment text; expected "// $this->messenger()->addStatus($this->t('Your username is
    |         |     @username', ['@username' => $form_state->getValue('name')]));" but found
    |         |     "//$this->messenger()->addStatus($this->t('Your username is @username', ['@username' =>
    |         |     $form_state->getValue('name')]));"
 68 | ERROR   | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------

FILE: ./fakelogin/src/Form/FakeLoginConfigForm.php
--------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 6 LINES
--------------------------------------------------
 21 | ERROR   | [x] Whitespace found at end of line
 27 | ERROR   | [x] Whitespace found at end of line
 57 | ERROR   | [x] Inline comments must start with a capital letter
 58 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 61 | ERROR   | [x] Expected 1 blank line after function; 0 found
 62 | ERROR   | [x] The closing brace for the class must have an empty line before it
--------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------

FILE: ./fakelogin/fakelogin.routing.yml
---------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------
 9 | ERROR | [x] Expected 1 newline at end of file; 0 found
---------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------

FILE: ./fakelogin/fakelogin.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
------------------------------------

Time: 119ms; Memory: 10MB
📌 Task
Status

Fixed

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 about 1 year ago
  • 🇮🇳India Shanu Chouhan

    I have Created a patch to fix this issue.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Why is --standard=Drupal used instead of --standard=Drupal,DrupalPractice?

  • 🇮🇳India Shanu Chouhan

    Hii @apaderno,
    I addressed DrupalPractice issue here https://www.drupal.org/project/fakelogin/issues/3362606 📌 \Drupal::service('router.builder')->rebuild() call should be avoided in classes, Use dependency injection instead in drupal Database Closed: duplicate

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -    // replace default user login with a fake form.
    +    // Replace default user login with a fake form.
    

    Since that comment is edited, a definite article should be added before default user; form should be added after user login.

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

    Tried to fixes the issue.
    providing patch please review.

  • Hello Folks !!
    I have tested the #6 patch and the phpcs issues has been successfully fixed! The patch was tested on Drupal 9.5.9 and PHP 8.2.4. To provide you with a comprehensive view, I will be adding both a before and after screenshot.
    Thank you for your support!

  • This is the screenshot before applying the patch!!

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function __construct(RouteBuilderInterface $routeBuilder) {

    The description for a constructor must start with Constructs a new followed by the class name (including its namespace), and end with object.
    The documentation comment for a constructor must describe the parameters.

    -    //$this->messenger()->addStatus($this->t('Your username is @username', ['@username' => $form_state->getValue('name')]));
    +    // $this->messenger()->addStatus($this->t('Your username is @username', [
    +    // '@username' => $form_state->getValue('name')
    +    // ]));

    Commented out code must still be correctly indented.

    -	  //Route options
    +      // Route options.
           [
             '_maintenance_access' => TRUE,
    -      ]	  
    +      ]

    Rather than editing the comment, I would remove it.

    -    // replace default user login with a fake form.
    +    // Replace default user login with a fake form.

    The definite article is missing before default user login. form is missing after default user login.

  • Assigned to nitin_lama
  • 🇮🇳India nitin_lama

    Addressed #9.
    Updated patch.

  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +  /**
    +   * Constructs a new FakeLoginConfigForm instance.

    The class namespace is missing.

    -    // rebuild the router.
    -    \Drupal::service('router.builder')->rebuild();
    +    // Rebuild the router.
    +    $this->routeBuilder->rebuild();
     

    I would rather remove that comment, as $this->routeBuilder->rebuild(); does not need explanations.

    -    //$this->messenger()->addStatus($this->t('Your username is @username', ['@username' => $form_state->getValue('name')]));
    +    // $this->messenger()->addStatus($this->t('Your username is @username', [
    +    // '@username' => $form_state->getValue('name')
    +    // ]));

    Commented out code still needs to be indented how code should be intended. (That means that '@username' => $form_state->getValue('name') must be indented by two spaces more.)
    I would rather remove that commented-out code as it seems more debugging code that should not be left in a public release.

    -    // replace default user login with a fake form.
    +    // Replace the default user login with a fake form.

    form is still missing after default user login.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India mrinalini9 New Delhi

    Updated patch #11 by addressing #13, please review it.

    Thanks!

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Fixed about 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024