Fix coding standard issue | PHPCS

Created on 3 February 2023, almost 2 years ago
Updated 30 August 2024, 4 months ago

Problem/Motivation

Fix the following coding standard issue.

FILE: /Applications/MAMP/htdocs/d9/web/modules/contrib/logintoboggan/logintoboggan.module
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
96 | ERROR | The array declaration extends to column 229 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------

FILE: /Applications/MAMP/htdocs/d9/web/modules/contrib/logintoboggan/logintoboggan.tokens.inc
---------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 4 LINES
---------------------------------------------------------------------------------------------
14 | ERROR | [x] Short array syntax must be used to define arrays
24 | ERROR | [x] Short array syntax must be used to define arrays
24 | ERROR | [x] Short array syntax must be used to define arrays
25 | ERROR | [x] Short array syntax must be used to define arrays
27 | ERROR | [x] Short array syntax must be used to define arrays
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------

FILE: /Applications/MAMP/htdocs/d9/web/modules/contrib/logintoboggan/logintoboggan.install
------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
6 | ERROR | [ ] Empty installation hooks are not necessary
------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------

FILE: /Applications/MAMP/htdocs/d9/web/modules/contrib/logintoboggan/src/Access/LogintobogganReValidateAccess.php
-----------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
33 | ERROR | [x] Each PHP statement must be on a line by itself
-----------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------

FILE: /Applications/MAMP/htdocs/d9/web/modules/contrib/logintoboggan/src/Plugin/Block/LogintobogganLoginBlock.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
-------------------------------------------------------------------------------------------------------------------------------------------
89 | ERROR | [x] Use null coalesce operator instead of ternary operator.
96 | ERROR | [x] Use null coalesce operator instead of ternary operator.
136 | ERROR | [ ] The array declaration extends to column 122 (the limit is 80). The array content should be split up over multiple lines
192 | ERROR | [ ] The array declaration extends to column 121 (the limit is 80). The array content should be split up over multiple lines
-------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------

FILE: /Applications/MAMP/htdocs/d9/web/modules/contrib/logintoboggan/src/Utility/LogintobogganUtility.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
46 | ERROR | [x] Use null coalesce operator instead of ternary operator.
47 | ERROR | [x] Use null coalesce operator instead of ternary operator.
49 | ERROR | [ ] The array declaration extends to column 93 (the limit is 80). The array content should be split up over multiple lines
-----------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY

๐Ÿ“Œ Task
Status

