Fix the issues reported by phpcs

Created on 16 March 2023, over 1 year ago
Updated 17 July 2024, 4 months ago

Problem/Motivation

FILE: /Users/projects/drupal-d10/modules/contrib/dpl/dpl.libraries.yml
------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------
 9 | ERROR | [x] Expected 1 newline at end of file; 2 found
------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------


FILE: /Users/projects/drupal-d10/modules/contrib/dpl/config/schema/dpl.schema.yml
------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------
 23 | ERROR | [x] Expected 1 newline at end of file; 2 found
------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------


FILE: /Users/projects/drupal-d10/modules/contrib/dpl/tests/src/Nightwatch/TestSetup.php
------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
------------------------------------------------------------
 11 | ERROR   | [x] Missing class doc comment
 25 | WARNING | [x] A comma should follow the last multiline array item. Found: 'Article'
------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------

FILE: /Users/projects/drupal-d10/modules/contrib/dpl/dpl.routing.yml
------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------
 9 | ERROR | [x] Expected 1 newline at end of file; 2 found
------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------


FILE: /Users/projects/drupal-d10/modules/contrib/dpl/README.md
------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
------------------------------------------------------------
  3 | WARNING | Line exceeds 80 characters; contains 114 characters
  8 | WARNING | Line exceeds 80 characters; contains 100 characters
  9 | WARNING | Line exceeds 80 characters; contains 92 characters
 11 | WARNING | Line exceeds 80 characters; contains 89 characters
 20 | WARNING | Line exceeds 80 characters; contains 107 characters
------------------------------------------------------------


FILE: /Users/projects/drupal-d10/modules/contrib/dpl/src/Form/PreviewLinkAddForm.php
--------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------------
 7 | ERROR | [x] Missing class doc comment
 8 | ERROR | [x] Whitespace found at end of line
--------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------


FILE: /Users/projects/drupal-d10/modules/contrib/dpl/src/Form/PreviewLinkEditForm.php
------------------------------------------------------------
FOUND 3 ERRORS AND 3 WARNINGS AFFECTING 6 LINES
------------------------------------------------------------
 10 | ERROR   | [x] Missing class doc comment
 45 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 47 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 52 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 95 | ERROR   | [x] Expected 1 blank line after function; 2 found
 98 | ERROR   | [x] The closing brace for the class must have an empty line before it
------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------

FILE: /Users/projects/drupal-d10/modules/contrib/dpl/src/Form/PreviewLinkDeleteForm.php
------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------
 8 | ERROR | [x] Missing class doc comment
 9 | ERROR | [x] Whitespace found at end of line
------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------

FILE: /Users/projects/drupal-d10/modules/contrib/dpl/src/Controller.php
-------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 3 LINES
-------------------------------------------------------------------------------------------
  5 | WARNING | [x] Unused use statement
 41 | ERROR   | [ ] Parameter $node is not described in comment
 41 | ERROR   | [ ] Parameter $decoupled_preview_link is not described in comment
 44 | ERROR   | [ ] Missing parameter comment
-------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------


FILE: /Users/projects/drupal-d10/modules/contrib/dpl/src/Entity/DecoupledPreviewLinkListBuilder.php
------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
------------------------------------------------------------
  8 | ERROR   | [x] Missing class doc comment
 23 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------


FILE: /Users/projects/drupal-d10/modules/contrib/dpl/src/Entity/DecoupledPreviewLink.php
------------------------------------------------------------
FOUND 13 ERRORS AFFECTING 13 LINES
------------------------------------------------------------
  92 | ERROR | Missing short description in doc comment
  97 | ERROR | Missing short description in doc comment
 112 | ERROR | Description for the @return value is missing
 124 | ERROR | Missing short description in doc comment
 125 | ERROR | Description for the @return value is missing
 131 | ERROR | Missing short description in doc comment
 132 | ERROR | Description for the @return value is missing
 138 | ERROR | Missing short description in doc comment
 139 | ERROR | Description for the @return value is missing
 145 | ERROR | Missing short description in doc comment
 146 | ERROR | Description for the @return value is missing
 152 | ERROR | Missing short description in doc comment
 153 | ERROR | Description for the @return value is missing
------------------------------------------------------------

