Problem/Motivation
Getting following error/warnings.
FILE: /var/www/html/modules/contrib/ayrshare/modules/ayrshare_node/src/Form/SettingsForm.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
87 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/ayrshare/modules/ayrshare_node/src/Plugin/views/field/UnserializedData.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------
21 | ERROR | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
-------------------------------------------------------------------------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/ayrshare/modules/ayrshare_node/src/Controller/NodeController.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
24 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/ayrshare/src/AyrshareApiClient.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------------
145 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
638 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
646 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------
Time: 1.58 secs; Memory: 8MB
Steps to reproduce
Run following command
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/ayrshare/
Proposed resolution
Above error/warnings need to be fixed.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | phpcs-issue-fixes-3352835-5.patch | 3.75 KB | ashutosh ahirwal |
| #3 | with patch.png | 193.31 KB | kenyoowen |
| #3 | without patch.png | 279.32 KB | kenyoowen |
| #2 | 3352835-2.patch | 5.9 KB | samitk |
Issue fork ayrshare-3352835
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
samitk commentedAbove errors/warnings has been fixed.
Comment #3
kenyoowen commentedHi samit.310@gmail.com
I applied patch #2 to the “Ayrshare” module against Version 1.0.x-dev and confirmed that the error and warnings are resolved. Please see the screenshots attached.
For your review.
Thank you.
Comment #4
avpadernoSince the
@returnline has been changed, also the return value description must be changed: What returned is not a Hello string.Comment #5
ashutosh ahirwal commentedProviding patch with fixes.
Comment #7
naveenvalechaComment #10
naveenvalecha