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
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

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

annmarysruthy’s picture

Assigned: Unassigned » annmarysruthy
annmarysruthy’s picture

Assigned: annmarysruthy » Unassigned
rassoni’s picture

Assigned: Unassigned » rassoni

After 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

rassoni’s picture

Assigned: rassoni » Unassigned

eduardo morales alberti’s picture

Thank you, _pratik_, is a good start.

eduardo morales alberti’s picture

Title: Fix codign standards on branch 3.x before a oficial release » Fix coding standards on branch 3.x before an official release

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

urvashi_vora’s picture

Facing 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.

sakthi_dev’s picture

Status: Needs work » Needs review
StatusFileSize
new34.42 KB

Created a patch. Please review.

avpaderno’s picture

Issue tags: +Coding standards
arpitk’s picture

Status: Needs review » Needs work
StatusFileSize
new130.98 KB

HI 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!

chaitanyadessai’s picture

Status: Needs work » Needs review
StatusFileSize
new43.35 KB

Fixed most fixable issues.

avpaderno’s picture

Status: Needs review » Needs work

The 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:

Solve the following coding standard

He did not open an issue to solve all the warnings/errors reported by PHP_CodeSniffer.

Changes like this are not correct.

-        $title = t($settings['side_panel_caption']);
+        $title = ($settings['side_panel_caption']);

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.

-      $identity_id = $identity['id'];
+      // $identity_id = $identity['id'];

The values set with CURLOPT_RETURNTRANSFER and CURLOPT_SSL_VERIFYHOST are described as Boolean values. I am not sure it is necessary to explicitly pass a Boolean value, though, since PHP consider 0 as equivalent of FALSE, and 1 as equivalent of TRUE.

     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
-    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
+    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, TRUE);
     curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);

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.

-  public function get_social_network_profile_data() {
-    return $this->social_network_profile_data;
+  public function getsocialNetworkProfileData() {
+    return $this->socialNetworkProfileData;
   }