Fix the issues reported by phpcs

Created on 29 May 2023, over 1 year ago
Updated 22 February 2024, 9 months ago

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig shows the following errors/warnings that should be fixed.

FILE: ./www_authenticate/www_authenticate.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: ./www_authenticate/www_authenticate.info.yml
------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------
  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
 13 | ERROR   | [x] Expected 1 newline at end of file; 0 found
------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------


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


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


FILE: ./www_authenticate/src/WwwAuthenticateSubscriber.php
------------------------------------------------------------------------------------------------------------------------------
FOUND 26 ERRORS AND 5 WARNINGS AFFECTING 23 LINES
------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] The PHP open tag must be followed by exactly one blank line
  2 | ERROR   | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
 10 | WARNING | [x] Unused use statement
 18 | ERROR   | [ ] Doc comment short description must start with a capital letter
 19 | ERROR   | [x] There must be exactly one blank line before the tags in a doc comment
 19 | ERROR   | [ ] The @see reference should not contain any additional text
 21 | ERROR   | [ ] Parameter tags must be defined first in a doc comment
 24 | ERROR   | [ ] Public method name "WwwAuthenticateSubscriber::WwwAuthenticateLoad" is not in lowerCamel format
 24 | ERROR   | [x] Expected 1 blank line before function; 0 found
 27 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 41 | ERROR   | [x] Expected 1 space before "==="; 3 found
 45 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 2
 45 | ERROR   | [x] Closing brace indented incorrectly; expected 4 spaces, found 2
 45 | ERROR   | [x] Expected newline after closing brace
 47 | WARNING | [ ] Line exceeds 80 characters; contains 84 characters
 48 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 4
 49 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 4
 49 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 51 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 4
 52 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 4
 54 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 4
 56 | WARNING | [ ] Code after the EXIT statement on line 54 cannot be executed
 56 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 4
 57 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 2
 58 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 0
 58 | ERROR   | [x] Closing brace indented incorrectly; expected 2 spaces, found 0
 63 | ERROR   | [x] Visibility must be declared on method "getSubscribedEvents"
 65 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 66 | ERROR   | [x] Short array syntax must be used to define arrays
 69 | ERROR   | [x] Expected 1 newline at end of file; 0 found
 69 | ERROR   | [x] The closing brace for the class must have an empty line before it
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 23 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------


FILE: ./www_authenticate/src/Form/WwwAuthenticateForm.php
--------------------------------------------------------------------------------------------------------
FOUND 11 ERRORS AND 1 WARNING AFFECTING 12 LINES
--------------------------------------------------------------------------------------------------------
   3 | ERROR   | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
  12 | WARNING | [x] Unused use statement
  39 | ERROR   | [x] Short array syntax must be used to define arrays
  44 | ERROR   | [x] Short array syntax must be used to define arrays
  50 | ERROR   | [x] Short array syntax must be used to define arrays
  56 | ERROR   | [x] Short array syntax must be used to define arrays
  62 | ERROR   | [x] Short array syntax must be used to define arrays
  68 | ERROR   | [x] Short array syntax must be used to define arrays
  89 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
  90 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
  91 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
 100 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
--------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 12 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------

Time: 46ms; Memory: 10MB
๐Ÿ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia jayprakash.kushwah India

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 @jayprakash.kushwah
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    The issue summary should always describe what the issue is trying to fix and, in the case of coding standards issues, show which command and arguments have been used and which report that command shown.

  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India

    The provided patch doesn't apply. Providing an updated patch.

  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    When I run the reported command, I get more errors/warnings.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia mrinalini9 New Delhi

    Rerolled patch #6, please review it.

    Thanks!

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    -      // Authentication failed, print the authorization headers and end the request.
    -    $print = $config->get('message');
    -    $sitename = \Drupal::config('system.site')->get('name');
    +      // Authentication failed, print the authorization headers and end the
    +      // request.
    +      $print = $config->get('message');
    +      $sitename = \Drupal::config('system.site')->get('name');
    

    The sentence in the comment is an example of comma-splice sentence, which is grammatically not correct. Instead of the comma, the correct punctuation mark is either the semicolon or the period.

    -   * // only if KernelEvents::REQUEST !!!
    -   * @see Symfony\Component\HttpKernel\KernelEvents for details
    +   * Only if KernelEvents::REQUEST !!!
    +   *
    +   * @see Symfony\Component\HttpKernel\KernelEvents
        *
        * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
        *   The Event to process.

    Only if KernelEvents::REQUEST !!! is not necessary, since that is clear from the used code.
    The @see line must be after the @param line. The correct order is the following one.

    • @var
    • @param
    • @return
    • @throws
    • @ingroup
    • @deprecated
    • @see
    • @todo
    -    // Add WwwAuthenticateLoad as a subscriber to the request event.
    -    // $events[KernelEvents::REQUEST][] = array('WwwAuthenticateLoad', 20);
    -    $events[KernelEvents::REQUEST][] = array('WwwAuthenticateLoad');
    +  public static function getSubscribedEvents() {
    +    // Add wwwAuthenticateLoad as a subscriber to the request event.
    +    // $events[KernelEvents::REQUEST][] = array('wwwAuthenticateLoad', 20);.

    Periods are not added at the end of commented out code. That commented out line is not even necessary, like the comment before it.

  • 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 Fixed 9 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ตNepal sujan shrestha Nepal๐Ÿ‡ณ๐Ÿ‡ต, Kathmandu
  • Status changed to Fixed 9 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ตNepal sujan shrestha Nepal๐Ÿ‡ณ๐Ÿ‡ต, Kathmandu
Production build 0.71.5 2024