Problem/Motivation

Fix the phpcs issues reported.

FILE: password_policy_history/tests/src/Unit/PasswordHistoryTest.php
------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------
 131 | ERROR | [x] Missing function doc comment
 134 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------


FILE: password_policy_history/password_policy_history.module
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 32 | ERROR | The $_POST super global must not be accessed directly; inject the request.stack service and use $stack->getCurrentRequest()->request->get('pass') instead
 32 | ERROR | The $_POST super global must not be accessed directly; inject the request.stack service and use $stack->getCurrentRequest()->request->get('pass') instead
------------------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: src/Plugin/migrate/process/PolicyConfiguration.php
------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------
 127 | ERROR | Type hint "array" missing for $value
------------------------------------------------------------------------------------------------------

Time: 2.28 secs; Memory: 14MB

Steps to reproduce

Run phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,css,info,yml .

Proposed resolution

Fix the issues reported and re-run the above command to check all issues are fixed.

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

hardikpandya created an issue. See original summary.

hardikpandya’s picture

Assigned: hardikpandya » Unassigned
Status: Active » Needs review
avpaderno’s picture

Title: Fix Drupal Coding Standards | phpcs » Fix the issues reported by phpcs
Category: Bug report » Task
Priority: Normal » Minor
Status: Needs review » Needs work
Issue tags: +Coding standards
+  /**
+   * Set ReflectionClass object.
+   */

That does not describe what the method does. Then, parameters are not documented, nor is the return value.

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

kunalgautam’s picture

Status: Needs work » Needs review

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

avpaderno’s picture

Status: Needs review » Needs work
-  public function setProtectedProperty($object, $property, $value) {
-    $reflection = new \ReflectionClass($object);
-    $reflection_property = $reflection->getProperty($property);
-    $reflection_property->setAccessible(true);
-    $reflection_property->setValue($object, $value);
-  }

What reported by PHP_CodeSniffer and shown in the issue summary does not say that method must be removed.

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

sakthi_dev’s picture

Status: Needs work » Needs review

Please review.

avpaderno’s picture

Status: Needs review » Needs work
+   * @param $object
+   *   The object variable.
+   * @param $property
+   *   The property variable.
+   * @param $value.
+   *   The variable of value.

Parameters are not described that way. It is not a helpful description, since it repeats the parameter names, adding variable. (Yes, a parameter is a local variable accessible from the function/method. That is how PHP works.)

+   * @return NULL
+   *   Returns Null.
+   */

If a method/function does not return anything, @return does not need to be added.

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

diego_mow’s picture

Status: Needs work » Needs review

MR 50 fixes same code from MR 49 + Comments on #13.

alina.basarabeanu’s picture

I applied the changes from MR 50 to Drupal Version 9.5.10 and Password Policy 4.0.0 but I still get a lot of phpcs errors.
I will list just a few.

FILE: /docroot/modules/contrib/password_policy/password_policy_delay/src/Plugin/PasswordConstraint/PasswordDelay.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------
12 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Password\PasswordInterface.
---------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------

FILE: /docroot/modules/contrib/password_policy/PATCHES.txt
-----------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------
1 | WARNING | [ ] Line exceeds 80 characters; contains 104 characters
5 | ERROR | [x] Expected 1 newline at end of file; 3 found
-----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------

FILE: /docroot/modules/contrib/password_policy/password_policy.module
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------
10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityInterface.
---------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY

FILE: /docroot/modules/contrib/password_policy/password_policy_history/tests/src/Unit/PasswordHistoryTest.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
---------------------------------------------------------------------------------------------------------------------------
7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Password\PasswordInterface.
22 | ERROR | [x] Data types in @var tags need to be fully namespaced
129 | ERROR | [x] Expected 1 blank line after function; 0 found
130 | ERROR | [ ] Parameter $value is not described in comment
137 | ERROR | [x] Doc comment parameter name "$value." must not end with a dot
---------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------

nisha_j’s picture

Status: Needs review » Needs work

Anjali Mehta made their first commit to this issue’s fork.

anjali mehta’s picture

Kindly review the changes.
Thank you.

anjali mehta’s picture

Status: Needs work » Needs review
kristen pol’s picture

Assigned: Unassigned » kristen pol

Assigning to myself for review.

kristen pol’s picture

Version: 4.0.0 » 4.0.x-dev

Duplicate issue found. I'll need to close one of these.

#3367028: Fix the issues reported by phpcs

apaderno changed the visibility of the branch 3347789-phpcs to hidden.

apaderno changed the visibility of the branch phpcs-3347789 to hidden.

apaderno changed the visibility of the branch 3347789-fix-phpcs-issues to hidden.

kristen pol’s picture

Assigned: kristen pol » Unassigned
Status: Needs review » Needs work

Merge conflict needs fixing.

kristen pol’s picture

Copying issue credits for people who worked on duplicate issue:

#3367028: Fix the issues reported by phpcs

vishalkhode’s picture

Status: Needs work » Closed (outdated)

Closing as this is fixed in #3464639: Fix Validate pipeline.