Fix the issues reported by phpcs

Created on 24 April 2023, over 1 year ago
Updated 4 May 2023, over 1 year ago

Problem/Motivation

C:\xampp\htdocs\backendassignment\web\modules\contrib>phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig view_modes_display

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\view_modes_display\README.md
----------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------
13 | WARNING | Line exceeds 80 characters; contains 81 characters
28 | WARNING | Line exceeds 80 characters; contains 99 characters
----------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\view_modes_display\src\Controller\PreviewController.php
------------------------------------------------------------------------------------------------------------------------
FOUND 9 ERRORS AND 9 WARNINGS AFFECTING 17 LINES
------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
6 | WARNING | [x] Unused use statement
8 | WARNING | [x] Unused use statement
10 | WARNING | [x] Unused use statement
11 | WARNING | [x] Unused use statement
12 | WARNING | [x] Unused use statement
13 | WARNING | [x] Unused use statement
76 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
76 | ERROR | [ ] Missing parameter comment
82 | ERROR | [x] Data types in @var tags need to be fully namespaced
96 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
106 | ERROR | [ ] Missing parameter comment
107 | ERROR | [ ] Missing parameter comment
109 | ERROR | [ ] Description for the @return value is missing
110 | ERROR | [x] Separate the @return and @throws sections by a blank line.
118 | ERROR | [x] Data types in @var tags need to be fully namespaced
131 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
137 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\view_modes_display\src\EntityTypeInfo.php
-----------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
36 | ERROR | [ ] Parameter $entityDisplayRepository is not described in comment
69 | WARNING | [ ] Unused variable $viewModes.
-----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------

FILE: ...htdocs\backendassignment\web\modules\contrib\view_modes_display\src\Plugin\Derivative\ViewModeDisplayLocalTask.php
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\view_modes_display\src\Routing\RouteSubscriber.php
------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 1 WARNING AFFECTING 7 LINES
------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
33 | ERROR | [ ] Parameter $entityDisplayRepository is not described in comment
39 | ERROR | [x] Expected 1 blank line before function; 2 found
49 | WARNING | [ ] Unused variable $viewModes.
54 | ERROR | [x] Space found before comma in argument list
116 | ERROR | [x] No space found before comment text; expected "// ->setOption('_admin_route', TRUE)" but found
| | "//->setOption('_admin_route', TRUE)"
130 | ERROR | [x] Short array syntax must be used to define arrays
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\view_modes_display\src\Service\PreviewFactory.php
----------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
14 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
84 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
162 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\view_modes_display\view_modes_display.module
--------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
10 | ERROR | [x] When importing a class with "use", do not include a leading \
--------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------

Time: 1.79 secs; Memory: 6MB

Steps to reproduce

Fix the issues reported by phpcs.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

3.0

Component

Code

Created by

🇮🇳India sidharth_soman Bangalore

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sidharth_soman
  • 🇬🇧United Kingdom zach.bimson

    Can you please provide the cli command you and and the standard you used please

  • @sidharth_soman opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India sidharth_soman Bangalore

    I'm using PHP_CodeSniffer version 3.7.2. I've fixed all the above issues except a dependency injection in PreviewController.php and some documentation warnings for readability and so on.

    I've issued an MR for the same. It's against the 3.x branch. Please review.

  • 🇮🇳India sidharth_soman Bangalore

    I can make a separate issue for implementing the dependency injection if it's required.

  • Assigned to zach.bimson
  • Status changed to Fixed over 1 year ago
  • Status changed to Fixed over 1 year ago
  • 🇬🇧United Kingdom zach.bimson

    Committed to dev! thanks for the MR, i think the DI may have been resolved on 3.x already but if you spot something please raise a new issue!

Production build 0.71.5 2024