Fix the issues reported by phpcs

Created on 4 May 2023, about 1 year ago
Updated 29 May 2024, about 1 month ago

Problem/Motivation

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

FILE: /var/www/html/vbd9/web/modules/contrib/node_menus/node_menus.info.yml
-----------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------
1 | WARNING | "core_version_requirement" property is missing in the info.yml file
-----------------------------------------------------------------------------------

FILE: /var/www/html/vbd9/web/modules/contrib/node_menus/node_menus.module
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 18 ERRORS AND 3 WARNINGS AFFECTING 19 LINES
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
12 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
64 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
68 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
96 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
98 | ERROR | [ ] Missing parameter comment
99 | ERROR | [ ] Missing parameter comment
99 | ERROR | [x] Data types in @param tags need to be fully namespaced
106 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
117 | ERROR | [ ] Missing parameter comment
119 | ERROR | [ ] Return type "array An array that contains default values for the menu link form." must not contain spaces
120 | ERROR | [x] Return comment indentation must be 3 spaces, found 1 spaces
122 | ERROR | [x] Short array syntax must be used to define arrays
130 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
242 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
248 | ERROR | [x] Use null coalesce operator instead of ternary operator.
256 | ERROR | [x] Use null coalesce operator instead of ternary operator.
262 | WARNING | [x] 'TODO make validation work again.' should match the format '@todo Fix problem X here.'
263 | ERROR | [x] No space found before comment text; expected "// $form['#validate'][] = 'node_menus_form_node_type_form_validate';" but found "//$form['#validate'][] =
| | 'node_menus_form_node_type_form_validate';"
263 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
293 | ERROR | [ ] The array declaration extends to column 116 (the limit is 80). The array content should be split up over multiple lines
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 14 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 409ms; Memory: 14MB

Steps to reproduce

Proposed resolution

Run:

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

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Needs review

Version

2.0

Component

Code

Created by

🇮🇳India dineshkumarbollu

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 @dineshkumarbollu
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -core: 8.x
    +core_version_requirement: 8.x

    core_version_requirement is not recognized from any Drupal version before Drupal 8.8. That requirement needs to be changed.

    +/**
    + * @file
    + * Primary module hooks for Node Menu moodule.
    + */
    +

    The short description for that module is Hook implementations for the Node menus module. since Drupal core does not have primary nor secondary hooks.
    moodule is a mispelled word.

    +    // We need to sync menu item. Things will break if we try to do similar
    +    // logicfound in menu ui submit callback, token module breaks hard.

    There is a missing space between logic and found, since those are two distinct words.

     /**
    - * Node form validate callback.
      * Sync main parent item with selected item from language menu.
      *
      * @param array $form
    - * @param FormStateInterface $form_state
    + *   The array of form values.S.
    + * @param \Drupal\Core\Form\FormStateInterface $form_state
    + *   Form cuurent state.
      */
     function node_menus_form_node_form_validate($form, FormStateInterface $form_state) {

    The documentation comment for a validation handler is different and it does not need to describe its parameters.

    -  // TODO make validation work again.
    -  //$form['#validate'][] = 'node_menus_form_node_type_form_validate';
    +  // @todo make validation work again.

    What follows @todo is a sentence: It starts with a capitalized word and it ends with a period.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India Soham Sengupta

    Hi, I have updated the patch with the changes

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    +core_version_requirement: ^8 || ^9 || ^10

    The minimum Drupal 8 version must be 8.8, so the first requirement needs to be ^8.8.

    + * @return array
    + *   An array that contains default values for the menu link form.

    The default values for the menu link form. is sufficient.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India Soham Sengupta

    Thanks, Updated the patch as per the suggestions.

  • Hi, Reviewed the patch #6, applies cleanly and resolves all the phpcs errors/warnings. And also addresses the comments mentioned at #5 .

  • 🇮🇳India dev16.addweb

    Re-roll the patch #8 according to the latest code changes.

Production build 0.69.0 2024