Fix the issues reported by phpcs

Created on 18 July 2024, 4 months ago
Updated 5 August 2024, 4 months ago

Problem/Motivation

There is a file that needs to be fixed with coding standards.
Here is the command: -

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,yml modules/contrib/redirects_fixer/

FILE: D:\wamp64\www\drupal10\modules\contrib\redirects_fixer\redirects_fixer.info.yml
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
 1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
 1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
 1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
-------------------------------------------------------------------------------------------------------------


FILE: D:\wamp64\www\drupal10\modules\contrib\redirects_fixer\redirects_fixer.install
------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------
 1 | ERROR | [x] Missing file doc comment
------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------


FILE: D:\wamp64\www\drupal10\modules\contrib\redirects_fixer\src\BatchManager.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 27 ERRORS AND 8 WARNINGS AFFECTING 28 LINES
-------------------------------------------------------------------------------------------------------------------------------
  40 | ERROR   | [ ] Missing member variable doc comment
  41 | ERROR   | [ ] Missing member variable doc comment
  42 | ERROR   | [ ] Missing member variable doc comment
  43 | ERROR   | [ ] Missing member variable doc comment
  44 | ERROR   | [ ] Missing member variable doc comment
  45 | ERROR   | [ ] Missing member variable doc comment
  46 | ERROR   | [ ] Missing member variable doc comment
  47 | ERROR   | [ ] Missing member variable doc comment
  48 | ERROR   | [ ] Missing member variable doc comment
  49 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
  49 | ERROR   | [ ] Missing member variable doc comment
  66 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 138 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 140 | WARNING | [ ] Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
 146 | WARNING | [ ] Only string literals should be passed to t() where possible
 203 | WARNING | [ ] Line exceeds 80 characters; contains 108 characters
 236 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 236 | ERROR   | [x] Comments may not appear after statements
 237 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 237 | ERROR   | [x] Comments may not appear after statements
 238 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 238 | ERROR   | [x] Comments may not appear after statements
 239 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 239 | ERROR   | [x] Comments may not appear after statements
 240 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 240 | ERROR   | [x] Comments may not appear after statements
 241 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 241 | ERROR   | [x] Comments may not appear after statements
 254 | WARNING | [ ] Line exceeds 80 characters; contains 106 characters
 257 | ERROR   | [x] Language constructs must be followed by a single space; expected 1 space but found "  "
 266 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 267 | ERROR   | [x] There should be no white space after an opening "("
 271 | ERROR   | [x] Array closing indentation error, expected 8 spaces but found 10
 410 | ERROR   | [x] Expected 1 space after "="; 0 found
 429 | WARNING | [ ] Only string literals should be passed to t() where possible
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 17 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------


FILE: D:\wamp64\www\drupal10\modules\contrib\redirects_fixer\src\Controller\FixLinksController.php
-----------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
-----------------------------------------------------------------------------------------------------------
  70 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
  81 | ERROR   | [x] Array indentation error, expected 8 spaces but found 10
  89 | ERROR   | [x] Array indentation error, expected 8 spaces but found 10
 100 | WARNING | [ ] Avoid backslash escaping in translatable strings when possible, use "" quotes instead
-----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------


FILE: D:\wamp64\www\drupal10\modules\contrib\redirects_fixer\src\Entity\RedirectsFixerLogEntity.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-------------------------------------------------------------------------------------------------------------------------------
  6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\ContentEntityBase.
 64 | ERROR | [x] Expected 1 blank line after function; 2 found
 67 | 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: D:\wamp64\www\drupal10\modules\contrib\redirects_fixer\src\Form\SettingsForm.php
--------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------------
 40 | ERROR | [x] Short array syntax must be used to define arrays
 49 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------


FILE: D:\wamp64\www\drupal10\modules\contrib\redirects_fixer\src\LinksFinder.php
--------------------------------------------------------------------------------------------------
FOUND 9 ERRORS AND 1 WARNING AFFECTING 6 LINES
--------------------------------------------------------------------------------------------------
 14 | ERROR   | [x] Comments may not appear after statements
 15 | ERROR   | [x] Comments may not appear after statements
 37 | WARNING | [x] '@todo: add description.' should match the format '@todo Fix problem X here.'
 43 | ERROR   | [x] There should be no white space after an opening "("
 43 | ERROR   | [x] Concat operator must be surrounded by a single space
 43 | ERROR   | [x] Concat operator must be surrounded by a single space
 46 | ERROR   | [x] Expected 1 space after comma in argument list; 2 found
 46 | ERROR   | [x] Expected one space after the comma, 2 found
 66 | ERROR   | [x] Expected 1 space after comma in argument list; 2 found
 66 | ERROR   | [x] Expected one space after the comma, 2 found
--------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------


FILE: D:\wamp64\www\drupal10\modules\contrib\redirects_fixer\src\LinksManager.php
---------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 3 WARNINGS AFFECTING 7 LINES
---------------------------------------------------------------------------------------------------------------
   7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is GuzzleHttp\Client.
  13 | ERROR   | [x] Doc comment short description must end with a full stop
  15 | WARNING | [ ] Line exceeds 80 characters; contains 83 characters
  68 | WARNING | [x] A comma should follow the last multiline array item. Found: TRUE
  85 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 121 | ERROR   | [x] Expected 1 blank line after function; 0 found
 122 | ERROR   | [x] The closing brace for the class must have an empty line before it