FILE: /Users/projects/drupal-d10/modules/contrib/dpl/src/Plugin/Menu/LocalTask/DecoupledPreviewLinkTask.php
-------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 6 LINES
------------------------------------------------------------
  68 | ERROR | [ ] Description for the @return value is missing
  81 | ERROR | [ ] Description for the @return value is missing
 123 | ERROR | [x] Array indentation error, expected 8 spaces but found 6
 124 | ERROR | [x] Array indentation error, expected 8 spaces but found 6
 131 | ERROR | [ ] Missing short description in doc comment
 132 | ERROR | [ ] Description for the @return value is missing
------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------


FILE: /Users/projects/drupal-d10/modules/contrib/dpl/src/PreviewLinkInstance.php
------------------------------------------------------------
FOUND 22 ERRORS AFFECTING 20 LINES
------------------------------------------------------------
  5 | ERROR | [x] Missing class doc comment
 28 | ERROR | [ ] Missing short description in doc comment
 33 | ERROR | [ ] Missing short description in doc comment
 34 | ERROR | [x] Whitespace found at end of line
 34 | ERROR | [x] Expected "string" but found "string " for @var tag in member variable comment
 40 | ERROR | [x] There must be exactly one blank line before the tags in a doc comment
 40 | ERROR | [ ] Missing parameter comment
 41 | ERROR | [ ] Missing parameter comment
 42 | ERROR | [ ] Missing parameter comment
 43 | ERROR | [ ] Missing parameter comment
 44 | ERROR | [ ] Missing parameter comment
 54 | ERROR | [ ] Missing short description in doc comment
 55 | ERROR | [ ] Description for the @return value is missing
 61 | ERROR | [ ] Missing short description in doc comment
 62 | ERROR | [ ] Description for the @return value is missing
 68 | ERROR | [ ] Missing short description in doc comment
 69 | ERROR | [ ] Description for the @return value is missing
 75 | ERROR | [ ] Missing short description in doc comment
 76 | ERROR | [ ] Description for the @return value is missing
 82 | ERROR | [x] Missing function doc comment
 92 | ERROR | [ ] Missing short description in doc comment
 93 | ERROR | [ ] Description for the @return value is missing
------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------

FILE: /Users/projects/drupal-d10/modules/contrib/dpl/src/BrowserSize.php
------------------------------------------------------------
FOUND 17 ERRORS AFFECTING 17 LINES
------------------------------------------------------------
  5 | ERROR | [x] Missing class doc comment
  7 | ERROR | [ ] Missing short description in doc comment
 12 | ERROR | [ ] Missing short description in doc comment
 17 | ERROR | [ ] Missing short description in doc comment
 22 | ERROR | [ ] Missing short description in doc comment
 30 | ERROR | [ ] Missing parameter comment
 31 | ERROR | [ ] Missing parameter comment
 32 | ERROR | [ ] Missing parameter comment
 33 | ERROR | [ ] Missing parameter comment
 45 | ERROR | [ ] Missing short description in doc comment
 46 | ERROR | [ ] Description for the @return value is missing
 52 | ERROR | [ ] Missing short description in doc comment
 53 | ERROR | [ ] Description for the @return value is missing
 59 | ERROR | [ ] Missing short description in doc comment
 60 | ERROR | [ ] Description for the @return value is missing
 66 | ERROR | [ ] Missing short description in doc comment
 67 | ERROR | [ ] Description for the @return value is missing
------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------

Time: 140ms; Memory: 10MB

Steps to reproduce

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

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

šŸ“Œ Task
Status

Needs work

Version

3.0

Component

Code

Created by

