Fix the errors/warnings reported by PHP_CodeSniffer

Created on 2 May 2024, 7 months ago
Updated 12 June 2024, 6 months ago

Problem/Motivation

When running the theme's code against Drupal coding standards based on Drupal standard, the theme shows errors

Steps to reproduce

Run the command:

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

Proposed resolution

Fix the following coding standards issues and create an MR with fixes.

FILE: /app/web/themes/contrib/da_vinci/da_vinci.theme
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\Form\FormStateInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: /app/web/themes/contrib/da_vinci/subtheme/subtheme.theme
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\Form\FormStateInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: /app/web/themes/contrib/da_vinci/subtheme/subtheme.info
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | ERROR | "name" property is missing in the info file
 1 | ERROR | "description" property is missing in the info file
 1 | ERROR | "core" property is missing in the info file
----------------------------------------------------------------------

Time: 109ms; Memory: 12MB
๐Ÿ“Œ Task
Status

RTBC

Version

9.1

Component

Code

Created by

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

Merge Requests

Comments & Activities

  • Issue created by @sourojeetpaul
  • Issue was unassigned.
  • Status changed to Needs review 7 months ago
  • Hi,
    I've fixed the errors/warnings reported by Phpcs. Also noticed that the subtheme.info file was not correctly named, so renamed it so that it can be detected as a valid yml file!

    Raised an MR addressing these. Please have a look:
    https://git.drupalcode.org/project/da_vinci/-/merge_requests/2

  • Status changed to Needs work 7 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines clarkssquared

    Hi

    I applied the MR !2 and I can still see many PHPCS issues and errors

    โžœ  da_vinci git:(9.1.0-beta2) curl https://git.drupalcode.org/project/da_vinci/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  1187    0  1187    0     0   2214      0 --:--:-- --:--:-- --:--:--  2235
    patching file da_vinci.theme
    patching file 'subtheme/subtheme.theme'
    โžœ  da_vinci git:(9.1.0-beta2) โœ— ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml da_vinci 
    
    FILE: ...g/Projects/d9/d9-local/web/themes/contrib/da_vinci/subtheme/subtheme.theme
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
    --------------------------------------------------------------------------------
      8 | WARNING | [x] Unused use statement
      9 | WARNING | [x] Unused use statement
     10 | WARNING | [x] Unused use statement
     11 | WARNING | [x] Unused use statement
     12 | WARNING | [x] Unused use statement
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...ng/Projects/d9/d9-local/web/themes/contrib/da_vinci/subtheme/subtheme.info
    --------------------------------------------------------------------------------
    FOUND 3 ERRORS AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | ERROR | "name" property is missing in the info file
     1 | ERROR | "description" property is missing in the info file
     1 | ERROR | "core" property is missing in the info file
    --------------------------------------------------------------------------------
    
    
    FILE: ...-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/da_vinci.info.yml
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | WARNING | Remove "version" from the info file, it will be added by
       |         | drupal.org packaging automatically
    --------------------------------------------------------------------------------
    
    
    FILE: ...ubing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/maintenance.css
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    --------------------------------------------------------------------------------
    
    
    FILE: ...ing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/user-password.css
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    --------------------------------------------------------------------------------
    
    
    FILE: ...ubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/main.css
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    --------------------------------------------------------------------------------
    
    
    FILE: ...bing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/README.md
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     10 | WARNING | Line exceeds 80 characters; contains 81 characters
    --------------------------------------------------------------------------------
    
    
    FILE: ...ing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/user-register.css
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    --------------------------------------------------------------------------------
    
    
    FILE: ...subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/user-login.css
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    --------------------------------------------------------------------------------
    
    
    FILE: ...Projects/d9/d9-local/web/themes/contrib/da_vinci/css/pages/maintenance.css
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    --------------------------------------------------------------------------------
    
    
    FILE: ...ojects/d9/d9-local/web/themes/contrib/da_vinci/css/pages/user-password.css
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    --------------------------------------------------------------------------------
    
    
    FILE: ...ojects/d9/d9-local/web/themes/contrib/da_vinci/css/pages/user-register.css
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    --------------------------------------------------------------------------------
    
    
    FILE: .../Projects/d9/d9-local/web/themes/contrib/da_vinci/css/pages/user-login.css
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    --------------------------------------------------------------------------------
    
    Time: 375ms; Memory: 12MB
    
    โžœ  contrib git:(master) โœ— 
    
  • ๐Ÿ‡ช๐Ÿ‡ธSpain nesta_

    Very good observation, if it is possible to fix it in the dev branch (9.1.x)

  • Status changed to Needs review 6 months ago
  • Hi, @clarkssquared
    After applying the patch that I provided I'm not getting any error. Also sorry for the confusion, the MR was actually raised for the dev version.
    And as suggested by @nesta_ it'll be better if we solve issues in dev version which can then be checked and approved and ported to the beta version.
    I see you're applying the patch in the beta version of the theme, So pls check once by applying the patch in dev version, I think the issues you're getting will be resolved. Once again sorry for the confusion regarding version.

    @nesta_ On the branch list in gitlab I can see the parent branch only which is 9.1.x, there's no corresponding dev branch. Though there exist a tag for the same(9.1.x-dev), In general we raise MRs against branch and not the tag, as far as I know. Pls correct me if I'm wrong. So I'm changing the version component now to dev to avoid any further confusion.

  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines clarkssquared

    Hi

    I applied the MR !2 into 9.1.x-dev version ( it says 9.1.x in my terminal) and I can still see this phpcs issues

    โžœ  da_vinci git:(9.1.x) curl https://git.drupalcode.org/project/da_vinci/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  1187    0  1187    0     0   2375      0 --:--:-- --:--:-- --:--:--  2412
    patching file da_vinci.theme
    patching file 'subtheme/subtheme.theme'
    โžœ  da_vinci git:(9.1.x) โœ— ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml da_vinci 
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/subtheme/subtheme.theme
    --------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
    --------------------------------------------------------------------------------------------------------
      8 | WARNING | [x] Unused use statement
      9 | WARNING | [x] Unused use statement
     10 | WARNING | [x] Unused use statement
     11 | WARNING | [x] Unused use statement
     12 | WARNING | [x] Unused use statement
    --------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/subtheme/subtheme.info
    -------------------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------
     1 | ERROR | "name" property is missing in the info file
     1 | ERROR | "description" property is missing in the info file
     1 | ERROR | "core" property is missing in the info file
    -------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/da_vinci.info.yml
    -----------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------
     1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    -----------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/maintenance.css
    ----------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    ----------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/user-password.css
    ------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    ------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/main.css
    ---------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    ---------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/README.md
    ----------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------
     10 | WARNING | Line exceeds 80 characters; contains 81 characters
    ----------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/user-register.css
    ------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    ------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/user-login.css
    ---------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    ---------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/pages/maintenance.css
    ----------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    ----------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/pages/user-password.css
    ------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    ------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/pages/user-register.css
    ------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    ------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/themes/contrib/da_vinci/css/pages/user-login.css
    ---------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------
     1 | WARNING | File appears to be minified and cannot be processed
    ---------------------------------------------------------------------------------------------------------
    
    Time: 348ms; Memory: 12MB
    
    โžœ  contrib git:(master) โœ— 
    
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

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

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

    I have fixed below issue, Please review

    modules/custom/da_vinci/
    
    FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/da_vinci/css/README.md
    -------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------
     10 | WARNING | Line exceeds 80 characters; contains 81 characters
    -------------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/da_vinci/da_vinci.info.yml
    -----------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------
     1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    -----------------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/da_vinci/subtheme/subtheme.info.yml
    --------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------
     1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    --------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/da_vinci/subtheme/subtheme.theme
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
    -----------------------------------------------------------------------------------------------------------------------
      8 | WARNING | [x] Unused use statement
      9 | WARNING | [x] Unused use statement
     10 | WARNING | [x] Unused use statement
     11 | WARNING | [x] Unused use statement
     12 | WARNING | [x] Unused use statement
    -----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------
    
    Time: 137ms; Memory: 12MB
    
  • Status changed to RTBC 6 months ago
  • Hello @silvi.addweb,
    Thanks for the efforts. After your recent commit the patch completely resolves all the remaining Phpcs issues.
    Hence moving it to RTBC++

Production build 0.71.5 2024