Problem/Motivation
Here is a list of the phpcs issue to fix:
E.E....E.E.... 14 / 14 (100%)
FILE: /var/www/html/web/modules/custom/auto_username/src/Form/AutoUsernameSettingsForm.php
------------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------------------------
11 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
| | Drupal\auto_username\AutoUsernameUtilities.
18 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
35 | ERROR | [ ] Missing short description in doc comment
287 | ERROR | [x] Expected 1 blank line after function; 2 found
290 | 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: /var/www/html/web/modules/custom/auto_username/src/AutoUsernameUtilities.php
------------------------------------------------------------------------------------------------------------------------
FOUND 48 ERRORS AND 33 WARNINGS AFFECTING 49 LINES
------------------------------------------------------------------------------------------------------------------------
16 | ERROR | [x] Missing class doc comment
18 | ERROR | [ ] Missing short description in doc comment
23 | ERROR | [ ] Missing short description in doc comment
28 | ERROR | [ ] Missing short description in doc comment
33 | ERROR | [ ] Missing short description in doc comment
38 | ERROR | [ ] Missing short description in doc comment
43 | ERROR | [ ] Missing short description in doc comment
48 | ERROR | [ ] Missing short description in doc comment
56 | ERROR | [ ] Missing parameter comment
57 | ERROR | [ ] Missing parameter comment
58 | ERROR | [ ] Missing parameter comment
59 | ERROR | [ ] Missing parameter comment
60 | ERROR | [ ] Missing parameter comment
61 | ERROR | [ ] Missing parameter comment
62 | ERROR | [ ] Missing parameter comment
121 | ERROR | [ ] The array declaration extends to column 99 (the limit is 80). The array content should be split up
| | over multiple lines
121 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
122 | ERROR | [ ] The array declaration extends to column 113 (the limit is 80). The array content should be split
| | up over multiple lines
122 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
123 | ERROR | [ ] The array declaration extends to column 86 (the limit is 80). The array content should be split up
| | over multiple lines
123 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
124 | ERROR | [ ] The array declaration extends to column 82 (the limit is 80). The array content should be split up
| | over multiple lines
124 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
125 | ERROR | [ ] The array declaration extends to column 83 (the limit is 80). The array content should be split up
| | over multiple lines
125 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
126 | ERROR | [ ] The array declaration extends to column 83 (the limit is 80). The array content should be split up
| | over multiple lines
126 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
127 | ERROR | [ ] The array declaration extends to column 87 (the limit is 80). The array content should be split up
| | over multiple lines
127 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
128 | ERROR | [ ] The array declaration extends to column 82 (the limit is 80). The array content should be split up
| | over multiple lines
128 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
129 | ERROR | [ ] The array declaration extends to column 86 (the limit is 80). The array content should be split up
| | over multiple lines
129 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
130 | ERROR | [ ] The array declaration extends to column 96 (the limit is 80). The array content should be split up
| | over multiple lines
130 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
131 | ERROR | [ ] The array declaration extends to column 95 (the limit is 80). The array content should be split up
| | over multiple lines
131 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
132 | ERROR | [ ] The array declaration extends to column 96 (the limit is 80). The array content should be split up
| | over multiple lines
132 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
133 | ERROR | [ ] The array declaration extends to column 96 (the limit is 80). The array content should be split up
| | over multiple lines
133 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
134 | ERROR | [ ] The array declaration extends to column 97 (the limit is 80). The array content should be split up
| | over multiple lines
134 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
135 | ERROR | [ ] The array declaration extends to column 86 (the limit is 80). The array content should be split up
| | over multiple lines
135 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
136 | ERROR | [ ] The array declaration extends to column 87 (the limit is 80). The array content should be split up
| | over multiple lines
136 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
137 | ERROR | [ ] The array declaration extends to column 85 (the limit is 80). The array content should be split up
| | over multiple lines
137 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
138 | ERROR | [ ] The array declaration extends to column 86 (the limit is 80). The array content should be split up
| | over multiple lines
138 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
139 | ERROR | [ ] The array declaration extends to column 89 (the limit is 80). The array content should be split up
| | over multiple lines
139 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
140 | ERROR | [ ] The array declaration extends to column 82 (the limit is 80). The array content should be split up
| | over multiple lines
140 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
141 | ERROR | [ ] The array declaration extends to column 88 (the limit is 80). The array content should be split up
| | over multiple lines
141 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
142 | ERROR | [ ] The array declaration extends to column 107 (the limit is 80). The array content should be split
| | up over multiple lines
142 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
143 | ERROR | [ ] The array declaration extends to column 84 (the limit is 80). The array content should be split up
| | over multiple lines
143 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
144 | ERROR | [ ] The array declaration extends to column 93 (the limit is 80). The array content should be split up
| | over multiple lines
144 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
145 | ERROR | [ ] The array declaration extends to column 82 (the limit is 80). The array content should be split up
| | over multiple lines
145 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
146 | ERROR | [ ] The array declaration extends to column 93 (the limit is 80). The array content should be split up
| | over multiple lines
146 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
147 | ERROR | [ ] The array declaration extends to column 94 (the limit is 80). The array content should be split up
| | over multiple lines
147 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
148 | ERROR | [ ] The array declaration extends to column 90 (the limit is 80). The array content should be split up
| | over multiple lines
148 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
149 | ERROR | [ ] The array declaration extends to column 91 (the limit is 80). The array content should be split up
| | over multiple lines
149 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
150 | ERROR | [ ] The array declaration extends to column 94 (the limit is 80). The array content should be split up
| | over multiple lines
150 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
151 | ERROR | [ ] The array declaration extends to column 82 (the limit is 80). The array content should be split up
| | over multiple lines
151 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
152 | ERROR | [ ] The array declaration extends to column 87 (the limit is 80). The array content should be split up
| | over multiple lines
152 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
203 | WARNING | [ ] The use of function eval() is discouraged
325 | ERROR | [ ] The array declaration extends to column 89 (the limit is 80). The array content should be split up
| | over multiple lines
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------
FILE: /var/www/html/web/modules/custom/auto_username/config/install/auto_username.settings.yml
----------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
11 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------
FILE: /var/www/html/web/modules/custom/auto_username/auto_username.module
------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 10 WARNINGS AFFECTING 7 LINES
------------------------------------------------------------------------------------------------------------------------
13 | WARNING | [ ] All constants defined by a module must be prefixed with the module's name, expected
| | "AUTO_USERNAME_AUN_CASE_LEAVE_ASIS" but found "AUN_CASE_LEAVE_ASIS"
13 | WARNING | [ ] Global constants should not be used, move it to a class or interface
18 | WARNING | [ ] All constants defined by a module must be prefixed with the module's name, expected
| | "AUTO_USERNAME_AUN_CASE_LOWER" but found "AUN_CASE_LOWER"
18 | WARNING | [ ] Global constants should not be used, move it to a class or interface
23 | WARNING | [ ] All constants defined by a module must be prefixed with the module's name, expected
| | "AUTO_USERNAME_AUN_PUNCTUATION_REMOVE" but found "AUN_PUNCTUATION_REMOVE"
23 | WARNING | [ ] Global constants should not be used, move it to a class or interface
28 | WARNING | [ ] All constants defined by a module must be prefixed with the module's name, expected
| | "AUTO_USERNAME_AUN_PUNCTUATION_REPLACE" but found "AUN_PUNCTUATION_REPLACE"
28 | WARNING | [ ] Global constants should not be used, move it to a class or interface
33 | WARNING | [ ] All constants defined by a module must be prefixed with the module's name, expected
| | "AUTO_USERNAME_AUN_PUNCTUATION_DO_NOTHING" but found "AUN_PUNCTUATION_DO_NOTHING"
33 | WARNING | [ ] Global constants should not be used, move it to a class or interface
63 | ERROR | [x] Short array syntax must be used to define arrays
93 | ERROR | [x] Expected 1 newline at end of file; 3 found
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------
Steps to reproduce
Proposed resolution
Refactor legacy code and fix phpcs issues.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #40 | Screenshot from 2024-07-17 10-43-04.png | 28.14 KB | hetal.solanki |
| #35 | auto_username-phpcs-3391633-35.patch | 764 bytes | liam morland |
| #27 | Screenshot from 2024-05-29 12-37-45.png | 105.44 KB | tirupati_singh |
| #24 | auto_username-issue-3391633.png | 51.15 KB | silvi.addweb |
| #15 | Screenshot from 2024-01-05 13-02-53.png | 142.99 KB | tirupati_singh |
Issue fork auto_username-3391633
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
Comment #2
anybody@Grevil: Perhaps we should better split off the code style fixes from the probably legacy code?
I think these are different concerns and the maintainer should have a look at that code, while fixing the code style issues should be a quick-win?
Comment #3
grevil commentedSure thing! Although a lot phpcs issues are related to legacy code.
Comment #4
shreya_th commentedComment #6
shreya_th commentedHi @Grevil,
I have fixed all the code standard issues and also created MR for this issue . Kindly review the changes.
Comment #7
shreya_th commentedAttached screenshot for your reference.
Comment #8
anybodyThanks @Shreya_th looks good, but some things need to be resolved, see my comments.
Comment #9
mohd sahzad commentedComment #10
mohd sahzad commentedComment #11
viren18febs commentedComment #12
liam morlandThe two new class files have no newline at end of file.
The constants are moved into these class files but the new constants are not used.
Comment #14
sidharth_soman commentedComment #15
tirupati_singh commentedI've installed this module but getting error after installing this module. Attaching screenshot for reference. This is occurred after fixing phpcs issues.
Comment #16
tirupati_singh commentedFixed issue of string translation undefined method, the module is now being install. Please review.
Comment #18
venkatraman ganesan commentedI ran the command phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml and found no phpcs errors.
Comment #19
liam morlandFor a full test, use
phpcbf --standard=Drupal,DrupalPractice.Comment #20
pray_12 commentedhello,
I ran the command phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml and found no phpcs errors.
Comment #21
liam morlandPerhaps your version of phpcs is out-of-date. I got a bunch of errors when I that command. You do need to provide a filename to check. I usually check the current directory by adding a
.at the end of the command you gave and running it from the repository directory.Comment #22
yashaswi18 commentedIs this the command
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml .?I ran this command inside the repository directory, still not able to find any remaining errors or warnings. Please correct if the command I used is wrong.
Branch: 3391633-fix-phpcs-issues
Comment #23
liam morlandThis is the exact command I use:
phpcs --standard=Drupal,DrupalPractice --report-width=auto --colors --extensions=php,module,inc,install,test,profile,theme,info,txt,md,scss,yml,twig .I don't know why we're getting different results. If automated testing is configured that can be used as the ultimate arbiter of coding standards.
Comment #24
silvi.addweb commentedI have tested and I got some deprecation error in create_function(), please review attached image.
Comment #25
liam morlandIn the merge request, I have added
.gitlab-ci.ymlso that coding standards checks will run.Comment #26
liam morlandcreate_function()was removed in PHP 8.0. It needs to be removed. It is used once insrc/AutoUsernameUtilities.php.Comment #27
tirupati_singh commented@Liam Morland, I've used the exact command that you've provided
phpcs --standard=Drupal,DrupalPractice --report-width=auto --colors --extensions=php,module,inc,install,test,profile,theme,info,txt,md,scss,yml,twig ., still I'm not getting any phpcs issues. Attaching the screenshot for reference. Moving the issue status to Needs Review.Comment #28
tirupati_singh commentedComment #29
liam morlandLooks good. phpcs is passing on the GitLab CI.
Comment #30
liam morlandSorry, commit 3a3f791, "Fixed phpcs issues", adds the use of
create_function(), which was removed in PHP 8.0.A good way to start would be to merge commit 3cb2db2, "Add .gitlab-ci.yml from template". Then every merge request will be getting coding standards checking.
Comment #31
liam morlandI reverted the change that introduced
create_function(). I added aphpcs:ignoreso that the use ofeval()does not cause aphpcsfailure.I have fixed some spelling errors and added a list of words to ignore. Now all checks pass.
Comment #32
paraderojether commentedHi
I reviewed MR!5, and confirmed it fixes all the issues reported by phpcs.
Moving this to RTBC.
Thank you.
Comment #34
jayelless commentedTanks everyone for your contributions in improving the module. Changes committed.
Comment #35
liam morlandThere is one more error; fix attached.
Comment #37
tirupati_singh commentedFixed the remaining phpcs issue. Please review the MR.
Comment #38
hetal.solankiComment #39
riddhi.addweb commentedThe mentioned phpcs issue is resolved, & I have also checked and it is working as expected. I am attaching the Screenshots & doing RTBC for the same.
Comment #40
hetal.solanki@Grevil, @Tirupati_Singh
I have tested MR and it is working properly with no errors found. I will move it forward to RTBC.
Thank you!!
Comment #42
jayelless commentedMerged to 8.x-1.x
Comment #46
liam morlandphpcs now passes.
Comment #48
jayelless commentedMerged to branch 2.0.x.
Thanks for all the help.