Fix the issues reported by phpcs

Created on 5 April 2023, over 1 year ago
Updated 17 July 2023, over 1 year ago

Problem/Motivation

Getting these phpcs errors and warnings

FILE: /filter_tooltips/css/filter_tooltips.autocomplete.css
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 26 | ERROR | [x] Expected 1 space before opening brace of class definition; 2
    |       |     found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: /filter_tooltips/filter_tooltips.routing.yml
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
 16 | WARNING | Open page callback found, please add a comment before the line
    |         | why there is no access restriction
--------------------------------------------------------------------------------


FILE: /filter_tooltips/filter_tooltips.module
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
--------------------------------------------------------------------------------
 224 | ERROR   | [x] Functions must not contain multiple empty lines in a row;
     |         |     found 2 empty lines
 226 | WARNING | [ ] Unused variable $allowed_html.
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: /filter_tooltips/filter_tooltips.info.yml
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
 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
 8 | WARNING | All dependencies must be prefixed with the project name, for
   |         | example "drupal:"
--------------------------------------------------------------------------------


FILE: /filter_tooltips/src/Plugin/CKEditorPlugin/CKEditorTooltips.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------------
 34 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         | $this->t() instead
 45 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         | $this->t() instead
 46 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         | $this->t() instead
--------------------------------------------------------------------------------


FILE: /filter_tooltips/src/Plugin/Filter/FilterTooltips.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------------
 167 | WARNING | [ ] #options values usually have to run through t() for
     |         |     translation
 168 | WARNING | [ ] #options values usually have to run through t() for
     |         |     translation
 195 | ERROR   | [x] Whitespace found at end of line
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: /filter_tooltips/src/Controller/AutocompleteController.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
 82 | WARNING | \Drupal calls should be avoided in classes, use dependency
    |         | injection instead
--------------------------------------------------------------------------------

Steps to reproduce

run this command in file directory
phpcs --standard="Drupal,DrupalPractice" --extensions="php,module,inc,install,test,profile,theme,css,info,txt,md,yml"

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India TanujJain-TJ

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 @TanujJain-TJ
  • 🇮🇳India TanujJain-TJ

    Adding a patch to fix the above mentioned phpcs issues.

  • 🇵🇭Philippines clarkssquared

    Hi Tanuj.,

    I applied your patch #2 to Filter tooltips version 8.x-1.x-dev and I noticed that there's still a PHPCS issue being flagged.

    Please look at the screenshot for your reference

    Thank you.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -  if ($filter_html_enabled && $allowed_html = $form_state->getValue($allowed_html_path)) {
    +  if ($filter_html_enabled == $form_state->getValue($allowed_html_path)) {

    The existing line and the changed line are not even equivalent. The existing code is not comparing $filter_html_enabled with $allowed_html

       requirements:
    +    # Access is open for all.
         _access: 'TRUE'

    Yes, that is already evident. Why is it open for everybody?

    Open page callback found, please add a comment before the line why there is no access restriction

  • Assigned to lalitkyttn
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    + # Allow everyone to access the preview

    It still does not explain why it is open.

    -
       if ($filter_html_enabled && $allowed_html = $form_state->getValue($allowed_html_path)) {

    That does not fix the Unused variable $allowed_html. report.

  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024