Fix the issues reported by phpcs

Created on 22 December 2022, almost 2 years ago
Updated 24 July 2024, 2 months ago

Problem/Motivation

Getting following error/warnings

FILE: /app/modules/contrib/publication_date/publication_date.module
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
16 | ERROR | Doc comment short description must be on a single line, further text should be a separate paragraph
20 | ERROR | The text '@deprecated will be removed before Publication Date 2.0.0. The behaviour of the module for unpublished entities has been changed in
| | https://www.drupal.org/project/publication_date/issues/3066446 ๐Ÿ› Field value should be empty for entities that were never published Fixed ' does not match the standard format: @deprecated in %deprecation-version% and is removed from
| | %removal-version%. %extra-info%.
20 | ERROR | Each @deprecated tag must have a @see tag immediately following it
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/publication_date/publication_date.post_update.php
----------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------
12 | WARNING | Line exceeds 80 characters; contains 94 characters
----------------------------------------------------------------------------

FILE: /app/modules/contrib/publication_date/src/Plugin/Field/FieldType/PublicationDateItem.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------
5 | WARNING | [x] Unused use statement
7 | WARNING | [x] Unused use statement
----------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/publication_date/src/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php
------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------
29 | WARNING | DateFormat::load calls should be avoided in classes, use dependency injection instead
30 | WARNING | DateFormat::load calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/publication_date/tests/src/Functional/PublicationDateTest.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 15 WARNINGS AFFECTING 17 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
132 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
136 | ERROR | [x] list(...) is forbidden, use [...] instead.
139 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
144 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
152 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
162 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
165 | ERROR | [x] list(...) is forbidden, use [...] instead.
166 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
167 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
174 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
177 | ERROR | [x] list(...) is forbidden, use [...] instead.
177 | WARNING | [ ] Unused variable $new_date.
178 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
179 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
180 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
185 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
190 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
195 | WARNING | [ ] There must be no blank line following an inline comment
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------

Time: 1.76 secs; Memory: 12MB

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

Proposed resolution

Above error/warnings need to be fixed

๐Ÿ“Œ Task
Status

Needs work

Version

2.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.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    Charchil Khandelwal โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    I will review this patch.

  • @charchil-khandelwal opened merge request.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    Thanks @samit.310@gmail.com, patch #2 applied cleanly, all errors and warnings are fixed.
    And i also created MR for same.
    Please review.

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
     /**
    + * The publication_date module.
    + *

    The usual module description is Hook implementations for the [module name] module. where [module name] is replaced by the module name as shown in the .info.yml file.

    + * @codingStandardsIgnoreStart
      * @deprecated will be removed before Publication Date 2.0.0.
    - *   The behaviour of the module for unpublished entities has been changed in
    - *   https://www.drupal.org/project/publication_date/issues/3066446
    + * @codingStandardsIgnoreEnd

    I am not sure it is necessary to use @codingStandardsIgnoreStart.

    +  /**
    +   * The entoty type manager.
    +   *
    +   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
    +   */
    +  protected $entityTypeManager;

    There is a typo in entoty.

    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, EntityTypeManagerInterface $entity_manager) {

    {@inheritdoc} is not used for constructors.

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

    Please review.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Status changed to Needs work 2 months ago
  • Hi @nitin_lama,

    Applied your latest changes on MR !3, obviously it did not patch successfully and errors were still thrown. Please see below:

     publication_date git:(78e5aa5) curl https://git.drupalcode.org/project/publication_date/-/merge_requests/13.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 11739    0 11739    0     0  34351      0 --:--:-- --:--:-- --:--:-- 35252
    patching file publication_date.module
    patching file publication_date.post_update.php
    patching file src/Plugin/Field/FieldType/PublicationDateItem.php
    patching file src/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php
    Hunk #1 FAILED at 4.
    Hunk #2 FAILED at 24.
    2 out of 2 hunks FAILED -- saving rejects to file src/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php.rej
    patching file tests/src/Functional/PublicationDateTest.php
    โžœ  publication_date git:(78e5aa5) โœ— cd ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig publication_date
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue-v9/web/modules/contrib/publication_date/publication_date.install
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
     10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Messenger\MessengerInterface.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue-v9/web/modules/contrib/publication_date/tests/src/Functional/PublicationDatePreExistingContentTest.php
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\Entity\BaseFieldOverride.
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue-v9/web/modules/contrib/publication_date/publication_date.module
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityTypeInterface.
     22 | ERROR | [ ] The text '@deprecated will be removed before Publication Date 2.0.0. The behaviour of the module for unpublished entities has been changed in' does not match
        |       |     the standard format: @deprecated in %deprecation-version% and is removed from %removal-version%. %extra-info%.
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 389ms; Memory: 12MB

    Kindly check

    Thanks,
    Jake

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    The issue fork is 15 commits behind the upstream repository.

Production build 0.71.5 2024