Right now in module there are 100 errors and 25 warnings in 31 files.
In order to simplify review process this issue splited to several issues to fix specific phpcs rules.

Child issue with list of rules to fix:

#3411792: Fix phpcs Drupal.WhiteSpace, Squiz.WhiteSpace issues

  • Drupal.WhiteSpace.ScopeIndent
  • Drupal.WhiteSpace.OpenBracketSpacing
  • Drupal.WhiteSpace.CloseBracketSpacing
  • Squiz.WhiteSpace.FunctionSpacing
  • Squiz.WhiteSpace.SuperfluousWhitespace

#3411794: Fix phpcs Drupal.Arrays.Array issues

  • Drupal.Arrays.Array

#3411804: Fix phpcs Drupal.Classes, DrupalPractice.FunctionCalls, SlevomatCodingStandard.PHP, Drupal.Semantics

  • Drupal.Classes.UnusedUseStatement
  • DrupalPractice.FunctionCalls.InsecureUnserialize
  • SlevomatCodingStandard.PHP.ShortList
  • Drupal.Semantics.FunctionT

#3411807: Fix phpcs Drupal.Files.LineLength issues

  • Drupal.Files.LineLength

#3411808: Fix phpcs Drupal.Commenting issues

  • Drupal.Commenting.DocComment
  • Drupal.Commenting.FunctionComment
  • Drupal.Commenting.InlineVariableComment
  • Drupal.Commenting.ClassComment
  • Drupal.Commenting.DataTypeNamespace
  • Drupal.Commenting.Deprecated
  • Drupal.Commenting.FileComment
  • Drupal.Commenting.InlineComment

Command to get phpcs report:

phpcs --standard=Drupal,DrupalPractice --extensions=php,inc,module,install,info,test,profile,theme modules/custom/pathauto/

PHPCS report:

https://www.drupal.org/files/issues/2024-01-22/report.txt

Issue fork pathauto-2833680

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

renatog created an issue. See original summary.

renatog’s picture

Assigned: renatog » Unassigned
Status: Active » Needs review
FileSize
66.14 KB

Patch submitted with the fixes.

Thanks.

Regards.

cebasqueira’s picture

renatog’s picture

Thank you very much @cebasqueira.

Fixed variable unused.

Regards.

cebasqueira’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @renatog, works fine... RTBC

Berdir’s picture

Status: Reviewed & tested by the community » Needs work

