Fix the issues reported by phpcs

Created on 2 March 2023, over 1 year ago
Updated 18 March 2023, over 1 year ago

Problem/Motivation

FILE: /var/www/html/drupal9/web/modules/contrib/likeit/src/Entity/LikeIt.php
-------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------
160 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
-------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------

FILE: /var/www/html/drupal9/web/modules/contrib/likeit/src/Controller/LikeItController.php
------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------
18 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
195 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupal9/web/modules/contrib/likeit/src/Form/LikeItSettingsForm.php
----------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------
18 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
173 | ERROR | [x] Use null coalesce operator instead of ternary operator.
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupal9/web/modules/contrib/likeit/likeit.info.yml
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
-------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupal9/web/modules/contrib/likeit/likeit.module
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
432 | ERROR | The $_COOKIE super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->cookies->get('likeit_session') instead
442 | ERROR | The $_COOKIE super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->cookies->get('likeit_session') instead
442 | ERROR | The $_COOKIE super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->cookies->get('likeit_session') instead
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 597ms; Memory: 14MB

Steps to reproduce

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig web/modules/contrib/likeit/

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

2.1

Component

Code

Created by

🇮🇳India indrapatil Bangalore

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

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.

  • Issue created by @indrapatil
  • Assigned to indrapatil
  • Status changed to Needs work over 1 year ago
  • 🇮🇳India indrapatil Bangalore

    I am working on it.

  • @indra-patil opened merge request.
  • Issue was unassigned.
  • 🇮🇳India indrapatil Bangalore

    Hi,
    Still we have this errors to work

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

    FILE: /var/www/html/drupal9/likeit-3345426/likeit.module
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    432 | ERROR | The $_COOKIE super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->cookies->get('likeit_session') instead
    442 | ERROR | The $_COOKIE super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->cookies->get('likeit_session') instead
    442 | ERROR | The $_COOKIE super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->cookies->get('likeit_session') instead
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Time: 572ms; Memory: 14MB

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Assigned to imustakim
  • 🇮🇳India imustakim Ahmedabad

    working on this.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India imustakim Ahmedabad

    Added a patch for fixes.
    Please review.

  • Status changed to Needs work over 1 year ago
  • 🇺🇦Ukraine andrew_tspkh

    @imustakim, please have a look on this code:

    $stack->getCurrentRequest()->cookies->get('likeit_session') = $session_id;
    

    Can't use method return value in write context.

  • Assigned to imustakim
  • 🇮🇳India imustakim Ahmedabad

    Updating the patch.

  • 🇮🇳India imustakim Ahmedabad

    Patch updated.
    Please review.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India imustakim Ahmedabad
  • Status changed to Needs work over 1 year ago
  • 🇺🇦Ukraine andrew_tspkh
    $likeit_session = $stack->getCurrentRequest()->cookies->get('likeit_session');
    $likeit_session = $session_id;
    

    Has no sense, because here we need to set cookie. And in code above you just assign session Id to variable that never be used.
    I think that good code is:

    $stack->getCurrentRequest()->cookies->set('likeit_session', $session_id);
    

    Also please check functions/variables doc parts where you put new parameters:

    @param Drupal\Core\Render\RendererInterface $renderer
    

    should be:

    @param \Drupal\Core\Render\RendererInterface $renderer
    
  • Assigned to imustakim
  • 🇮🇳India imustakim Ahmedabad
  • Issue was unassigned.
  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024