Fix the warnings/errors reported by PHP_CodeSniffer

Created on 20 June 2023, about 1 year ago
Updated 3 July 2023, 12 months ago

Problem/Motivation

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\menu_link_by_role\menu_link_by_role.module
-------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
-------------------------------------------------------------------------------------------------------------------------------
35 | WARNING | Line exceeds 80 characters; contains 82 characters
61 | WARNING | Line exceeds 80 characters; contains 107 characters
70 | ERROR | Doc comment is empty
114 | ERROR | Doc comment is empty
117 | ERROR | Invalid function name, expected menu_link_by_role_load_custom_link but found menu_link_by_role_loadCustomLink
-------------------------------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\menu_link_by_role\README.txt
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 10 WARNINGS AFFECTING 10 LINES
--------------------------------------------------------------------------------
4 | WARNING | Line exceeds 80 characters; contains 252 characters
13 | WARNING | Line exceeds 80 characters; contains 82 characters
14 | WARNING | Line exceeds 80 characters; contains 117 characters
24 | WARNING | Line exceeds 80 characters; contains 106 characters
28 | WARNING | Line exceeds 80 characters; contains 122 characters
29 | WARNING | Line exceeds 80 characters; contains 122 characters
30 | WARNING | Line exceeds 80 characters; contains 124 characters
31 | WARNING | Line exceeds 80 characters; contains 158 characters
32 | WARNING | Line exceeds 80 characters; contains 130 characters
36 | WARNING | Line exceeds 80 characters; contains 160 characters
--------------------------------------------------------------------------------

Steps to reproduce

Run the command:
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml menu_link_by_role/

Proposed resolution

Above error/warnings need to be fixed.

๐Ÿ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia arti_parmar

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

  • Issue created by @arti_parmar
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia arti_parmar

    Kindly review patch.

  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Anmol_Specbee

    The patch is applying cleanly and issues mentioned are getting resolved by it. Moving it to RTBC.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia yashaswini Bangalore

    Let me check on it.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia yashaswini Bangalore
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +2. Place the module directory in the "modules" folder of your Drupal 
    +installation.
    -7. The custom links will be associated with the corresponding user roles and used when rendering the menu.
    +7. The custom links will be associated with the corresponding user roles
    +and used when rendering the menu.
    +- The "menu_link_by_role_form_alter" function alters the menu link content form
    +and adds custom link fields for each role.

    Since that text is part of a list, the second line must be indented.

    +This module is licensed under the [GNU General Public License version 2
    +or later](https://www.gnu.org/licenses/gpl-2.0.html).

    A link markup cannot be split in two lines.

  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama

    Addressed #6. Updated patch.

  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Anmol_Specbee

    Patch seems to be applying cleanly, moving to RTBC.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    -        // Fetch the stored custom link and set as the default value if it exists.
    +        // Fetch the stored custom link and set as the default
    +        // value if it exists.

    Since that comment is changed, and set as needs to be corrected (and set it as).

     /**
    - *
    + * Form submission handler for menu_link_by_role form.
      */

    A definite article is missing before menu_link_by_role.

  • Assigned to nitin_lama
  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Harshita mehra

    Hello arti_parmar,
    Your patch #2 is working fine.

  • Issue was unassigned.
  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama

    Addressed #11.

  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
     /**
    - *
    + * Implements hook_link_by_role_load_custom_link().
      */
    -function menu_link_by_role_loadCustomLink($menu_link_plugin_id, $user_role) {

    Looking at the module code, I gather that is not a hook implementation; otherwise, it would not be called directly.

    -      // Assume loadCustomLink is a function that fetches the custom links based on the menu link and role.
    -      $custom_link = menu_link_by_role_loadCustomLink($item['original_link']->getPluginId(), $user_role);
    +      // Assume loadCustomLink is a function that fetches the custom links
    +      // based on the menu link and role.
    +      $custom_link = menu_link_by_role_load_custom_link($item['original_link']->getPluginId(), $user_role);

    I would rather remove that comment, simply because it does not make sense. Assume loadCustomLink is a function is referring to a function this very module implements. There is no need to assume that function exists: The module knows it exists.

  • Status changed to Needs review 12 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia PrasadDeole

    Changes suggested in #19 have been fixed in this patch.

  • Status changed to Needs work 12 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
     /**
    - *
    + * Function fetches the custom links based on the menu link and role.
      */
    -function menu_link_by_role_loadCustomLink($menu_link_plugin_id, $user_role) {
    +function menu_link_by_role_load_custom_link($menu_link_plugin_id, $user_role) {

    Without Function at the beginning, that description would be fine.
    The parameter and the return value descriptions are missing.

    For the rest, the patch would be good to go.

  • First commit to issue fork.
  • Assigned to Neha-Verma
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Neha-Verma

    I am working on it.

  • @sonam_sharma opened merge request.
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kbk1992 Hyderabad

    bharath-kondeti โ†’ made their first commit to this issueโ€™s fork.

  • Status changed to Needs review 12 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kbk1992 Hyderabad

    Updated the MR with fixes commit and addressed #21. Please review

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
Production build 0.69.0 2024