---------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------


FILE: D:\wamp64\www\drupal10\modules\contrib\redirects_fixer\src\Plugin\views\field\RedirectFixerLogLinkToBaseEntity.php
------------------------------------------------------------------------------------------------------------------------
FOUND 17 ERRORS AND 1 WARNING AFFECTING 18 LINES
------------------------------------------------------------------------------------------------------------------------
  7 | WARNING | [x] Unused use statement
  9 | ERROR   | [x] There must be one blank line after the last USE statement; 2 found;
 13 | ERROR   | [x] Expected 1 space(s) before asterisk; 0 found
 14 | ERROR   | [x] Expected 1 space(s) before asterisk; 0 found
 15 | ERROR   | [x] Expected 1 space(s) before asterisk; 0 found
 16 | ERROR   | [x] Expected 1 space(s) before asterisk; 0 found
 17 | ERROR   | [x] Expected 1 space(s) before asterisk; 0 found
 18 | ERROR   | [x] Expected 1 space(s) before asterisk; 0 found
 21 | ERROR   | [ ] Missing short description in doc comment
 22 | ERROR   | [x] Expected 3 space(s) before asterisk; 2 found
 23 | ERROR   | [x] Expected 3 space(s) before asterisk; 2 found
 25 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 2
 28 | ERROR   | [ ] Missing short description in doc comment
 29 | ERROR   | [x] Expected 3 space(s) before asterisk; 2 found
 30 | ERROR   | [x] Expected 3 space(s) before asterisk; 2 found
 32 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 55 | ERROR   | [x] Expected 1 blank line after function; 0 found
 56 | ERROR   | [x] The closing brace for the class must have an empty line before it
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 16 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

Time: 1.09 secs; Memory: 14MB

Steps to reproduce

Run PHPCS on this module.

Proposed resolution

Fix the coding standards.

Remaining tasks

Submit the patch either MR.

User interface changes

none

API changes

none

Data model changes

none

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India amanbtr72

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 @amanbtr72
  • Assigned to sourav_paul
  • Issue was unassigned.
  • Status changed to Needs review 4 months ago
  • Status changed to Needs work 4 months ago
  • 🇮🇳India sarwan_verma

    Reviewed MR !3 and found one error below.

    Kindly fix the remaining issue.

    Thanks

    vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,yml,twig../ ~/project/drupal10/web/modules/contrib/redirects_fixer

    FILE: /home/developer/project/drupal10/web/modules/contrib/redirects_fixer/src/BatchManager.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 6 LINES
    -----------------------------------------------------------------------------------------------------------------------
    126 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    198 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    200 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    206 | WARNING | Only string literals should be passed to t() where possible
    334 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    497 | WARNING | Only string literals should be passed to t() where possible
    -----------------------------------------------------------------------------------------------------------------------

    FILE: /home/developer/project/drupal10/web/modules/contrib/redirects_fixer/src/LinksManager.php
    -----------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------
    86 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    -----------------------------------------------------------------------------------------------

    FILE: /home/developer/project/drupal10/web/modules/contrib/redirects_fixer/src/Controller/FixLinksController.php
    ----------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ----------------------------------------------------------------------------------------------------------------
    70 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    100 | WARNING | Avoid backslash escaping in translatable strings when possible, use "" quotes instead
    ----------------------------------------------------------------------------------------------------------------

    Time: 293ms; Memory: 12MB

  • Assigned to hetal.solanki
  • Issue was unassigned.
  • Status changed to RTBC 4 months ago
  • 🇮🇳India hetal.solanki

    Hello,

    I have reviewed and fixed the remaining issues. Now it's lookings good.
    I am moving it to RTBC.
    Thank you!!

  • 🇺🇦Ukraine Eugene Bsk Ukraine

    @hetalsolanki
    Did you test changes?

    Error: Call to undefined method Drupal\redirects_fixer\BatchManager::configFactory() in Drupal\redirects_fixer\BatchManager->__construct() (line 128 of modules/contrib/redirects_fixer/src/BatchManager.php).

  • 🇺🇦Ukraine Eugene Bsk Ukraine

    eugene_bsk changed the visibility of the branch 3462349-fix-phpcs-errors to hidden.

  • 🇺🇦Ukraine Eugene Bsk Ukraine

    eugene_bsk changed the visibility of the branch 3462349-fix-phpcs-errors to active.

  • Status changed to Fixed 4 months ago
  • 🇨🇦Canada dstorozhuk Chicago 🇺🇸, Toronto 🇨🇦, Kyiv 🇺🇦

    Hetal.Solanki , sarwan_verma, Sourav_Paul if you propose some changes in a code - please test the code manually before creating MR.
    Fixing the code with automated tool have zero sense if module become broken after that.
    Thanks.

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

Production build 0.71.5 2024