Needs work

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia noorulshameera

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @noorulshameera
  • Status changed to Needs review almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia noorulshameera

    Adding patch to fix PHPCS issues.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

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

  • Assigned to Charchil Khandelwal
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    I will review this.

  • Status changed to Needs work almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    C:\xampp\htdocs\abc\drupal\modules>phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml logintoboggan

    FILE: C:\xampp\htdocs\abc\drupal\modules\logintoboggan\INSTALL.txt
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 7 WARNINGS AFFECTING 7 LINES
    ----------------------------------------------------------------------
    55 | WARNING | Line exceeds 80 characters; contains 83 characters
    56 | WARNING | Line exceeds 80 characters; contains 82 characters
    57 | WARNING | Line exceeds 80 characters; contains 90 characters
    59 | WARNING | Line exceeds 80 characters; contains 84 characters
    62 | WARNING | Line exceeds 80 characters; contains 91 characters
    63 | WARNING | Line exceeds 80 characters; contains 99 characters
    64 | WARNING | Line exceeds 80 characters; contains 95 characters
    ----------------------------------------------------------------------

    FILE: ...mpp\htdocs\abc\drupal\modules\logintoboggan\logintoboggan.module
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------
    50 | WARNING | Unused variable $k.
    ----------------------------------------------------------------------

    FILE: C:\xampp\htdocs\abc\drupal\modules\logintoboggan\README.txt
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 12 WARNINGS AFFECTING 12 LINES
    ----------------------------------------------------------------------
    8 | WARNING | Line exceeds 80 characters; contains 81 characters
    9 | WARNING | Line exceeds 80 characters; contains 84 characters
    10 | WARNING | Line exceeds 80 characters; contains 85 characters
    11 | WARNING | Line exceeds 80 characters; contains 87 characters
    39 | WARNING | Line exceeds 80 characters; contains 89 characters
    40 | WARNING | Line exceeds 80 characters; contains 86 characters
    41 | WARNING | Line exceeds 80 characters; contains 91 characters
    42 | WARNING | Line exceeds 80 characters; contains 91 characters
    43 | WARNING | Line exceeds 80 characters; contains 91 characters
    44 | WARNING | Line exceeds 80 characters; contains 94 characters
    45 | WARNING | Line exceeds 80 characters; contains 95 characters
    46 | WARNING | Line exceeds 80 characters; contains 88 characters
    ----------------------------------------------------------------------

    FILE: ...modules\logintoboggan\src\Controller\LogintobogganController.php
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
    ----------------------------------------------------------------------
    15 | WARNING | The class short comment should describe what the
    | | class does and not simply repeat the class name
    35 | WARNING | Unused variable $hash_2.
    43 | WARNING | Unused variable $stop.
    ----------------------------------------------------------------------

    Time: 909ms; Memory: 12MB

    Need to fix these errors and warnings.

  • @charchil-khandelwal opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    All the errors and warnings are fixed now.
    Created MR for same, please review.

    Thank You.

  • Status changed to Needs work 5 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines cleavinjosh

    Hi @Charchil Khandelwal,

    I applied MR!2, it was applied smoothly and fixed most of the phpcs issues.

    These are the remaining issues after I ran phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml:

    โžœ  logintoboggan git:(8.x-1.x) curl https://git.drupalcode.org/project/logintoboggan/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 14437    0 14437    0     0  32587      0 --:--:-- --:--:-- --:--:-- 32662
    patching file INSTALL.txt
    patching file README.txt
    patching file logintoboggan.install
    patching file logintoboggan.links.menu.yml
    patching file logintoboggan.module
    patching file logintoboggan.routing.yml
    patching file logintoboggan.tokens.inc
    patching file src/Access/LogintobogganReValidateAccess.php
    patching file src/Controller/LogintobogganController.php
    patching file src/Plugin/Block/LogintobogganLoginBlock.php
    patching file src/Utility/LogintobogganUtility.php
    โžœ  logintoboggan git:(8.x-1.x) โœ— ..
    โžœ  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml logintoboggan
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/logintoboggan/logintoboggan.module
    -----------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------
     18 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Link.
    -----------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/logintoboggan/css/logintoboggan.css
    --------------------------------------------------------------------------------------------------------
    FOUND 6 ERRORS AFFECTING 5 LINES
    --------------------------------------------------------------------------------------------------------
      1 | ERROR | [x] Additional whitespace found at start of file
     22 | ERROR | [x] CSS colours must be defined in lowercase; expected #fff19a but found #FFF19A
     24 | ERROR | [x] Expected 1 newline at end of file; 5 found
     27 | ERROR | [ ] More than 2 empty lines are not allowed
     28 | ERROR | [ ] More than 2 empty lines are not allowed
     28 | ERROR | [x] Additional whitespace found at end of file
    --------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/logintoboggan/css/logintoboggan-rtl.css
    ------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ------------------------------------------------------------------------------------------------------------
     1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
     4 | ERROR | [x] Expected 1 newline at end of file; 0 found
    ------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/logintoboggan/src/Form/LogintobogganProfileForm.php
    ------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------
     7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Link.
    ------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/logintoboggan/src/Form/LogintobogganRegister.php
    ---------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------
     8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Url.
    ---------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/logintoboggan/src/Form/LogintobogganHelpForm.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/logintoboggan/src/Form/LogintobogganSettingsForm.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
     7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/logintoboggan/src/Access/LogintobogganValidateAccess.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
     11 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Symfony\Component\HttpFoundation\Request.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/logintoboggan/src/Plugin/Block/LoginTobogganloggedBlock.php
    --------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------------
     9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Plugin\ContainerFactoryPluginInterface.
    --------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/logintoboggan/src/Plugin/Block/LogintobogganLoginBlock.php
    -------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------
     10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Utility\Xss.
    -------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/logintoboggan/src/Controller/LogintobogganController.php
    -------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------
     8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Controller\ControllerBase.
    -------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------
    
    Time: 518ms; Memory: 12MB
    
    โžœ  contrib

    Thank you.

  • First commit to issue fork.
Production build 0.71.5 2024