Problem/Motivation
Make a Drupal stable module based on https://github.com/oneall/social-login-drupal
Proposed resolution
Solve the following coding standard:
wodby@php.container:/var/www/html $ phpcs --standard=Drupal,DrupalPractice web/modules/contrib/social_login/
FILE: /var/www/html/docroot/modules/contrib/social_login/src/Event/SocialLoginUserLinkedEvent.php
------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 6 LINES
------------------------------------------------------------------------------------------------------
23 | ERROR | Missing @var tag in member variable comment
24 | ERROR | Class property $social_network_profile_data should use lowerCamel naming without
| | underscores
37 | ERROR | Public method name "SocialLoginUserLinkedEvent::set_social_network_profile_data" is not
| | in lowerCamel format
44 | ERROR | Public method name "SocialLoginUserLinkedEvent::get_social_network_profile_data" is not
| | in lowerCamel format
51 | ERROR | Public method name "SocialLoginUserLinkedEvent::set_account" is not in lowerCamel
| | format
58 | ERROR | Public method name "SocialLoginUserLinkedEvent::get_account" is not in lowerCamel
| | format
------------------------------------------------------------------------------------------------------
FILE: /var/www/html/docroot/modules/contrib/social_login/src/Event/SocialLoginUserLoginEvent.php
------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------
24 | ERROR | Class property $social_network_profile_data should use lowerCamel naming without
| | underscores
37 | ERROR | Public method name "SocialLoginUserLoginEvent::set_social_network_profile_data" is not
| | in lowerCamel format
44 | ERROR | Public method name "SocialLoginUserLoginEvent::get_social_network_profile_data" is not
| | in lowerCamel format
51 | ERROR | Public method name "SocialLoginUserLoginEvent::set_account" is not in lowerCamel format
58 | ERROR | Public method name "SocialLoginUserLoginEvent::get_account" is not in lowerCamel format
------------------------------------------------------------------------------------------------------
FILE: /var/www/html/docroot/modules/contrib/social_login/src/Event/SocialLoginUserCreatedEvent.php
------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------
23 | ERROR | Class property $social_network_profile_data should use lowerCamel naming without
| | underscores
36 | ERROR | Public method name "SocialLoginUserCreatedEvent::set_social_network_profile_data" is
| | not in lowerCamel format
43 | ERROR | Public method name "SocialLoginUserCreatedEvent::get_social_network_profile_data" is
| | not in lowerCamel format
50 | ERROR | Public method name "SocialLoginUserCreatedEvent::set_account" is not in lowerCamel
| | format
57 | ERROR | Public method name "SocialLoginUserCreatedEvent::get_account" is not in lowerCamel
| | format
------------------------------------------------------------------------------------------------------
FILE: /var/www/html/docroot/modules/contrib/social_login/src/Plugin/Block/SocialLoginBlock.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
43 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------
FILE: /var/www/html/docroot/modules/contrib/social_login/src/Form/SocialLoginBlock.php
---------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
---------------------------------------------------------------------------------------------
39 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
80 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------
FILE: /var/www/html/docroot/modules/contrib/social_login/src/Form/SocialLoginAdminSettings.php
------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------
464 | ERROR | The array declaration extends to column 124 (the limit is 80). The array content
| | should be split up over multiple lines
470 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------
FILE: /var/www/html/docroot/modules/contrib/social_login/src/Controller/SocialLoginController.php
------------------------------------------------------------------------------------------------------
FOUND 15 ERRORS AND 25 WARNINGS AFFECTING 36 LINES
------------------------------------------------------------------------------------------------------
47 | ERROR | The $_POST super global must not be accessed directly; inject the request_stack
| | service and use $stack->getCurrentRequest()->request instead
47 | ERROR | The $_POST super global must not be accessed directly; inject the request_stack
| | service and use $stack->getCurrentRequest()->request->get('connection_token')
| | instead
47 | ERROR | The $_POST super global must not be accessed directly; inject the request_stack
| | service and use $stack->getCurrentRequest()->request->get('oa_action') instead
47 | ERROR | The $_POST super global must not be accessed directly; inject the request_stack
| | service and use $stack->getCurrentRequest()->request->get('oa_action') instead
47 | ERROR | The array declaration extends to column 155 (the limit is 80). The array content
| | should be split up over multiple lines
49 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
50 | ERROR | The $_POST super global must not be accessed directly; inject the request_stack
| | service and use $stack->getCurrentRequest()->request->get('connection_token')
| | instead
71 | ERROR | The array declaration extends to column 113 (the limit is 80). The array content
| | should be split up over multiple lines
75 | ERROR | The array declaration extends to column 97 (the limit is 80). The array content
| | should be split up over multiple lines
78 | ERROR | The $_POST super global must not be accessed directly; inject the request_stack
| | service and use $stack->getCurrentRequest()->request->get('connection_token')
| | instead
88 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
145 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
169 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
174 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
190 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
199 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
215 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
226 | ERROR | The $_GET super global must not be accessed directly; inject the request_stack
| | service and use $stack->getCurrentRequest()->query->get('origin') instead
227 | ERROR | The $_GET super global must not be accessed directly; inject the request_stack
| | service and use $stack->getCurrentRequest()->query->get('origin') instead
251 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
256 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
264 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
273 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
293 | ERROR | The $_GET super global must not be accessed directly; inject the request_stack
| | service and use $stack->getCurrentRequest()->query->get('origin') instead
294 | ERROR | The $_GET super global must not be accessed directly; inject the request_stack
| | service and use $stack->getCurrentRequest()->query->get('origin') instead
316 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
422 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
430 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
432 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
453 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
457 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
467 | WARNING | User::load calls should be avoided in classes, use dependency injection instead
473 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
522 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
538 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
558 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
585 | ERROR | The $_GET super global must not be accessed directly; inject the request_stack
| | service and use $stack->getCurrentRequest()->query->get('origin') instead
586 | ERROR | The $_GET super global must not be accessed directly; inject the request_stack
| | service and use $stack->getCurrentRequest()->query->get('origin') instead
603 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
614 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------
Time: 631ms; Memory: 18MB
Comments
Comment #4
annmarysruthy commentedComment #5
annmarysruthy commentedComment #6
rassoni commentedAfter Applied MR few issue issues are fixed and found more errors. NW
FILE: /Users/rashmi.krishnachand/projects/drupal-d10/modules/contrib/social-login/README.md
-------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
-------------------------------------------------------------------------------------------
35 | WARNING | Line exceeds 80 characters; contains 89 characters
36 | WARNING | Line exceeds 80 characters; contains 91 characters
37 | WARNING | Line exceeds 80 characters; contains 95 characters
96 | WARNING | Line exceeds 80 characters; contains 112 characters
-------------------------------------------------------------------------------------------
FILE: /Users/rashmi.krishnachand/projects/drupal-d10/modules/contrib/social-login/social_login.module
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 4 WARNINGS AFFECTING 7 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
180 | WARNING | Only string literals should be passed to t() where possible
194 | WARNING | Only string literals should be passed to t() where possible
209 | WARNING | Only string literals should be passed to t() where possible
219 | ERROR | Unnecessarily gendered language in a comment
235 | WARNING | Only string literals should be passed to t() where possible
437 | ERROR | Blank lines are not allowed after DEFAULT statements
678 | ERROR | The array declaration extends to column 105 (the limit is 80). The array content should be split up over multiple lines
-----------------------------------------------------------------------------------------------------------------------------------------
FILE: /Users/rashmi.krishnachand/projects/drupal-d10/modules/contrib/social-login/src/Form/SocialLoginAdminSettings.php
---------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------
464 | ERROR | The array declaration extends to column 124 (the limit is 80). The array content should be split up over multiple lines
---------------------------------------------------------------------------------------------------------------------------------------
FILE: /Users/rashmi.krishnachand/projects/drupal-d10/modules/contrib/social-login/src/Controller/SocialLoginController.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------------------------------------------------------------
47 | ERROR | The array declaration extends to column 155 (the limit is 80). The array content should be split up over multiple lines
71 | ERROR | The array declaration extends to column 113 (the limit is 80). The array content should be split up over multiple lines
75 | ERROR | The array declaration extends to column 97 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------
FILE: /Users/rashmi.krishnachand/projects/drupal-d10/modules/contrib/social-login/src/Event/SocialLoginUserLinkedEvent.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 6 LINES
---------------------------------------------------------------------------------------------------------------------------
23 | ERROR | Missing @var tag in member variable comment
24 | ERROR | Class property $social_network_profile_data should use lowerCamel naming without underscores
37 | ERROR | Public method name "SocialLoginUserLinkedEvent::set_social_network_profile_data" is not in lowerCamel format
44 | ERROR | Public method name "SocialLoginUserLinkedEvent::get_social_network_profile_data" is not in lowerCamel format
51 | ERROR | Public method name "SocialLoginUserLinkedEvent::set_account" is not in lowerCamel format
58 | ERROR | Public method name "SocialLoginUserLinkedEvent::get_account" is not in lowerCamel format
---------------------------------------------------------------------------------------------------------------------------
FILE: /Users/rashmi.krishnachand/projects/drupal-d10/modules/contrib/social-login/src/Event/SocialLoginUserLoginEvent.php
--------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
--------------------------------------------------------------------------------------------------------------------------
24 | ERROR | Class property $social_network_profile_data should use lowerCamel naming without underscores
37 | ERROR | Public method name "SocialLoginUserLoginEvent::set_social_network_profile_data" is not in lowerCamel format
44 | ERROR | Public method name "SocialLoginUserLoginEvent::get_social_network_profile_data" is not in lowerCamel format
51 | ERROR | Public method name "SocialLoginUserLoginEvent::set_account" is not in lowerCamel format
58 | ERROR | Public method name "SocialLoginUserLoginEvent::get_account" is not in lowerCamel format
--------------------------------------------------------------------------------------------------------------------------
FILE: /Users/rashmi.krishnachand/projects/drupal-d10/modules/contrib/social-login/src/Event/SocialLoginUserCreatedEvent.php
----------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
----------------------------------------------------------------------------------------------------------------------------
23 | ERROR | Class property $social_network_profile_data should use lowerCamel naming without underscores
36 | ERROR | Public method name "SocialLoginUserCreatedEvent::set_social_network_profile_data" is not in lowerCamel format
43 | ERROR | Public method name "SocialLoginUserCreatedEvent::get_social_network_profile_data" is not in lowerCamel format
50 | ERROR | Public method name "SocialLoginUserCreatedEvent::set_account" is not in lowerCamel format
57 | ERROR | Public method name "SocialLoginUserCreatedEvent::get_account" is not in lowerCamel format
----------------------------------------------------------------------------------------------------------------------------
Time: 282ms; Memory: 16MB
Comment #7
rassoni commentedComment #9
eduardo morales albertiThank you, _pratik_, is a good start.
Comment #10
eduardo morales albertiComment #17
urvashi_vora commentedFacing some weird issue with the branch. Everytime taking pull of 3.x and pushing the changes in issue branch, but after creating a MR, it shows merge blocked.
HELP!!
Tried rebasing too.
Comment #18
sakthi_dev commentedCreated a patch. Please review.
Comment #19
avpadernoComment #20
arpitk commentedHI The patch #18 it applied cleanly. However these errors/warnings are produced when running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,js . Tested on Drupal 9.5.8 and social_login:3.x-dev
Thanks!
Comment #21
chaitanyadessai commentedFixed most fixable issues.
Comment #22
avpadernoThe issue summary shows that seven files must be changed, while the last patch changes 11 files.
Please notice this issue has been created from a maintainer for this project, who wrote:
He did not open an issue to solve all the warnings/errors reported by PHP_CodeSniffer.
Changes like this are not correct.
PHP would throw a Parse error: syntax error, unexpected token "," error.
Then, code that is not necessary is removed, not commented out. Changes like the following are not correct either.
The values set with
CURLOPT_RETURNTRANSFERandCURLOPT_SSL_VERIFYHOSTare described as Boolean values. I am not sure it is necessary to explicitly pass a Boolean value, though, since PHP consider 0 as equivalent ofFALSE, and 1 as equivalent ofTRUE.A public method name cannot be changed to remove underscores; such change is not backward compatible, if the class is not marked as internal. Every module using that method would start throwing errors.