Fix issues reported by phpcs.

Created on 28 June 2023, over 1 year ago
Updated 26 May 2024, 6 months ago

Problem/Motivation

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

FILE: /home/arpitkayare/drupal_9.5/web/modules/contrib/stop_broken_link_in_body/src/Controller/BrokenLinkController.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 3 WARNINGS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------------------------------
10 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
19 | ERROR | [x] Doc comment short description must start with a capital letter
22 | ERROR | [x] Expected 1 space after "="; 2 found
22 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
26 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
33 | ERROR | [x] Doc comment short description must start with a capital letter
-----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------

FILE: /home/arpitkayare/drupal_9.5/web/modules/contrib/stop_broken_link_in_body/src/Form/RunContentBrokenLink.php
----------------------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AND 8 WARNINGS AFFECTING 16 LINES
----------------------------------------------------------------------------------------------------------------------
11 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
16 | ERROR | [ ] Missing @var tag in member variable comment
17 | ERROR | [ ] Class property $nodes_broken should use lowerCamel naming without underscores
48 | WARNING | [ ] Possible useless method overriding detected
57 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
69 | ERROR | [x] Return type must not contain variable name "$content_types"
76 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
89 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
91 | WARNING | [ ] Unused variable $operations.
113 | ERROR | [ ] Missing parameter type
122 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
134 | ERROR | [ ] Missing parameter type
139 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
148 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
167 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
189 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------

FILE: /home/arpitkayare/drupal_9.5/web/modules/contrib/stop_broken_link_in_body/stop_broken_link_in_body.module
-------------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES
-------------------------------------------------------------------------------------------------------------------------
53 | WARNING | [ ] Unused variable $config.
108 | ERROR | [x] Return type must not contain variable name "$message."
144 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
164 | ERROR | [x] Return comment indentation must be 3 spaces, found 2 spaces
179 | ERROR | [x] Expected newline after closing brace
-------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------

Steps to reproduce

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

Proposed resolution

Fix the issues provide a patch and get it reviewed.

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ“Œ Task
Status

Needs work

Version

2.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia arpitk

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 @arpitk
  • Issue was unassigned.
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia arpitk

    Here is the patch fixing the DI issues still other comments issues need to be addressed. So keeping the status as NW.

    Thanks!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Ashutosh Ahirwal India

    Providing updated patch. Only one issue of Possible useless method overriding detected remaining not sure about it.
    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/stop_broken_link_in_body/src/Form/RunContentBrokenLink.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
    79 | WARNING | Possible useless method overriding detected
    -----------------------------------------------------------------------------------------------------------------------------------

    Time: 176ms; Memory: 12MB

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Bhupesh_upadhyay

    All errors fixed including the remaining ones, kindly fixed it.

  • Hi, reviewed the patch at #4 , which applies cleanly and fixes all the phpcs errors/warnings.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

    silvi.addweb โ†’ made their first commit to this issueโ€™s fork.

  • Merge request !3Fix issues reported by phpcs. โ†’ (Open) created by Unnamed author
  • Status changed to Needs work 6 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines clarkssquared

    Hi

    I applied patch #4 and I confirmed that it fixes the PHPCS issues that were reported.

    โžœ  stop_broken_link_in_body git:(8.x-2.2) curl https://www.drupal.org/files/issues/2023-06-30/fix-phpcs-3371162-4.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  9509  100  9509    0     0  14730      0 --:--:-- --:--:-- --:--:-- 14857
    patching file 'src/Controller/BrokenLinkController.php'
    patching file 'src/Form/RunContentBrokenLink.php'
    patching file stop_broken_link_in_body.module
    โžœ  stop_broken_link_in_body git:(8.x-2.2) โœ— ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml stop_broken_link_in_body
    โžœ  contrib git:(master) โœ— 
    

    however, instead of uploading your patdh file here, can you add your changes inside the existing MR? so that if it passed by the community the Maintainer can easily look at it and merge . I will transition the status to needs work for that matter.

Production build 0.71.5 2024