Improving the source code style to get the security advisory coverage

Created on 7 August 2023, over 1 year ago
Updated 8 August 2023, over 1 year ago

Problem/Motivation

To get the security advisory coverage, the php code sniffer is used to improve some code syntax.
Link to Issue

After the installation and execution of the command
phpcs --standard=Drupal,DrupalPractice web/modules/contrib/ckeditor5_template/

we get following output:

FILE: /var/www/html/docport/web/modules/contrib/ckeditor5_template/src/Plugin/CKEditor5Plugin/Template.php
---------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 12 ERRORS AND 3 WARNINGS AFFECTING 14 LINES
---------------------------------------------------------------------------------------------------------------------------------------------------------------
 10 | WARNING | [x] Unused use statement
 12 | ERROR   | [x] There must be one blank line after the last USE statement; 2 found;
 15 | ERROR   | [x] Missing class doc comment
 18 | ERROR   | [x] Whitespace found at end of line
 20 | ERROR   | [x] Expected 3 space(s) before asterisk; 1 found
 21 | ERROR   | [x] Expected 3 space(s) before asterisk; 1 found
 22 | ERROR   | [x] Expected 3 space(s) before asterisk; 1 found
 23 | ERROR   | [x] Expected 3 space(s) before asterisk; 1 found
 31 | WARNING | [ ] #description values usually have to run through t() for translation
 36 | ERROR   | [x] Expected 1 blank line after function; 2 found
 46 | ERROR   | [x] Expected 1 blank line after function; 2 found
 54 | ERROR   | [x] Expected 1 blank line after function; 2 found
 70 | WARNING | [x] A comma should follow the last multiline array item. Found: '/modules/contrib/ckeditor5_template/template/ckeditor5_template.json.example'
 73 | ERROR   | [x] Expected 1 newline at end of file; 0 found
 73 | ERROR   | [x] The closing brace for the class must have an empty line before it
---------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 14 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/docport/web/modules/contrib/ckeditor5_template/js/ckeditor5_plugins/template/src/template.js
----------------------------------------------------------------------------------------------------------------
FOUND 15 ERRORS AFFECTING 14 LINES
----------------------------------------------------------------------------------------------------------------
 10 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
 16 | ERROR | [x] Whitespace found at end of line
 17 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 22 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 24 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 35 | ERROR | [x] Space before opening parenthesis of function call prohibited
 36 | ERROR | [x] Space before opening parenthesis of function call prohibited
 37 | ERROR | [x] Whitespace found at end of line
 38 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 38 | ERROR | [x] Whitespace found at end of line
 53 | ERROR | [x] Space before opening parenthesis of function call prohibited
 61 | ERROR | [x] Whitespace found at end of line
 63 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
 64 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
 69 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 15 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/docport/web/modules/contrib/ckeditor5_template/js/template.js
---------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------
 1 | WARNING | File appears to be minified and cannot be processed
---------------------------------------------------------------------------------


FILE: /var/www/html/docport/web/modules/contrib/ckeditor5_template/css/layout.css
---------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------------
 2 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
 2 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
 3 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
 3 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
 4 | ERROR | [x] Expected 1 newline at end of file; 0 found
---------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------


FILE: /var/www/html/docport/web/modules/contrib/ckeditor5_template/css/admin.css
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] Additional whitespace found at start of file
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: /var/www/html/docport/web/modules/contrib/ckeditor5_template/webpack.config.js
---------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------------------------
 20 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 25 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
 29 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------

Time: 300ms; Memory: 10MB

Steps to reproduce

Install phpcs and run phpcs --standard=Drupal,DrupalPractice web/modules/contrib/ckeditor5_template/

Proposed resolution

No more entries

Remaining tasks

Fix errors and warnings using the instructions.
Using the PHPCBF (PHP Code Beautifier and Fixer) might be helpful.

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇩🇪Germany vincent.hoehn Dresden, Germany

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

Comments & Activities

  • Issue created by @vincent.hoehn
  • Status changed to Fixed over 1 year ago
  • 🇩🇪Germany vincent.hoehn Dresden, Germany

    So far, all errors and warnings have been fixed. The output of the command now looks like this:

    FILE: /var/www/html/docport/web/modules/contrib/ckeditor5_template/js/ckeditor5_plugins/template/src/template.js
    ----------------------------------------------------------------------------------------------------------------
    FOUND 5 ERRORS AFFECTING 5 LINES
    ----------------------------------------------------------------------------------------------------------------
     20 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
     22 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
     36 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
     60 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
     61 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    ----------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/docport/web/modules/contrib/ckeditor5_template/js/template.js
    ---------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    ---------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/docport/web/modules/contrib/ckeditor5_template/webpack.config.js
    ---------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AFFECTING 3 LINES
    ---------------------------------------------------------------------------------------------
     20 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
     25 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
     29 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    ---------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------
    
    Time: 256ms; Memory: 10MB

    The coding standards refer mostly to the extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml
    js files are not included. If the "errors" were fixed with the instructions, the module would not work. The build process does not work at all.

    So I think we have solved that.

  • Status changed to Fixed over 1 year ago
  • 🇩🇪Germany dbielke1986

    @vishal.kadam has confirmed that everything is OK now.

    Great work!

  • 🇩🇪Germany vincent.hoehn Dresden, Germany
  • 🇩🇪Germany vincent.hoehn Dresden, Germany
Production build 0.71.5 2024