Fix the issues reported by phpcs

Created on 13 February 2023, almost 2 years ago
Updated 25 July 2024, 5 months ago

Problem/Motivation

Getting following error/warnings.

FILE: /var/www/html/modules/contrib/publishing_dropbutton/tests/src/Functional/NodeFormButtonsTest.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 16 WARNINGS AFFECTING 17 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
45 | ERROR | [x] Missing function doc comment
49 | ERROR | [ ] The array declaration extends to column 99 (the limit is 80). The array content should be split up over multiple lines
51 | ERROR | [ ] The array declaration extends to column 89 (the limit is 80). The array content should be split up over multiple lines
64 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
64 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
70 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
78 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
78 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
82 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
90 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
97 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
97 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
105 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
110 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
119 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
129 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
146 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
146 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
153 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
186 | ERROR | [x] Expected 1 blank line after function; 2 found
189 | 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: /var/www/html/modules/contrib/publishing_dropbutton/tests/src/Functional/ModerationFormTest.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 15 WARNINGS AFFECTING 15 LINES
------------------------------------------------------------------------------------------------------------------------------------------
59 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
83 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
100 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
117 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
136 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
157 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
166 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
175 | 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
208 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
227 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
236 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
247 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
268 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
281 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/publishing_dropbutton/publishing_dropbutton.module
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------------------------
12 | WARNING | [x] Unused use statement
24 | ERROR | [ ] The array declaration extends to column 96 (the limit is 80). The array content should be split up over multiple lines
-------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/publishing_dropbutton/src/Plugin/Field/FieldWidget/ModerationStateWidget.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------------
78 | ERROR | [x] Parameter comment must end with a full stop
120 | ERROR | [x] Data types in @var tags need to be fully namespaced
212 | ERROR | [ ] The array declaration extends to column 95 (the limit is 80). The array content should be split up over multiple lines
------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/publishing_dropbutton/src/NodePublishingDropbutton.php
------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 9 WARNINGS AFFECTING 7 LINES
------------------------------------------------------------------------------------------------------------------------------
24 | WARNING | [ ] Line exceeds 80 characters; contains 86 characters
25 | WARNING | [ ] Line exceeds 80 characters; contains 90 characters
26 | WARNING | [ ] Line exceeds 80 characters; contains 90 characters
27 | WARNING | [ ] Line exceeds 80 characters; contains 89 characters
28 | WARNING | [ ] Line exceeds 80 characters; contains 87 characters
28 | WARNING | [x] There must be no blank line following an inline comment
28 | WARNING | [ ] There must be no blank line following an inline comment
28 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
32 | WARNING | [ ] Line exceeds 80 characters; contains 89 characters
45 | WARNING | [ ] Line exceeds 80 characters; contains 93 characters
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------

Time: 1.63 secs; Memory: 6MB

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

Proposed resolution

Above error/warnings need to be fixed.

๐Ÿ“Œ Task
Status

Closed: duplicate

Version

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

  • Issue created by @samit.310@gmail.com
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia samit.310@gmail.com

    Above error/warnings are fixed.

  • Status changed to RTBC almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia hardikpandya

    I have checked the patch is applying and there are no more phpcs issues reported. Marking as RTBC!

  • @hardikpandya opened merge request.
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    -      // isNew | prev status ร‚ยป default   & publish label             & unpublish label
    -      // 1     | 1           ร‚ยป publish   & Save and publish          & Save as unpublished
    -      // 1     | 0           ร‚ยป unpublish & Save and publish          & Save as unpublished
    -      // 0     | 1           ร‚ยป publish   & Save and keep published   & Save and unpublish
    -      // 0     | 0           ร‚ยป unpublish & Save and keep unpublished & Save and publish
    -
    +      // isNew | prev status ร‚ยป
    +      // default   & publish label             & unpublish label
    +      // 1     | 1           ร‚ยป
    +      // publish   & Save and publish          & Save as unpublished
    +      // 1     | 0           ร‚ยป
    +      // unpublish & Save and publish          & Save as unpublished
    +      // 0     | 1           ร‚ยป
    +      // publish   & Save and keep published   & Save and unpublish
    +      // 0     | 0           ร‚ยป
    +      // unpublish & Save and keep unpublished & Save and publish.
           // Add a "Publish" button.

    Since that data is shown in a tabular format, the existing code is much more readable. Code lines are allowed to exceed 80 characters.

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

    Please review.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines roberttabigue

    Hi,

    I'm still seeing PHPCS errors after applying the latest Merge to the Publishing Dropbutton module with version 8.x-1.x-dev and with Drupal core version 9.5.8.

    Marking this as Needs work for now.
    Kindly refer to the attached screenshots, please.

  • First commit to issue fork.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    Please review.

  • Status changed to RTBC over 1 year ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines roberttabigue

    Hi @sakthi_dev,

    Confirmed it resolves the PHPCS errors after applying your latest commit to the Publishing Drop Button module version 8.x-1.x-dev and with Drupal core version 9.5.8.

    Marking this now as RTBC,
    Thank you!

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Status changed to Closed: duplicate 5 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    Thanks folks - marking this as a duplicate of ๐Ÿ“Œ Add gitlabci Active

    Not transferring credit because I don't give credit for PHPCS issues for those who already have such credits, these are great first issues, but not for established contributors.

Production build 0.71.5 2024