Fix coding standards after running Gitlab CI

Created on 27 January 2024, 10 months ago
Updated 8 July 2024, 4 months ago

We got the following reports after running Gitlab CI.

$ php vendor/bin/phpstan analyze $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $PHPSTAN_CONFIGURATION --no-progress || EXIT_CODE=$?
 ------ --------------------------------------------------------------------- 
  Line   activity.install                                                     
 ------ --------------------------------------------------------------------- 
  128    Function drupal_get_module_schema not found.                         
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
  129    Function _drupal_schema_initialize not found.                        
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
  131    Static call to instance method                                       
         Drupal\Core\Database\Schema::tableExists().                          
  132    Static call to instance method                                       
         Drupal\Core\Database\Schema::dropTable().                            
  134    Static call to instance method                                       
         Drupal\Core\Database\Schema::tableExists().                          
  135    Static call to instance method                                       
         Drupal\Core\Database\Schema::dropTable().                            
 ------ --------------------------------------------------------------------- 
 ------ ---------------------------------------------------------------------- 
  Line   src/Form/ActivityListForm.php                                         
 ------ ---------------------------------------------------------------------- 
  28     \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
  64     Function pager_default_initialize not found.                          
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols   
 ------ ---------------------------------------------------------------------- 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Form/ConfigureActivityForm.php                                            
 ------ ------------------------------------------------------------------------------ 
  109    Parameter $tree_builder of method                                             
         Drupal\activity\Form\ConfigureActivityForm::__construct() has invalid         
         type Drupal\token\TreeBuilderInterface.                                       
  110    Parameter $entity_mapper of method                                            
         Drupal\activity\Form\ConfigureActivityForm::__construct() has invalid         
         type Drupal\token\TokenEntityMapperInterface.                                 
  114    Parameter $tempStoreFactory of method                                         
         Drupal\activity\Form\ConfigureActivityForm::__construct() has invalid         
         type Drupal\user\PrivateTempStoreFactory.                                     
  133    Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
  167    \Drupal calls should be avoided in classes, use dependency injection          
         instead                                                                       
  168    \Drupal calls should be avoided in classes, use dependency injection          
         instead                                                                       
  211    Access to an undefined property                                               
         Drupal\activity\Form\ConfigureActivityForm::$options.                         
         💡 Learn more:                                                                
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  283    \Drupal calls should be avoided in classes, use dependency injection          
         instead                                                                       
  306    \Drupal calls should be avoided in classes, use dependency injection          
         instead                                                                       
  319    \Drupal calls should be avoided in classes, use dependency injection          
         instead                                                                       
  350    \Drupal calls should be avoided in classes, use dependency injection          
         instead                                                                       
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Form/CreateActivityForm.php                                               
 ------ ------------------------------------------------------------------------------ 
  27     Parameter $tempStoreFactory of method                                         
         Drupal\activity\Form\CreateActivityForm::__construct() has invalid            
         type Drupal\user\PrivateTempStoreFactory.                                     
  35     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ --------------------------------------------------------------------- 
  Line   src/Form/DeleteActionForm.php                                        
 ------ --------------------------------------------------------------------- 
  49     Function drupal_set_message not found.                               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
 ------ --------------------------------------------------------------------- 
 ------ --------------------------------------------------------------------- 
  Line   src/Form/DeleteActivityForm.php                                      
 ------ --------------------------------------------------------------------- 
  48     Function drupal_set_message not found.                               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
 ------ --------------------------------------------------------------------- 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Form/DeleteForm.php                                                       
 ------ ------------------------------------------------------------------------------ 
  51     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Form/MultiStepFormBase.php                                                
 ------ ------------------------------------------------------------------------------ 
  55     Parameter $temp_store_factory of method                                       
         Drupal\activity\Form\MultiStepFormBase::__construct() has invalid             
         type Drupal\user\PrivateTempStoreFactory.                                     
  67     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Plugin/views/query/ActivityPlugin.php                                     
 ------ ------------------------------------------------------------------------------ 
  95     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
  271    Caught class                                                                  
         Drupal\activity\Plugin\views\query\DatabaseExceptionWrapper not               
         found.                                                                        
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols           
  274    Function drupal_set_message not found.                                        
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols           
  277    Instantiated class                                                            
         Drupal\activity\Plugin\views\query\DatabaseExceptionWrapper not               
         found.                                                                        
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols           
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/QueryActivity.php                                                         
 ------ ------------------------------------------------------------------------------ 
  46     Parameter $container of method                                                
         Drupal\activity\QueryActivity::create() has invalid type                      
         Drupal\activity\ContainerInterface.                                           
  47     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
  121    \Drupal calls should be avoided in classes, use dependency injection          
         instead                                                                       
  139    \Drupal calls should be avoided in classes, use dependency injection          
         instead                                                                       
  250    \Drupal calls should be avoided in classes, use dependency injection          
         instead                                                                       
  261    \Drupal calls should be avoided in classes, use dependency injection          
         instead                                                                       
 ------ ------------------------------------------------------------------------------ 
