This is a part of the attempt to fix #2572645: [Meta] Fix 'Drupal.Commenting.FunctionComment' coding standard

This issue is created to tackle the sub-sniff Drupal.Commenting.FunctionComment.ParamNameNoMatch

To review:

$ composer install
$ ./vendor/bin/phpcs --config-set installed_paths ../../drupal/coder/coder_sniffer
$ cd core
$ ../vendor/bin/phpcs -ps

Should result in no errors found.

CommentFileSizeAuthor
#36 interdiff-2722609-33-36.txt2.12 KBmfernea
#36 drupal-coding-standards-2722609-36.patch27.29 KBmfernea
#33 2722609-33.patch26.7 KBjofitz
#33 interdiff-29-33.txt1.56 KBjofitz
#29 2722609-29.patch26.65 KBjofitz
#25 drupal-coding-standards-2901663-25.patch26.84 KBmfernea
#24 drupal-coding-standards-2901663-24.patch25.76 KBmfernea
#21 drupal-coding-standards-2722609-21.patch25.83 KBmfernea
#15 drupal-coding-standards-2722609-15.patch37.54 KBdruprad
#13 diff-2722609-10-13.txt265 bytesanoopjohn
#13 drupal-coding-standards-function-comment-ParamNameNoMatch-ParamCommentNotCapital-2722609-13.patch34.81 KBanoopjohn
#10 interdiff-2722609-8-10.txt1.88 KBanoopjohn
#10 drupal-coding-standards-function-comment-ParamNameNoMatch-ParamCommentNotCapital-2722609-10.patch34.83 KBanoopjohn
#8 interdiff-2722609-2-8.txt3.07 KBanoopjohn
#8 drupal-coding-standards-function-comment-ParamNameNoMatch-ParamCommentNotCapital-2722609-8.patch34.81 KBanoopjohn
#6 drupal-coding-standards-2722609-6.patch35.47 KBchishah92
#2 drupal-coding-standards-function-comment-ParamNameNoMatch-ParamCommentNotCapital-2722609-2.patch38.84 KBanoopjohn
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

anoopjohn created an issue. See original summary.

anoopjohn’s picture

Please find attached a patch that fixes the reported issue.

Do note that although this is a function comment fix patch, there are a couple of code changes in core/lib/Drupal/Component/Assertion/Inspector.php where the comment was correct but the code needed fixing.

anoopjohn’s picture

Status: Active » Needs review
Mile23’s picture

Issue summary: View changes
Status: Needs review » Needs work

Updated issue summary with review instructions.

No phpcs errors other than unrelated Drupal.Commenting.FunctionComment.ThrowsComment.

