coding standards and best practices

Created on 21 December 2022, almost 2 years ago
Updated 20 January 2023, almost 2 years ago

Problem/Motivation

Hi, While reviewing the module for best practices and standards. I have found several issues with the help of PHPCS.

FILE: /var/www/html/dcontri/age_verification/src/EventSubscriber/pathGate.php
--------------------------------------------------------------------------------------------------------
FOUND 56 ERRORS AND 5 WARNINGS AFFECTING 56 LINES
--------------------------------------------------------------------------------------------------------
   3 | ERROR   | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
   5 | ERROR   | [x] Doc comment short description must be on the first line
   8 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 1
  11 | WARNING | [x] Unused use statement
  22 | ERROR   | [ ] Class name doesn't match filename; expected "class pathGate"
  24 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  25 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  26 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  27 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  31 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  32 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  33 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  34 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  38 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  39 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  40 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  41 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  42 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  43 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  44 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  46 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  47 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  48 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 6
  48 | ERROR   | [x] Closing brace indented incorrectly; expected 2 spaces, found 6
  51 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  52 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
  54 | WARNING | [ ] Line exceeds 80 characters; contains 91 characters
  54 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  55 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  56 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  58 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  60 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  62 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  63 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  64 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
  65 | ERROR   | [x] Closing brace indented incorrectly; expected 8 spaces, found 4
  70 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
  75 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
  79 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
  92 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
  93 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
  94 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
  95 | ERROR   | [x] Closing brace indented incorrectly; expected 12 spaces, found 6
 100 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 117 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
 121 | WARNING | [ ] Line exceeds 80 characters; contains 93 characters
 123 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 124 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 125 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 10
 125 | ERROR   | [x] Closing brace indented incorrectly; expected 4 spaces, found 10
 127 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 128 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 10
 128 | ERROR   | [x] Closing brace indented incorrectly; expected 4 spaces, found 10
 132 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 137 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 10
 144 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
 145 | ERROR   | [x] Expected 3 space(s) before asterisk; 5 found
 147 | WARNING | [ ] Line exceeds 80 characters; contains 86 characters
 147 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 148 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 149 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
--------------------------------------------------------------------------------------------------------


FILE: /var/www/html/dcontri/age_verification/src/Form/AgeVerificationAdminForm.php
----------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------------------
  9 | ERROR | [x] Missing class doc comment
 13 | ERROR | [x] Expected 1 blank line before function; 0 found
----------------------------------------------------------------------------------


FILE: /var/www/html/dcontri/age_verification/src/Form/AgeVerificationForm.php
-----------------------------------------------------------------------------
FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES
-----------------------------------------------------------------------------
  7 | WARNING | [x] Unused use statement
  9 | ERROR   | [x] Missing class doc comment
 57 | ERROR   | [x] Short array syntax must be used to define arrays
 58 | ERROR   | [x] list(...) is forbidden, use [...] instead.
 85 | ERROR   | [ ] Unnecessarily gendered language in a comment
-----------------------------------------------------------------------------


FILE: /var/www/html/dcontri/age_verification/config/schema/age_verification.schema.yml
--------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------
 16 | ERROR | [x] Expected 1 newline at end of file; 2 found
--------------------------------------------------------------------------------------


FILE: /var/www/html/dcontri/age_verification/config/install/age_verification.settings.yml
-----------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------
 4 | ERROR | [x] Expected 1 newline at end of file; 2 found
-----------------------------------------------------------------------------------------


FILE: /var/www/html/dcontri/age_verification/age_verification.install
-----------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------
 1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
-----------------------------------------------------------------------------


FILE: /var/www/html/dcontri/age_verification/age_verification.module
---------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
---------------------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
 5 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
---------------------------------------------------------------------------------------------------------------------

I have fixed the above issues and have provided the patch.

The branch from which I am working is 8.x which is the latest branch.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India akshay.singh Noida

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.

No activities found.

Production build 0.71.5 2024