$ vendor/bin/phpcs -s $_WEB_ROOT/modules/custom --report-junit=junit.xml --report-full --report-summary --report-source
FILE: ...vity/web/modules/custom/activity/src/Plugin/views/query/ActivityPlugin.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
 178 | WARNING | [x] '@todo: Maybe it would make sense to just add an
     |         |     addOrderByRand or something similar.' should match the
     |         |     format '@todo Fix problem X here.'
     |         |     (Drupal.Commenting.TodoComment.TodoFormat)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...tivity/web/modules/custom/activity/src/Plugin/views/field/DeleteAction.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 8 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Link.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...uilds/project/activity/web/modules/custom/activity/src/Form/DeleteForm.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is Drupal\Core\Database\Connection.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
 24 | ERROR | [ ] Missing member variable doc comment
    |       |     (Drupal.Commenting.VariableComment.Missing)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...oject/activity/web/modules/custom/activity/src/Form/CreateActivityForm.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
 27 | WARNING | Possible useless method overriding detected
    |         | (Generic.CodeAnalysis.UselessOverridingMethod.Found)
--------------------------------------------------------------------------------
FILE: ...ct/activity/web/modules/custom/activity/src/Form/ConfigureActivityForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is Drupal\token\TokenEntityMapperInterface.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
Time: 228ms; Memory: 6MB
PHP CODE SNIFFER REPORT SUMMARY
--------------------------------------------------------------------------------
FILE                                                            ERRORS  WARNINGS
--------------------------------------------------------------------------------
.../modules/custom/activity/src/Form/ConfigureActivityForm.php  1       0
...web/modules/custom/activity/src/Form/CreateActivityForm.php  0       1
...ctivity/web/modules/custom/activity/src/Form/DeleteForm.php  2       0
...les/custom/activity/src/Plugin/views/field/DeleteAction.php  1       0
...s/custom/activity/src/Plugin/views/query/ActivityPlugin.php  0       1
--------------------------------------------------------------------------------
A TOTAL OF 4 ERRORS AND 2 WARNINGS WERE FOUND IN 13 FILES
--------------------------------------------------------------------------------
PHPCBF CAN FIX 4 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
--------------------------------------------------------------------------------
    SOURCE                                                                 COUNT
--------------------------------------------------------------------------------
[x] SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.Incorrectl  3
[x] Drupal.Commenting.TodoComment.TodoFormat                               1
[ ] Drupal.Commenting.VariableComment.Missing                              1
[ ] Generic.CodeAnalysis.UselessOverridingMethod.Found                     1
--------------------------------------------------------------------------------
A TOTAL OF 6 SNIFF VIOLATIONS WERE FOUND IN 4 SOURCES
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SOURCES AUTOMATICALLY (4 VIOLATIONS IN TOTAL)
--------------------------------------------------------------------------------
/builds/project/activity/web/modules/custom/activity/activity.permissions.yml
  2:1  error  Expected indentation of 2 spaces but found 4 spaces  yml/indent
  3:1  error  Expected indentation of 2 spaces but found 4 spaces  yml/indent
  4:1  error  Expected indentation of 2 spaces but found 4 spaces  yml/indent
  7:1  error  Expected indentation of 2 spaces but found 4 spaces  yml/indent
  8:1  error  Expected indentation of 2 spaces but found 4 spaces  yml/indent
  9:1  error  Expected indentation of 2 spaces but found 4 spaces  yml/indent
🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇺🇦Ukraine _shy Ukraine, Lutsk 🇺🇦

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

Comments & Activities

Production build 0.71.5 2024