šŸ‡®šŸ‡³India rassoni 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 @rassoni
  • šŸ‡®šŸ‡³India rassoni Bangalore
  • Assigned to akshaydalvi212
  • šŸ‡®šŸ‡³India akshaydalvi212

    I will work on this issue.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India akshaydalvi212

    Providing the patch to solve all the PHPCS issues.
    Kindly review.

  • Status changed to Needs work over 1 year ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
    +dependencies:
    +  - drupal:token
    

    The Token module is not a Drupal core module. It is also not necessary to declare it as dependency, since this module checks first the Token module is installed.

     /**
     /**
    - * Returns a random number between min and max.
    + * Return a random number between min and max.
      *
      * @param {int} min
      *   The minimal value.
    

    The existing comment is already correct, given that is a comment for a function or a method. It is @param {int} min that needs to be fixed, as it needs to be fixed the other parameter definition.

    +/**
    + * Provide Size values for the Browser.
    + */
    

    The verb must use the Simple Present and the third person singular. Size and Browser do not need to be capitalized. The class description can be better written.

        * BrowserSize constructor.
        *
        * @param int $min_width
    +   *   Minimum width value.
        * @param int $max_width
    +   *   Maximum width value.
        * @param string $label
    +   *   Label for preview.
        * @param string $short_label
    +   *   Short label for preview.

    The class name does not include its namespace. The descriptions are missing articles.

    +   * Get Minimum width.
    +   *
        * @return int
    +   *   Minimum width value.

    This is also wrong for the reasons already said for the other lines.

       /**
    +   * The link size.
    +   *
        * @var array
        */
       protected $sizes;
    

    Since that property contains an array, it cannot be described as link size. Also, what is, exactly, a link size in this case?

       /**
    +   * Return the lable of link.
    +   *
        * @return string
    +   *   Link label.

    lable is a typo.

       /**
    +   * Return the Open External Label.
    +   *
        * @return string
    +   *   External Label.

    Return is probably not the best verb to use for a method, or it should be used for almost all the methods and functions.

    +/**
    + * Preview link editing using edit form.
    + */

    That description does not make sense. It is more probable that is the class for the edit form used for the preview link.

        * @return \Drupal\Core\Link
    +   *   URL link for previewing the entity.

    It is not necessary to say URL link, as a link is necessarily a URL.

  • First commit to issue fork.
  • Merge request !23348397: phpcs fixes ā†’ (Open) created by kkalashnikov
  • šŸ‡®šŸ‡³India TanujJain-TJ

    updating the patch as it shows this error error: patch failed: dpl.info.yml:4, error: dpl.info.yml: patch does not apply while applying and also addressing some changes listed in #5, please review.

  • Assigned to shalini_jha
  • šŸ‡®šŸ‡³India shalini_jha

    I will work on this issues.

  • šŸ‡®šŸ‡³India shalini_jha

    Added the patch for fixes of most of listed issues. please review.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Status changed to Needs work over 1 year ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
     /**
    - * Returns a random number between min and max.
    - *
    - * @param {int} min
    + *@param {int} min
      *   The minimal value.
      * @param {int} max
      *   The maximum value.

    The short description should not be removed.
    How the parameters are described is correct, since that is for a JavaScript file. (I did not notice that, earlier, and I wrongly reported @param {int} min should be fixed.)

       /**
    +   * Minimum width value.
    +   *
        * @var int
        */
       protected $minWidth;
     
       /**
    +   * Maximum width value.
    +   *
        * @var int
        */
       protected $maxWidth;
     
       /**
    +   * Label for preview.
    +   *
        * @var string
        */
       protected $label;
     
       /**
    +   * Short label for preview.
    +   *
        * @var string
        */

    Those descriptions are all missing an article or two.

        * BrowserSize constructor.
        *
        * @param int $min_width
    +   *   Minimum width value.
        * @param int $max_width
    +   *   Maximum width value.
        * @param string $label
    +   *   Label for preview.
        * @param string $short_label
    +   *   Short label for preview.

    The class name is missing its namespace.

       /**
    +   * Minimum width value.
        * @return int
        */
       public function getMinWidth() {

    The description is missing an article, and it could be better written.
    There is a missing empty line before @return.
    The return value is not described.

       /**
    +   * Get the Label for preview.
    +   *
        * @return string
    +   *   Label.
        */

    When Label is not the first word in a sentence, it is not written in capital case.
    The verb used in a method description must use the Simple Present and the third person singular.
    The return value description can be written better.

        * Controller for the preview page.
        *
    +   * @param Drupal\node\NodeInterface $node
    +   *   The Node.
    +   * @param Drupal\dpl\Entity\DecoupledPreviewLink $decoupled_preview_link
    +   *   The consumer preview links.
        * @param \Symfony\Component\HttpFoundation\Request $request
    +   *   The HTTP request.

    Since that documentation comment is changed, also the short description should be changed: It misses an article.
    Node, since it is not the first word in a sentence, must be spelled differently.

       /**
    -   * Returns a preview link for a given consumer.
    +   * Return a preview link for a given consumer.

    The verb was already correct. What needs to be change is the article used before preview link.

       /**
    +   * The link size.
    +   *
        * @var array
        */
       protected $sizes;

    Since that is an array, it cannot be the link size. Either that variable does not contain an array, or it cannot be described in that way.

    +   * Default size.
    +   *
        * @var string
        */

    An article is missing from the description.

        * @return \Drupal\dpl\PreviewLinkInstance
    +   *   PreviewLink Instance.

    That does not describe the return value; it is just the class name of the returned object spelled as two word.
    Instance is not spelled correctly. (It is not the first word in a sentence.)

    +/**
    + * Preview link creating using add form.
    + */
     class PreviewLinkAddForm extends PreviewLinkEditForm {

    That description is not grammatically correct, since there are two present participles in row.
    Even if that were correct, the description does not make sense.

    +  /**
    +   * Constructs a new service object.
    +   *

    The description must include the class name and its namespace.

    -        '#markup' => $this->t('Enable the token module to see a list of available tokens.')
    +        '#markup' => $this->t('Enable the token module to see a list of available tokens.'),

    Since that line is changed, the module name should also be written in title case.

       /**
    +   * Get the Defination of the previewed instance.
    +   *
        * @return \Drupal\dpl\PreviewLinkInstance
    +   *   URL link of the Instance.

    There is the same typo already reported.

  • First commit to issue fork.
  • Status changed to Needs review 10 months ago
  • šŸ‡®šŸ‡³India zkhan.aamir

    Hi,

    MR #14 applied successfully.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib/dpl (8.x-2.x)
    $ curl https://git.drupalcode.org/project/dpl/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 18507    0 18507    0     0  48736      0 --:--:-- --:--:-- --:--:-- 48831
    patching file README.md
    patching file config/schema/dpl.schema.yml
    patching file dpl.info.yml
    patching file dpl.libraries.yml
    patching file dpl.routing.yml
    patching file src/BrowserSize.php
    patching file src/Controller.php
    patching file src/DecoupledPreviewLinks.php
    patching file src/Entity/DecoupledPreviewLink.php
    patching file src/Entity/DecoupledPreviewLinkListBuilder.php
    patching file src/Form/PreviewLinkAddForm.php
    patching file src/Form/PreviewLinkDeleteForm.php
    patching file src/Form/PreviewLinkEditForm.php
    patching file src/Plugin/Deriver/PreviewLinkLocalTaskDeriver.php
    patching file src/Plugin/Menu/LocalTask/DecoupledPreviewLinkTask.php
    patching file src/PreviewLinkInstance.php
    patching file tests/src/Nightwatch/TestSetup.php
    
    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib
    $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,js,yml dpl/
    
    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib
    $
    

    No remaining issues or errors.

  • Status changed to Needs work 4 months ago
  • Hi @Yashawi18,

    Your changes on MR !2 was applied not-so successfully, might be the reason errors are still reported. Please see below:

    dpl git:(master) āœ— curl https://git.drupalcode.org/project/dpl/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 18507    0 18507    0     0  58660      0 --:--:-- --:--:-- --:--:-- 61281
    patching file README.md
    patching file config/schema/dpl.schema.yml
    patching file dpl.info.yml
    Hunk #1 FAILED at 4.
    1 out of 1 hunk FAILED -- saving rejects to file dpl.info.yml.rej
    patching file dpl.libraries.yml
    patching file dpl.routing.yml
    patching file src/BrowserSize.php
    patching file src/Controller.php
    patching file src/DecoupledPreviewLinks.php
    patching file src/Entity/DecoupledPreviewLink.php
    patching file src/Entity/DecoupledPreviewLinkListBuilder.php
    patching file src/Form/PreviewLinkAddForm.php
    patching file src/Form/PreviewLinkDeleteForm.php
    patching file src/Form/PreviewLinkEditForm.php
    patching file src/Plugin/Deriver/PreviewLinkLocalTaskDeriver.php
    patching file src/Plugin/Menu/LocalTask/DecoupledPreviewLinkTask.php
    patching file src/PreviewLinkInstance.php
    patching file tests/src/Nightwatch/TestSetup.php
    āžœ  dpl git:(master) āœ— cd ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig dpl
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue-v9/web/modules/contrib/dpl/src/Plugin/Menu/LocalTask/DecoupledPreviewLinkTask.php
    --------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    --------------------------------------------------------------------------------------------------------------------------------------
     40 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
     54 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    --------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue-v9/web/modules/contrib/dpl/src/DecoupledPreviewLinks.php
    -------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------------------
     51 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
     99 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    -------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------
    
    Time: 391ms; Memory: 10MB

    Kindly check

    Thanks,
    Jake

Production build 0.71.5 2024