Coding standards fixes remaining
Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib
$ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,js,yml weight/
FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\contrib\weight\views\views_handler_weight_selector.inc
-------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 1 WARNING AFFECTING 5 LINES
-------------------------------------------------------------------------------------------------------------------
6 | ERROR | Class name must begin with a capital letter
6 | ERROR | Class name must use UpperCamel naming without underscores
6 | WARNING | Class name must be prefixed with the project name "Weight"
28 | ERROR | Public method name "views_handler_weight_selector::option_definition" is not in lowerCamel format
46 | ERROR | Public method name "views_handler_weight_selector::options_form" is not in lowerCamel format
91 | ERROR | Public method name "views_handler_weight_selector::views_form" is not in lowerCamel format
158 | ERROR | Public method name "views_handler_weight_selector::views_form_submit" is not in lowerCamel format
-------------------------------------------------------------------------------------------------------------------
FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\contrib\weight\weight.module
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
153 | 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."
192 | 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."
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Time: 357ms; Memory: 10MB
Steps to reproduce
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml weight/
Comments
Comment #3
vladimirausComment #6
annmarysruthy commentedMade commit to fix some more issues in phpcs. However 1 warning is remaining which cannot be solved.
FILE: /var/www/html/web/modules/contrib/weight-3343609/weight.views.inc
-----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------
17 | WARNING | Unused variable $table_name.
-----------------------------------------------------------------------
we cannot remove the $table_name variable from the foreach loop because it is used as a key in the $data array. Removing it would cause an error in the loop, as it would not be possible to access the data in the $data array without the key.
Comment #7
annmarysruthy commentedComment #8
vladimirausThanks for commit. phpcs return other errors
Comment #9
nmorin commentedGetting Error when attempting to update weight module... Is this related to the errors in the previous comments?
^^ This was after "drush up" command was issued...
Comment #10
dhigby commentedI got the same "unexpected '?'" error, reported here: https://www.drupal.org/project/weight/issues/3344820
Comment #11
vladimirausPatch was pushed for testing for #3344820: Apache 500 error with 7.x-3.2.
Please test.
Comment #12
avpadernoComment #13
sourabhjainComment #16
zkhan.aamir commentedHi,
MR #15 applied successfully.
Remaining issues
Comment #17
zkhan.aamir commentedIssue summary updated.
Comment #19
yashaswi18 commentedHello, after checking out to the branch '3343609-7.x-phpcs-coding', found these errors remaining :
Comment #21
chandansha commentedComment #22
roberttabigue commentedHi @avpaderno,
After reviewing and applied the MR!10 to the Weight module against 7.x-3.x-dev on Drupal 10, I still see 1 PHPCS warning.
See below:
I ran this command on the module:
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml,css,js weight/I'm moving this to ‘Needs work’ for now.
Thank you!
Comment #23
avpadernoGitLab CI does not report any PHP_CodeSniffer error/warning.
phpcs --standard=Drupal,DrupalPracticedoes not applies the same PHP_CodeSniffer rules GitLab CI applies, which means it can give different errors/warnings, but that is irrelevant, since GitLab CI is used to test the project.Comment #24
vladimirausComment #25
anybodyHere's the fix for modern Drupal: #3481730: Fix phpcs, cspell and phpunit could both be merged perhaps?
Comment #28
vladimirausThanks, everyone! 🧁
Committed!
Comment #29
vladimiraus