Problem/Motivation

Getting Following errors/warnings

$ phpcs --standard=Drupal username_validation

FILE: ...min\Desktop\task\username_validation\src\Form\UserNameValidationConfig.php
--------------------------------------------------------------------------------
FOUND 7 ERRORS AND 1 WARNING AFFECTING 8 LINES
--------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found
     |         |     "\r\n"
  12 | WARNING | [ ] The class short comment should describe what the class
     |         |     does and not simply repeat the class name
  73 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
  83 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
  90 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
  97 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
 106 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
 115 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 458ms; Memory: 8MB

Proposed resolution

Fix the errors and warnings.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Jay Jangid created an issue. See original summary.

jay jangid’s picture

Assigned: jay jangid » Unassigned
Status: Active » Needs review

Created MR , please review.

Thank you.

realsp’s picture

Status: Needs review » Needs work
Issue tags: +Coding standards

Found following phpcs issues in MR #2,

FILE: /home/contribution/drupal/web/modules/contrib/username_validation/username_validation.routing.yml
-----------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
 10 | ERROR | [x] Expected 1 newline at end of file; 2 found
-----------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/username_validation/username_validation.links.menu.yml
--------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------
 7 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/username_validation/username_validation.module
------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 11 ERRORS AND 4 WARNINGS AFFECTING 15 LINES
------------------------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] Missing file doc comment
   9 | WARNING | [ ] Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar()
     |         |     for xyz-bar.html.twig.", "* Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or "* Implements hook_foo_BAR_ID_bar() for block
     |         |     templates."
  23 | WARNING | [ ] Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar()
     |         |     for xyz-bar.html.twig.", "* Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or "* Implements hook_foo_BAR_ID_bar() for block
     |         |     templates."
  30 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
  55 | ERROR   | [ ] All functions defined in a module file must be prefixed with the module's name, found "_get_username_from_db" but expected
     |         |     "username_validation__get_username_from_db"
  69 | ERROR   | [ ] Missing parameter comment
  70 | ERROR   | [ ] Missing parameter comment
  72 | ERROR   | [ ] Description for the @return value is missing
  82 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
 114 | ERROR   | [x] Expected one space after the comma, 0 found
 122 | ERROR   | [ ] Missing short description in doc comment
 153 | ERROR   | [x] Expected one space after the comma, 0 found
 156 | ERROR   | [x] Whitespace found at end of line
 158 | WARNING | [ ] Only string literals should be passed to t() where possible
 161 | WARNING | [ ] Only string literals should be passed to t() where possible
------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------------------

realsp’s picture

Assigned: Unassigned » realsp

I'll update the MR to fix the remaining phpcs issues

realsp’s picture

Assigned: realsp » Unassigned
Status: Needs work » Needs review

I've fixed the remaining phpcs issues in the MR, Please review the MR.
Thank you.

VladimirAus made their first commit to this issue’s fork.

vladimiraus’s picture

Status: Needs review » Needs work

Grevil made their first commit to this issue’s fork.

grevil’s picture

Title: Drupal Coding Standards Issues | phpcs » Drupal Coding Standards Issues | phpcs, phpstan, cspell
grevil’s picture

Status: Needs work » Needs review
Issue tags: -Coding standards

Alright, this issue can be reviewed. There are a few dangerous, but necessary changes here, we need to manually test them first, before merging.

The eslint issue needs to be fixed in a separate issue, they are related to the empty config file (which shouldn't be empty of course), but not related to this issue. I will quickly fix the remaining cspell issues tomorrow and do some quick manually tests for the form_state "getValues()" changes and then we can commit this. Codewise, this can already get reviewed!

I'd say this will be the last commit for 1.x any further work for refactoring, etc. should be done in 2.x. (Note that we also need to cherry-pick this into 2.x once finished).

grevil’s picture

Alright, all fixed and working as expected, please review!

anybody’s picture

Status: Needs review » Reviewed & tested by the community

LGTM, thx!

anybody’s picture

grevil’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all, fixed!

grevil’s picture

Version: 8.x-1.x-dev » 2.x-dev

  • Grevil committed b1127729 on 2.x authored by Jay Jangid
    Issue #3337901: Drupal Coding Standards Issues | phpcs
    
    
    (cherry picked...
vladimiraus’s picture

Status: Fixed » Closed (fixed)

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