Fix the issues reported by phpcs

Created on 1 March 2023, almost 2 years ago
Updated 3 March 2023, almost 2 years ago

Problem/Motivation

Getting following error/warnings.

FILE: /var/www/html/modules/contrib/login_switch/src/Form/LoginSwitchSettingsForm.php
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 17 ERRORS AFFECTING 8 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
17 | ERROR | [ ] Missing short description in doc comment
18 | ERROR | [x] Expected "\Drupal\Core\ProxyClass\Routing\RouteBuilder" but found "\Drupal\Core\ProxyClass\Routing\RouteBuilder." for @var tag in member variable comment
76 | ERROR | [x] Comma not allowed after last value in single-line array declaration
76 | ERROR | [x] Expected one space after the comma, 0 found
80 | ERROR | [ ] The array declaration extends to column 81 (the limit is 80). The array content should be split up over multiple lines
80 | ERROR | [x] Comma not allowed after last value in single-line array declaration
80 | ERROR | [x] Expected one space after the comma, 0 found
81 | ERROR | [ ] The array declaration extends to column 126 (the limit is 80). The array content should be split up over multiple lines
81 | ERROR | [x] Comma not allowed after last value in single-line array declaration
81 | ERROR | [x] Expected one space after the comma, 0 found
86 | ERROR | [x] Comma not allowed after last value in single-line array declaration
86 | ERROR | [x] Expected one space after the comma, 0 found
98 | ERROR | [x] Comma not allowed after last value in single-line array declaration
98 | ERROR | [x] Expected one space after the comma, 0 found
99 | ERROR | [ ] The array declaration extends to column 124 (the limit is 80). The array content should be split up over multiple lines
99 | ERROR | [x] Comma not allowed after last value in single-line array declaration
99 | ERROR | [x] Expected one space after the comma, 0 found
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 13 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/login_switch/src/Routing/LoginSwitchRouteSubscriber.php
-------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------
14 | ERROR | Missing member variable doc comment
-------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/login_switch/src/Routing/ExceptionEventSubscriber.php
--------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AND 2 WARNINGS AFFECTING 8 LINES
--------------------------------------------------------------------------------------------------
7 | WARNING | [x] Unused use statement
12 | ERROR | [x] Missing class doc comment
12 | ERROR | [x] Expected 1 space before opening brace; found 2
14 | ERROR | [ ] Missing member variable doc comment
26 | ERROR | [ ] Missing parameter comment
27 | ERROR | [ ] Missing parameter comment
39 | ERROR | [x] Array indentation error, expected 6 spaces but found 8
43 | ERROR | [x] Missing function doc comment
43 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
44 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
--------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/login_switch/src/EventSubscriber/AddNoIndexHeader.php
------------------------------------------------------------------------------------------------------------------------------
FOUND 46 ERRORS AND 1 WARNING AFFECTING 33 LINES
------------------------------------------------------------------------------------------------------------------------------
8 | ERROR | [x] There must be one blank line after the last USE statement; 2 found;
11 | ERROR | [x] Missing class doc comment
13 | ERROR | [ ] Missing member variable doc comment
31 | ERROR | [x] Expected 1 blank line after function; 2 found
35 | ERROR | [x] Expected 3 space(s) before asterisk; 2 found
35 | ERROR | [x] Doc comment short description must end with a full stop
36 | ERROR | [x] Expected 3 space(s) before asterisk; 2 found
37 | ERROR | [x] Expected 3 space(s) before asterisk; 2 found
37 | ERROR | [ ] Missing parameter comment
37 | ERROR | [x] Data types in @param tags need to be fully namespaced
38 | ERROR | [x] Expected 3 space(s) before asterisk; 2 found
39 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
40 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
40 | ERROR | [x] Opening brace should be on the same line as the declaration
41 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 3
42 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 5
43 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 3
45 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 3
45 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
46 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 3
47 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 3
49 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 3
49 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
50 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 3
51 | ERROR | [x] Array indentation error, expected 5 spaces but found 7
52 | ERROR | [x] Array indentation error, expected 5 spaces but found 7
53 | ERROR | [x] Array indentation error, expected 5 spaces but found 7
54 | ERROR | [x] Array closing indentation error, expected 3 spaces but found 5
56 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 5
56 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
57 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 5
57 | ERROR | [x] Expected 1 space after IF keyword; 0 found
58 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 7
59 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 7
59 | ERROR | [x] Expected 1 space after IF keyword; 0 found
60 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 9
60 | ERROR | [x] Expected 1 space after IF keyword; 0 found
61 | ERROR | [x] Line indented incorrectly; expected 10 spaces, found 11
62 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 9
63 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 7
64 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 5
65 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 3
65 | ERROR | [x] Closing brace indented incorrectly; expected 1 spaces, found 3
65 | ERROR | [x] Expected 1 blank line after function; 0 found
66 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 1
66 | ERROR | [x] The closing brace for the class must have an empty line before it
66 | ERROR | [x] Closing brace indented incorrectly; expected 0 spaces, found 1
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 44 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------

Time: 4.95 secs; Memory: 6MB

Steps to reproduce

Run following command

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/login_switch/

Proposed resolution

Above error/warnings need to be fixed.

๐Ÿ“Œ Task
Status

Needs work

Version

3.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia samit.310@gmail.com

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 @samit.310@gmail.com
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia samit.310@gmail.com

    Above error/warnings are fixed.

  • Status changed to RTBC almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sourabhjain

    Reviewed the patch #2. It looking fine.
    Moving to RTBC.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rassoni Bangalore

    Rashmisoni โ†’ made their first commit to this issueโ€™s fork.

  • @rashmisoni opened merge request.
  • Status changed to Needs work almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +   * @param \Drupal\Core\Routing\RouteMatchInterface $routeMatch
    +   *   The RouteMatch service.

    The service description can be better.

    +   * Add noindex Headers.
    +   *
    +   * @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event
    +   *   The Response Event.
    +   */

    Headers and Event are not at the beginning of the sentence.

    +    // Get Configuration & Event Response.
    +    $config = $this->configFactory->get('login_switch.settings');
    +    $response = $event->getResponse();
    

    That comment does not explain anything the code does not make already clear. Since those lines are edited, the comment can be removed.

    -   * @var \Drupal\Core\ProxyClass\Routing\RouteBuilder.
    +   * The routerBuilder.

    Repeating the class name, even with a different spelling, is not adding a documentation comment for a class property.

    +        '#title' => $this->t('Disable default user/@key route', ['@key' => $key]),
    

    The article is missing.

    +/**
    + * The ExceptionEventSubscriber Class.
    + */
    +class ExceptionEventSubscriber implements EventSubscriberInterface {
    

    Repeating the class name is not documenting a class. When class is not at the beginning of a sentence, it is not written in capital case.

    +  /**
    +   * The onException function.
    +   */

    That simply repeats the method name (and calls it function).

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rassoni Bangalore

    Fixed 1,3,4 feedback.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kkalashnikov Ghaziabad, India
  • Status changed to Needs review almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kkalashnikov Ghaziabad, India
  • Status changed to Needs work almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    Neither one or the other of those patches fix what reported.

Production build 0.71.5 2024