Fix the issues reported by phpcs

Created on 11 January 2023, over 1 year ago
Updated 11 September 2023, 10 months ago

Problem/Motivation

Getting following error/warnings

FILE: /var/www/html/modules/contrib/recently_read/tests/src/Functional/RecentlyReadBlockTest.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 8 WARNINGS AFFECTING 10 LINES
------------------------------------------------------------------------------------------------------------------------------------------
  19 | ERROR   | Doc comment short description must start with a capital letter
  56 | ERROR   | The array declaration extends to column 129 (the limit is 80). The array content should be split up over multiple lines
  74 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  78 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  83 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  87 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  91 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  95 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 116 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 120 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/modules/contrib/recently_read/recently_read.info.yml
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
 8 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
----------------------------------------------------------------------------------------------


FILE: /var/www/html/modules/contrib/recently_read/recently_read.install
-----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------
 1 | ERROR | [x] Missing file doc comment
-----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------


FILE: /var/www/html/modules/contrib/recently_read/README.txt
----------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------
 47 | WARNING | Line exceeds 80 characters; contains 82 characters
 50 | WARNING | Line exceeds 80 characters; contains 85 characters
 56 | WARNING | Line exceeds 80 characters; contains 81 characters
----------------------------------------------------------------------


FILE: /var/www/html/modules/contrib/recently_read/src/RecentlyReadServiceInterface.php
-----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
 12 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
-----------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/modules/contrib/recently_read/src/Form/RecentlyReadTypeForm.php
-----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
 13 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
-----------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/modules/contrib/recently_read/src/RecentlyReadService.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------
 97 | WARNING | [x] 'TODO: Replace this with something cleaner once core provides it.' should match the format '@todo Fix problem X here.'
-------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------

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/recently_read/

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India samit.310@gmail.com

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.

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +  3. Navigate to Administration > Configuration > System > Recently read
    +        config to configure.

    The last line is not indented corrected. It should start 2 spaces to the right of the previous line.

     /**
    - * Class RecentlyReadTypeForm.
    + * The Class RecentlyReadTypeForm.

    That description is still repeating the class name, while it should describe what the class does.

    -  protected $defaultTheme = 'bartik';
    +  protected $defaultTheme = 'stark';

    The report shown in the issue summary does not say that the default value for that property must be changed.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India mrinalini9 New Delhi

    Updated patch #6 by addressing #11, please review it.

    Thanks!

  • Hello Folks !!

    I have applied and tested the #12patch

    and the phpcs issues has been successfully fixed! The patch was tested on Drupal 9.5.9 and PHP 8.2.4. To provide you with a comprehensive view, I will be adding both a before and after screenshot.

    Thank you for your support!!

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -       recently read articles.
    -  3. Navigate to Administration > Configuration > System > Recently read config to
    -       configure.
    +  recently read articles.
    +  3. Navigate to Administration > Configuration > System > Recently read
    +  config to configure.
       4. From the "Configuration" tab, enable entity types for which you want
    -       to track recently read items. There are also options for deleting the records:
    -       Time based, Count based, or Never.
    -  5. From the "List" tab, entities can be individually configured by
    -       selecting the "Edit" option.
    +  to track recently read items. There are also options for deleting the records:
    +  Time based, Count based, or Never.
    +  5. From the "List" tab, entities can be individually configured by selecting
    +  the "Edit" option.
       6. Navigate to Administration > Structure > Views to create a new view for
    -       Recently read content (Content) just add a relationship to Recently read
    -       with Require this relationship option checked. See (Recently read content)
    -       as an example.
    +  Recently read content (Content) just add a relationship to Recently read
    +  with Require this relationship option checked. See (Recently read content) as
    +  an example.

    I apologize if I have not been clear. This is how that text should be formatted.

      1. Navigate to Administration > Extend and enable the module.
      2. When the module is enabled, it automatically creates a view block for
         recently read articles.
      3. Navigate to Administration > Configuration > System > Recently read config
         to configure.
      4. From the "Configuration" tab, enable entity types for which you want
         to track recently read items. There are also options for deleting the
         records: Time based, Count based, or Never.
      5. From the "List" tab, entities can be individually configured by
         selecting the "Edit" option.
      6. Navigate to Administration > Structure > Views to create a new view for
         Recently read content (Content) just add a relationship to Recently read
         with Require this relationship option checked. See (Recently read content)
         as an example.
    
    +/**
    + * @file
    + * Install, update and uninstall functions for the Recently Read module.
    + */
    +

    A comma is missing before and.

     /**
    - * Class RecentlyReadTypeForm.
    + * Defines the Recently read type form.
      */

    the Recently read type form does not say what the form does.

     /**
    - * Interface RecentlyReadServiceInterface.
    + * The Interface RecentlyReadServiceInterface.
      *

    That is still just repeating the interface name. The article at the beginning does not change that.

  • Assigned to imustakim
  • 🇮🇳India imustakim Ahmedabad

    Working on this.

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

    Updated patch addressing suggestions mentioned in #14 📌 Fix the issues reported by phpcs Needs review .
    Please review.

  • Hello imustakim,

    I have reviewed your patch & Implemented it on my website having Drupal version-9.5.9 And PHP version - 8.2
    I am adding screenshot(after applying the patch) for your reference.
    Please have a look.

    Thank You for your support!!!

  • Status changed to RTBC about 1 year ago
  • 🇮🇳India Shyam_Bhatt Gujarat

    I have reviewed your patch & Implemented it on my website having Drupal version 10.0.9 And PHP version 8.1
    The patch #16 📌 Fix the issues reported by phpcs Needs review is working fine.

    Please check the below screenshot:

  • First commit to issue fork.
  • Status changed to Needs review 10 months ago
  • 🇸🇮Slovenia DeaOm

    Corrected order of use statements and also removed static calls for loading entities, added type hint etc. Needs review as there are not adequate test, to see if anything broke.

  • First commit to issue fork.
  • Status changed to RTBC 10 months ago
  • Rebased and tested the code. From what I see everything works like it's supposed to. The tests issued are being handled by 📌 Drupal 10 Fix deprecations in tests Needs review . Marking the issue as RTBC. Should be now ready for merge.

  • Status changed to Needs work 10 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs review 10 months ago
  • Hello updated the file as per the changes suggested . Kindly review the changes
    Thank you .

Production build 0.69.0 2024