Fix the issues reported by phpcs

Created on 5 May 2023, about 1 year ago
Updated 4 January 2024, 6 months ago

Problem/Motivation

❯ phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml,css,js .

FILE: /Users/specbee/Sites/Projects/addtocal_augment/js/modal.js
---------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
---------------------------------------------------------------------------------------------
 14 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
 15 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------


FILE: /Users/specbee/Sites/Projects/addtocal_augment/tests/src/Unit/TestAddToCal.php
----------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
----------------------------------------------------------------------------------------------------------------------
  8 | ERROR | [x] Missing class doc comment
 12 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 29 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 35 | ERROR | [x] Expected 1 blank line after function; 0 found
 36 | ERROR | [x] The closing brace for the class must have an empty line before it
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------


FILE: /Users/specbee/Sites/Projects/addtocal_augment/README.md
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 49 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: /Users/specbee/Sites/Projects/addtocal_augment/src/Plugin/DateAugmenter/AddToCal.php
------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 3 WARNINGS AFFECTING 8 LINES
------------------------------------------------------------------------------------------------------------
  29 | ERROR   | [ ] Missing member variable doc comment
  30 | ERROR   | [ ] Missing member variable doc comment
  31 | ERROR   | [ ] Missing member variable doc comment
  32 | ERROR   | [ ] Missing member variable doc comment
 284 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 285 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 371 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
 397 | WARNING | [x] 'TODO: support other field types?' should match the format '@todo Fix problem X here.'
------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------

Time: 208ms; Memory: 12MB

Steps to reproduce

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

📌 Task
Status

Fixed

Version

1.1

Component

Code

Created by

🇮🇳India sidharth_soman 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

Merge Requests

Comments & Activities

  • Issue created by @sidharth_soman
  • 🇮🇳India sidharth_soman Bangalore

    I am finding the above issues after running the phpcs command. I will work on them.

  • Merge request !7Fixed the phpcs issues. → (Merged) created by sidharth_soman
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India sidharth_soman Bangalore

    I've solved all issues except for the dependency injection and minor requirements of editing/filling in documentation. This should ideally be resolved by the maintainer.

    I've opened an MR above. Please review.

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

    The issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, show which command has been used, which arguments have been used, and which report that command shown.

  • 🇮🇳India imustakim Ahmedabad

    Issue summary updated.

  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -      // TODO: support other field types?
    +      // @todo support other field types?

    What follows @todo is a sentence: It starts with a capitalized word and end with a period (preferable), a question mark, or an exclamation point. In this case, Consider supporting other field types. is a better sentence.

    +/**
    + *
    + */
     class TestAddToCal extends AddToCal {

    Documentation comments for classes must describe the class purpose.

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

    Patch and issue summary updated.
    Please review.

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
     /**
      * @file
    - * Contains addtocal_augment.module.
    + * Hook implementation for the Add to Calendar Date Augmenter module.
      */

    It should be Hook implementations.

       /**
    -   * Override parent::defaultConfiguration()
    -   * which uses String Translation.
    +   * Override parent::defaultConfiguration() which uses String Translation.

    It should be either string translation or StringTranslationTrait, if it is referring to the trait used by the parent class.

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

    Patch updated.
    Please review.

  • 🇮🇳India arpitk

    Hi I reviews the patch and it applied cleanly. Running phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml,css,js . after patch results no warnins or errors. Here attaching the screenshots.

    Thanks!

  • First commit to issue fork.
  • Status changed to Fixed 6 months ago
  • 🇺🇸United States mark_fullmer Tucson

    Valid PHPCS and PHPStan warnings are now handled. I opted to add "ignore" statements for the PHPStan warning about not using dependency injection, since I think the conditional usage of the Token service here makes more sense as a direct call.

    ESlinting is still reporting violations, but I'm not convinced that those are quite valid, based on discussion in 📌 JS closure results in "Unexpected unnamed function" warning from eslint Closed: won't fix , so leaving as-is.

    One of the PHPCS warnings was about augmentOutput() needing a return statement, since date_augmenter/src/DateAugmenter/DateAugmenterInterface states that requirement, but I think that is incorrect based on usage and needs to be updated. I added an innocuous return for now to satisfy the Interface and will follow-up in the DateAugmenter module.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024