Thanks, but this adds a lot of strange comments just to technically comply to the standards, can't accept that, see below.

  1. +++ b/pathauto.js
    @@ -1,3 +1,8 @@
    +/**
    + * @file
    + * Name: pathauto.js.
    + */
    +
    

    this isn't very useful, an actual description would be nice.

  2. +++ b/pathauto.module
    @@ -12,7 +13,9 @@
     /**
      * @file
    - * Main file for the Pathauto module, which automatically generates aliases for content.
    + * Main file for the Pathauto module.
    + *
    + * Which automatically generates aliases for content.
    

    that isn't really proper english anymore, we oculd leave out automatically instead, as generating kind of implies automatically.

  3. +++ b/src/Form/PatternEditForm.php
    @@ -16,11 +16,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
     
       /**
    +   * Manager.
    +   *
        * @var \Drupal\pathauto\AliasTypeManager
        */
       protected $manager;
     
       /**
    +   * Entity.
    +   *
        * @var \Drupal\pathauto\PathautoPatternInterface
        */
    

    those descriptions are pretty bogus, if we do write something, we need to have an actual description that makes sense.

  4. +++ b/src/Form/PatternEditForm.php
    @@ -70,7 +82,9 @@ class PatternEditForm extends EntityForm {
       /**
    -   * {@inheritDoc}
    +   * Build Form.
    +   *
    +   * {@inheritDoc}.
        */
       public function buildForm(array $form, FormStateInterface $form_state) {
    

    this is not valid.

  5. +++ b/src/Form/PatternEditForm.php
    @@ -198,7 +212,9 @@ class PatternEditForm extends EntityForm {
     
       /**
    -   * {@inheritDoc}
    +   * Build Entity.
    +   *
    +   * {@inheritDoc}.
        */
       public function buildEntity(array $form, FormStateInterface $form_state) {
    

    this neither.

  6. +++ b/src/Form/PatternEditForm.php
    @@ -255,7 +273,9 @@ class PatternEditForm extends EntityForm {
    -   * {@inheritDoc}
    +   * Function to save.
    +   *
    +   * {@inheritDoc}.
        */
    

    same.

  7. +++ b/src/PathautoGeneratorInterface.php
    @@ -77,8 +79,8 @@ interface PathautoGeneratorInterface {
    -   *   - force: will force updating the path
    -   *   - language: the language for which to create the alias
    +   *   - Force: will force updating the path
    +   *   - language: the language for which to create the alias.
        *
    

    this change is also not correct, force is a lower-case key.

  8. +++ b/src/PathautoPatternInterface.php
    @@ -41,6 +48,7 @@ interface PathautoPatternInterface extends ConfigEntityInterface {
        *
        * @return int
    +   *   Return weight.
    
    @@ -58,6 +66,7 @@ interface PathautoPatternInterface extends ConfigEntityInterface {
        *
        * @return \Drupal\Core\Plugin\Context\ContextInterface[]
    +   *   Return contexts.
    

    same for those things, it only makes sense to have a description if it's at least valid english

  9. +++ b/src/PathautoPatternInterface.php
    @@ -171,10 +182,11 @@ interface PathautoPatternInterface extends ConfigEntityInterface {
        *
        * @return bool
    +   *   Return flag with type boolean.
        */
    

    this doesn't make sesne.

  10. +++ b/src/PathautoWidget.php
    @@ -24,18 +24,19 @@ class PathautoWidget extends PathWidget {
         // @todo Impossible to do this in widget, use another solution
         /*
         $form['path'] += array(
    -      '#type' => 'fieldset',
    -      '#title' => $this->t('URL path settings'),
    -      '#collapsible' => TRUE,
    -      '#collapsed' => empty($form['path']['alias']),
    -      '#group' => 'additional_settings',
    -      '#attributes' => array(
    -        'class' => array('path-form'),
    -      ),
    -      '#access' => \Drupal::currentUser()->hasPermission('create url aliases') || \Drupal::currentUser()->hasPermission('administer url aliases'),
    -      '#weight' => 30,
    -      '#tree' => TRUE,
    -      '#element_validate' => array('path_form_element_validate'),
    +    '#type' => 'fieldset',
    +    '#title' => $this->t('URL path settings'),
    +    '#collapsible' => TRUE,
    +    '#collapsed' => empty($form['path']['alias']),
    +    '#group' => 'additional_settings',
    +    '#attributes' => array(
    +    'class' => array('path-form'),
    

    this change doesn't make sense, this is commented out code.

  11. +++ b/src/Tests/PathautoBulkUpdateTest.php
    @@ -54,7 +56,10 @@ class PathautoBulkUpdateTest extends WebTestBase {
     
    -  function testBulkUpdate() {
    +  /**
    +   * Function testBulkUpdate().
    +   */
    +  public function testBulkUpdate() {
    

    this and more below are also bad, if we have a docblock it needs to be an actual sentence.

hgunicamp’s picture

Continuing the work of the patch 'pathauto-codingstandards-2833680-4.patch'.

hgunicamp’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 7: coding_standards_for-2833680-7.patch, failed testing. View results

hgunicamp’s picture

Status: Needs work » Needs review
FileSize
982 bytes
157.95 KB

Sorry. A typo when saving the file.

Status: Needs review » Needs work

The last submitted patch, 10: coding_standards_for-2833680-10.patch, failed testing. View results

aldairsoares’s picture

Assigned: Unassigned » aldairsoares

I'm working on it.

aldairsoares’s picture

Assigned: aldairsoares » Unassigned
Status: Needs work » Needs review
Issue tags: -#ciandt-contrib
FileSize
85.34 KB

I worked on Coding Standards against 8.x-1.x-dev.
I ran all the tests and everything seemed to work.

Needs review :D

Status: Needs review » Needs work

The last submitted patch, 13: 2833680-13.patch, failed testing. View results

aldairsoares’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests

The error occured in the patch is from Javascript Functional test (PathautoLocaleTest::testLanguagePatterns).

The code on 8.x-1.x contained a return statement in line #161 which prevented to run the rest of the assertions. The error occurs in line #182.

I was not able to fix that therefore I am leaving this one for someone with better understanding of the module.

aldairsoares’s picture

Issue tags: -Needs tests
matheusmaciel’s picture

Status: Needs review » Needs work

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

urvashi_vora’s picture

Assigned: Unassigned » urvashi_vora

I am working on this.

urvashi_vora’s picture

Assigned: urvashi_vora » Unassigned
Status: Needs work » Needs review
vitorbs’s picture

Hi, i founded some code standards errors, i will work on that.

vitorbs’s picture

Status: Needs review » Needs work
vitorbs’s picture

phpcs fixed

vitorbs’s picture

Status: Needs work » Needs review
alexanderj’s picture

Assigned: Unassigned » alexanderj

i will review it

alexanderj’s picture

Assigned: alexanderj » Unassigned
Status: Needs review » Needs work

I did the review on the related code standards errors and they were fixed, but the 2 tests are still failing, so I believe it is still necessary to resolve them.

dmariano’s picture

Assigned: Unassigned » dmariano

I will on that!

dmariano’s picture

Merge conflicts resolved, but the test are failing.

1) Drupal\Tests\pathauto\FunctionalJavascript\PathautoLocaleTest::testLanguagePatterns
The link Add was not found on the page.
Failed asserting that an array has the key 0.

/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:119
/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:55
/var/www/html/core/tests/Drupal/Tests/UiHelperTrait.php:503
/var/www/html/modules/contrib/pathauto/tests/src/FunctionalJavascript/PathautoLocaleTest.php:176
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:703
fail: [Other] Line 0 of sites/default/files/simpletest/phpunit-10.xml:
PHPUnit Test failed to complete; Error: PHPUnit 8.5.26 �[44m#StandWith�[0m�[43mUkraine�[0m

Testing Drupal\Tests\pathauto\Kernel\PathautoEntityWithStringIdTest
dmariano’s picture

Assigned: dmariano » Unassigned
jsricardo’s picture

Assigned: Unassigned » jsricardo

I Will work on it

jsricardo’s picture

Assigned: jsricardo » Unassigned

Sorry, I couldn't identify the error.
as said in comment #28, tests keep failing

zkhan.aamir’s picture

Issue tags: +Coding standards

Nikolay Shapovalov made their first commit to this issue’s fork.

Nikolay Shapovalov’s picture

As requested by @Berdir I am going to split this MR to small one, and create separate issues.
I create child issue: #3411792: Fix phpcs Drupal.WhiteSpace, Squiz.WhiteSpace issues.

Nikolay Shapovalov’s picture

Fixed issue in the MR made during MR merge conflict fix.
And create second child issue #3411794: Fix phpcs Drupal.Arrays.Array issues

Nikolay Shapovalov’s picture

Nikolay Shapovalov changed the visibility of the branch 2833680-coding-standard-fixes to hidden.

Nikolay Shapovalov changed the visibility of the branch 2833680-coding-standards-for to hidden.

Nikolay Shapovalov’s picture

Issue summary: View changes
FileSize
32.59 KB

Add fresh phpcs report to IS.