Manual review says this...

  1. +++ b/core/lib/Drupal/Component/Assertion/Inspector.php
    @@ -205,7 +205,7 @@ public static function assertAllStrictArrays($traversable) {
        */
    -  public static function assertAllHaveKey() {
    +  public static function assertAllHaveKey($traversable) {
         $args = func_get_args();
         $traversable = array_shift($args);
    
    @@ -396,7 +396,7 @@ public static function assertAllRegularExpressionMatch($pattern, $traversable) {
    -  public static function assertAllObjects() {
    +  public static function assertAllObjects($traversable) {
         $args = func_get_args();
         $traversable = array_shift($args);
    

    Pretty sure these are set up that way for a reason. Don't change the method signature.

  2. +++ b/core/lib/Drupal/Core/Utility/Token.php
    @@ -155,7 +155,7 @@ public function __construct(ModuleHandlerInterface $module_handler, CacheBackend
    -   * @param \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata|null
    +   * @param \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata
        *   (optional) An object to which static::generate() and the hooks and
        *   functions that it invokes will add their required bubbleable metadata.
    
    +++ b/core/modules/editor/editor.api.php
    @@ -51,7 +51,7 @@ function hook_editor_js_settings_alter(array &$settings) {
    - * @param \Drupal\filter\FilterFormatInterface $original_format|null
    + * @param \Drupal\filter\FilterFormatInterface $original_format
      *   (optional) The original text format configuration entity (when switching
    
    +++ b/core/modules/editor/editor.module
    @@ -261,7 +261,7 @@ function editor_load($format_id) {
    - * @param \Drupal\filter\FilterFormatInterface $original_format|null
    + * @param \Drupal\filter\FilterFormatInterface $original_format
      *   (optional) The original text format (i.e. when switching text formats,
    

    Put the |null after the type.

chishah92’s picture

Assigned: Unassigned » chishah92
chishah92’s picture

Status: Needs work » Needs review
FileSize
35.47 KB

I have reverted the changes as suggested with a new patch

Thanks!
Chirag

Status: Needs review » Needs work

The last submitted patch, 6: drupal-coding-standards-2722609-6.patch, failed testing.

anoopjohn’s picture

Thanks for the review Mile23. The last patch failed to apply. Rerolled for latest 8.2.x head and added interdiff against #2 as that was what was reviewed against.

Mile23’s picture

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

Needs reroll since core/phpcs.xml.dist changed.

  1. +++ b/core/includes/form.inc
    @@ -782,8 +782,8 @@ function batch_set($batch_definition) {
    + *   (optional) URL of the batch processing page.
    + *   Should only be used for separate scripts like update.php.
    

    All lines like this should extend out to an 80 character wrap.

  2. +++ b/core/modules/views/src/Views.php
    @@ -283,7 +283,7 @@ public static function getDisabledViews() {
        * @param mixed $exclude_view
    -   *   view or current display to exclude
    +   *   View or current display to exclude
        *   either a
        *   - views object (containing $exclude_view->storage->name and $exclude_view->current_display)
        *   - views name as string:  e.g. my_view
    

    Should be...

    View or current display to exclude. Either a:

    All on one line.

anoopjohn’s picture

Thanks again for the review Mile23. I have rerolled the patch and have made the suggested changes.

anoopjohn’s picture

Status: Needs work » Needs review
Mile23’s picture

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

Needs a reroll for changed phpcs.xml.dist.

The rest looks pretty reasonable.

anoopjohn’s picture

Rerolled patch. BTW I was able to apply the patch with git apply --3way patchname. interdiff was not giving any output so did a diff.

Mile23’s picture

Status: Needs review » Needs work

These must have been introduced since that patch:

FILE: ...ojects/drupal8/core/lib/Drupal/Component/Assertion/Inspector.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 200 | ERROR | Doc comment for parameter $traversable does not match
     |       | actual variable name <undefined>
     |       | (Drupal.Commenting.FunctionComment.ParamNameNoMatch)
 390 | ERROR | Doc comment for parameter $traversable does not match
     |       | actual variable name <undefined>
     |       | (Drupal.Commenting.FunctionComment.ParamNameNoMatch)
----------------------------------------------------------------------


FILE: ...lmitchum/projects/drupal8/core/lib/Drupal/Core/Utility/Token.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 158 | ERROR | Doc comment for parameter $bubbleable_metadata|null does
     |       | not match actual variable name $bubbleable_metadata
     |       | (Drupal.Commenting.FunctionComment.ParamNameNoMatch)
----------------------------------------------------------------------


FILE: .../paulmitchum/projects/drupal8/core/modules/editor/editor.api.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 54 | ERROR | Doc comment for parameter $original_format|null does not
    |       | match actual variable name $original_format
    |       | (Drupal.Commenting.FunctionComment.ParamNameNoMatch)
----------------------------------------------------------------------


FILE: ...s/paulmitchum/projects/drupal8/core/modules/editor/editor.module
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 264 | ERROR | Doc comment for parameter $original_format|null does not
     |       | match actual variable name $original_format
     |       | (Drupal.Commenting.FunctionComment.ParamNameNoMatch)
----------------------------------------------------------------------

Time: 5 mins, 59.47 secs; Memory: 126.5Mb

There were some other errors in the log, but I deleted them and they're being handled here: #2747073: Fix Drupal CS regressions for Coder 8.2.8

druprad’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
37.54 KB

Rerolled patch along with resolved issue as par comment #14

Mile23’s picture

Status: Needs review » Needs work
--- a/core/lib/Drupal/Component/Assertion/Inspector.php
+++ b/core/lib/Drupal/Component/Assertion/Inspector.php

@@ -197,11 +197,6 @@ public static function assertAllStrictArrays($traversable) {
    * to the object that uses them, or are collected into one assertion set for
    * the package.
    *
-   * @param mixed $traversable
-   *   Variable to be examined.
-   * @param string ...
-   *   Keys to be searched for.
-   *
    * @return bool
    *   TRUE if $traversable can be traversed and all members have all keys.
    */
@@ -387,11 +382,6 @@ public static function assertAllRegularExpressionMatch($pattern, $traversable) {

@@ -387,11 +382,6 @@ public static function assertAllRegularExpressionMatch($pattern, $traversable) {
    *     $collection', \'\\Foo\', \'\\Bar\\None\'');
    * @endcode
    *
-   * @param mixed $traversable
-   *   Variable to be examined.
-   * @param string ...
-   *   Classes and interfaces to test objects against.
-   *

These docblocks need to stay because the functions use parameters.

It looks like we don't have a standard for this: https://www.drupal.org/coding-standards/docs#param

Plus coder can't adapt to just @param with a type and no variable name.

So we could wait on the whole thing until we have a standard for this, or we could re-scope this issue a little bit and only handle Drupal.Commenting.FunctionComment.ParamCommentNotCapital.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mfernea’s picture

Title: Fix Drupal.Commenting.FunctionComment.ParamNameNoMatch and Drupal.Commenting.FunctionComment.ParamCommentNotCapital » Fix Drupal.Commenting.FunctionComment.ParamNameNoMatch
Component: base system » other
Issue summary: View changes

Since the patch is more than 1 year old and Drupal.Commenting.FunctionComment.ParamCommentNotCapital is fixed in #2902726: Fix 'Drupal.Commenting.FunctionComment.ParamCommentNotCapital' coding standard I guess it's best to focus only on Drupal.Commenting.FunctionComment.ParamNameNoMatch in this issue.
I also updated the review instructions.

mfernea’s picture

Status: Needs work » Needs review
FileSize
25.83 KB

Here is the patch.

martin107’s picture

Issue tags: +Needs reroll

patch no longer applies.
and testbot is reporting a coding standard error to resolve.

I will lurk on this issue, with a hope of moving it to RTBC as soon as possible.

It is tricky every patch of this type causes others patches to need to reroll... I guess the only way to minimise reroll hell is to get each one committed before proceeding to the next.

martin107’s picture

Status: Needs review » Needs work
mfernea’s picture

Status: Needs work » Needs review
FileSize
25.76 KB

Re-roll.

mfernea’s picture

Two more fixes required.

martin107’s picture

Status: Needs review » Reviewed & tested by the community

I have had a careful comb through of all the changes... in each case the appropriate changes has been made.

Wow we had a lots of little screw-ups ... with a project of this age ... I guess that is to be expected.

test report no failures.

+1 from me

jofitz’s picture

Issue tags: -Needs reroll

Removed the "Needs reroll" tag.

martin107’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

We are going through a pattern of commit an issue then reroll all similar issues ... repeat

The only solution is to slow the rate of review and wait until the next active issue get committed. :(

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
26.65 KB

Simple re-rolls like that take no time at all.

martin107’s picture

Status: Needs review » Reviewed & tested by the community

Thanks ...

There is a scaling problem ... if I review 10 issues in a day .. that is potentially 9 rerolls.

Well 4 reviews in motion is doable ... but still unwelcome.

Anyway.. this looks good.

jofitz’s picture

@martin107 Maybe postpone a few?

catch’s picture

Status: Reviewed & tested by the community » Needs work

The conflicts are all due to the phpcs.yml.dist changes - if we moved those to one patch on one issue, the code style fixes could go in separately without conflicts.

Noticed a couple of things with the patch:

  1. +++ b/core/lib/Drupal/Component/Assertion/Inspector.php
    @@ -205,9 +205,9 @@ public static function assertAllStrictArrays($traversable) {
    +  public static function assertAllHaveKey($traversable) {
         $args = func_get_args();
    -    $traversable = array_shift($args);
    +    unset($args[0]);
    

    $args is no longer used, so we could skip both lines?

  2. +++ b/core/lib/Drupal/Component/Assertion/Inspector.php
    @@ -396,9 +396,9 @@ public static function assertAllRegularExpressionMatch($pattern, $traversable) {
    -  public static function assertAllObjects() {
    +  public static function assertAllObjects($traversable) {
         $args = func_get_args();
    -    $traversable = array_shift($args);
    +    unset($args[0]);
     
    

    Same here.

  3. +++ b/core/lib/Drupal/Core/Config/StorageComparer.php
    @@ -423,9 +423,9 @@ protected function getAndSortConfigData($collection) {
        *
    -   * @param string $old_name
    +   * @param string $name1
        *   The old configuration object name.
    -   * @param string $new_name
    +   * @param string $name2
        *   The new configuration object name.
    

    $old_name and $new_name are more descriptive, why not change the argument variables instead of the docs

  4. +++ b/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php
    @@ -60,7 +60,7 @@ public function getConfig() {
        *
    -   * @param string $name
    +   * @param string $key
        *   The name of the configuration option to set.
        * @param mixed $value
    

    The description should match the param but now doesn't.

jofitz’s picture

Status: Needs work » Needs review
FileSize
1.56 KB
26.7 KB
  1. $args is used later in the function and is expected to contain more than one element.
  2. ditto
  3. Changed the variable names.
  4. Changed the description.

I noticed a number of other documentation errors in Drupal\Core\Executable\ExecutablePluginBase, but did not consider them relevant to this issue so have opened a follow-up: #2904711: Missing and incorrect parameter, return, and thrown exception data types in Drupal\Core\Executable\ExecutablePluginBase.

Status: Needs review » Needs work

The last submitted patch, 33: 2722609-33.patch, failed testing. View results

mfernea’s picture

Status: Needs work » Reviewed & tested by the community

I rerun the tests and everything seems to be fine now. The error was not related to the code in this patch.
Modifications look fine. I agree with Jo's notes for 1. and 2..

mfernea’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
27.29 KB
2.12 KB

I took another look at the params' comments that we've modified in this issue and I think 3 more modifications are needed.

martin107’s picture

Status: Needs review » Reviewed & tested by the community

Regarding the changes $args issue ... yep the patch is correct.

From 31,

Maybe postpone a few?

I don't to stop other eyes passing over the issues completely .. it is a tricky balance.

My plan is to try and work down the list from top to bottom ....and stick on one 'til done.

I am happy with all the recent changes.... they improve things and I don't want to get hung up on what is out of scope and what is not.

catch’s picture

Version: 8.5.x-dev » 8.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!

  • catch committed cb9b6d4 on 8.5.x
    Issue #2722609 by anoopjohn, mfernea, Jo Fitzgerald, chishah92, druprad...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.