Problem/Motivation

Part of the work to enable the rule, 'Drupal.Commenting.VariableComment'.

This is to enable 'Drupal.Commenting.VariableComment.MissingVar'.

Steps to reproduce

Proposed resolution

Fix remaining violations and enable the sniff.

Remaining tasks

Enable the sniff and fix any remaining problems

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-2909372

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

mfernea created an issue. See original summary.

shkiper’s picture

Assigned: Unassigned » shkiper
Issue tags: +lutsk2017
shkiper’s picture

Status: Active » Needs review
StatusFileSize
new72.23 KB
andriyun’s picture

Status: Needs review » Needs work

Good patch
I don't see phpcs fails related to issue sniff after patch applying

But patch doesn't have changes for phpcs.xml.dist file
We have to enable fixed sniff for further checks. See step 1 from instruction.
Please add proper sniffs to this.

To avoid fails related to other subsniffs from Drupal.Commenting.VariableComment
you will need to exclude them.
Finally you will get smth like this:

+  <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php">
+    <!-- Sniff for: DuplicateVar -->
+    <exclude name="Drupal.Commenting.VariableComment.InlineVariableName"/>
+    <exclude name="Drupal.Commenting.VariableComment.EmptyVar"/>
+    <exclude name="Drupal.Commenting.VariableComment.IncorrectVarType"/>
+    <exclude name="Drupal.Commenting.VariableComment.MissingVar"/>
+    <exclude name="Drupal.Commenting.VariableComment.VarOrder"/>
+    <exclude name="Drupal.Commenting.VariableComment.WrongStyle"/>
+  </rule>
zaporylie’s picture

Status: Needs work » Needs review
StatusFileSize
new72.62 KB
new6.4 KB

I reviewed the patch, added sniff section to phpcs.xml.dist as mentioned in #4 and fixed some minor issues I have found on the way.

zaporylie’s picture

Assigned: shkiper » Unassigned
zaporylie’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
zaporylie’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new73.66 KB
new1.56 KB

Reroll + additions added since 9 October 2017 at 00:56

zaporylie’s picture

StatusFileSize
new16.17 KB
new73.92 KB

I went once again thoroughly through all changes introduced by last patch, and fixed places, I believe, were wrong (wrong order, incorrect data type, etc). Hope someone can find the time to make a final review.

martin107’s picture

Status: Needs review » Reviewed & tested by the community

1) I have justified all the changes to myself during a visual inspection of the patch

.. all looks good.

2) The phpcs.xml.dist was modified correctly

3) There are no remaining coding standard error in test runs output

I think this issue is ready.... everybodyWhoWorkedOnThis++

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 9: fix-2909372-9.patch, failed testing. View results

mfernea’s picture

Status: Needs work » Needs review
StatusFileSize
new74.59 KB

Quick re-roll due to phpcs.xml.dist conflicts.

martin107’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the quick reroll.

I have rechecked ... everything I said in #10 is valid about this new patch.

I missed the "does the patch still apply" off my checklist

martin107--

xjm’s picture

Status: Reviewed & tested by the community » Needs work

I love it when our coding standards cleanups also make our code more usable. :)

This issue is a bit tricker to review than other coding standards patches since one has to look up the data types for things that don't provide defaults. The following is a mix of actual review points and notes to myself...

  1. +++ b/core/lib/Drupal/Component/Datetime/DateTimePlus.php
    @@ -54,6 +54,8 @@ class DateTimePlus {
       /**
        * An array of possible date parts.
    +   *
    +   * @var array
        */
       protected static $dateParts = [
         'year',
    

    Is this a string[]?

  2. +++ b/core/lib/Drupal/Component/Datetime/DateTimePlus.php
    @@ -66,41 +68,57 @@ class DateTimePlus {
       /**
        * The value of the language code passed to the constructor.
    +   *
    +   * @var string|null
        */
       protected $langcode = NULL;
    
    +++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
    @@ -24,6 +24,8 @@ class DrupalDateTime extends DateTimePlus {
       /**
    

    It's clear it can be NULL because there's a null there, and a machine name is obviously a string. So this is OK.

  3. +++ b/core/lib/Drupal/Component/Datetime/DateTimePlus.php
    @@ -66,41 +68,57 @@ class DateTimePlus {
       /**
        * An array of errors encountered when creating this date.
    +   *
    +   * @var array
        */
       protected $errors = [];
    

    What kind of things are errors? Is this a render array, so array[]? Is it a list of strings, so string[]?

  4. +++ b/core/lib/Drupal/Component/Gettext/PoItem.php
    @@ -13,7 +13,7 @@ class PoItem {
    -   * @car string
    +   * @var string
    

    A string car doesn't sound very useful. :)

  5. +++ b/core/lib/Drupal/Component/Graph/Graph.php
    @@ -9,6 +9,8 @@ class Graph {
       /**
        * Holds the directed acyclic graph.
    +   *
    +   * @var array
        */
       protected $graph;
    
    +++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
    @@ -24,6 +24,8 @@ class DrupalDateTime extends DateTimePlus {
       /**
    

    Note to self: look these one up and confirm it's set in the constructor (i.e. never NULL). Scalar defaults for array values are often fragile, also, so we might find some followup issues for these.

  6. +++ b/core/lib/Drupal/Core/Access/CheckProvider.php
    @@ -38,6 +38,8 @@ class CheckProvider implements CheckProviderInterface, ContainerAwareInterface {
       /**
        * Array of access checks which only will be run on the incoming request.
    +   *
    +   * @var array
        */
       protected $checksNeedsRequest = [];
    

    What kinds of things are these? Sounds like maybe objects of some access check type?

  7. +++ b/core/lib/Drupal/Core/Cache/PhpBackend.php
    @@ -27,6 +27,8 @@ class PhpBackend implements CacheBackendInterface {
       /**
        * Array to store cache objects.
    +   *
    +   * @var array
        */
       protected $cache = [];
    

    Cache objects are presumably instances of some interface?

  8. +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
    @@ -14,6 +14,8 @@ class ConfigEntityType extends EntityType implements ConfigEntityTypeInterface {
       /**
        * The config prefix set in the configuration entity type annotation.
        *
    +   * @var string
    +   *
        * @see \Drupal\Core\Config\Entity\ConfigEntityTypeInterface::getConfigPrefix()
        */
       protected $config_prefix;
    
    +++ b/core/lib/Drupal/Core/Database/Transaction.php
    @@ -42,6 +42,8 @@ class Transaction {
        * This is used to label the transaction savepoint. It will be overridden to
        * 'drupal_transaction' if there is no transaction depth.
    +   *
    +   * @var string
        */
       protected $name;
    

    Note to self: Sounds stringy but check, and check for NULL.

  9. +++ b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php
    @@ -11,6 +11,8 @@
       /**
        * Parsed elements.
    +   *
    +   * @var array
        */
       protected $elements;
    

    It's called ArrayElement but check, and check NULL. What is it an array of?

  10. +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
    @@ -40,6 +40,8 @@ class Connection extends DatabaseConnection {
        * In PostgreSQL, 'LIKE' is case-sensitive. ILKE should be used for
        * case-insensitive statements.
    +   *
    +   * @var array
        */
       protected static $postgresqlConditionOperatorMap = [
         'LIKE' => ['operator' => 'ILIKE'],
    

    Looks like it's a string[][]?

  11. +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
    @@ -52,6 +54,8 @@ class Connection extends DatabaseConnection {
    +   *
    +   * @var array
    

    string[]?

  12. +++ b/core/lib/Drupal/Core/Database/Query/Condition.php
    @@ -61,6 +63,8 @@ class Condition implements ConditionInterface, \Countable {
    +   * @var string
    
    +++ b/core/lib/Drupal/Core/Database/Query/Merge.php
    @@ -66,6 +66,8 @@ class Merge extends Query implements ConditionInterface {
       /**
        * The table or subquery to be used for the condition.
    +   *
    +   * @var string
        */
       protected $conditionTable;
    

    Note to self: Sounds like a string and having no table (NULL) for the condition sounds like invalid SQL, but double-check.

  13. +++ b/core/lib/Drupal/Core/Database/Query/SelectExtender.php
    @@ -25,11 +25,15 @@ class SelectExtender implements SelectInterface {
       /**
        * A unique identifier for this query object.
    +   *
    +   * @var string
        */
       protected $uniqueIdentifier;
    
    +++ b/core/lib/Drupal/Core/Database/Schema.php
    @@ -30,11 +32,15 @@
        * A unique identifier for this query object.
    +   *
    +   * @var string
        */
       protected $uniqueIdentifier;
    

    Note to self: Sounds like a string but double-check that it's never NULL.

  14. +++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
    @@ -24,6 +24,8 @@ class DrupalDateTime extends DateTimePlus {
       /**
        * Format string translation cache.
    +   *
    +   * @var array
        */
       protected $formatTranslationCache;
    

    The docs say string but the type says array. One of these is wrong.

    ...Or, wait. Is it the "Translation cache of format strings"?

  15. +++ b/core/lib/Drupal/Core/Entity/EntityType.php
    @@ -224,11 +224,15 @@ class EntityType extends PluginDefinition implements EntityTypeInterface {
       /**
        * The machine name of the entity type group.
    +   *
    +   * @var string
        */
       protected $group;
     
       /**
        * The human-readable name of the entity type group.
    +   *
    +   * @var string
        */
       protected $group_label;
    
    +++ b/core/lib/Drupal/Core/Entity/EntityType.php
    @@ -224,11 +224,15 @@ class EntityType extends PluginDefinition implements EntityTypeInterface {
       /**
        * The machine name of the entity type group.
    +   *
    +   * @var string
        */
       protected $group;
     
       /**
        * The human-readable name of the entity type group.
    +   *
    +   * @var string
        */
       protected $group_label;
    

    Note to self: Obviously strings but check for null values.

  16. +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
    @@ -66,9 +66,9 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
        * The EntityViewDisplay objects created for individual field rendering.
        *
    -   * @see \Drupal\Core\Entity\EntityViewBuilder::getSingleFieldDisplay()
    +   * @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface[]
        *
    -   * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface[]
    +   * @see \Drupal\Core\Entity\EntityViewBuilder::getSingleFieldDisplay()
        */
       protected $singleFieldDisplays;
    

    Note to self: I probably need to look these up.

...That's as far as I got before got some reviewer fatigue. This is one of the coding standards issues I'd suggest splitting up. My suggestion:

  1. One patch of things that already are documented but have a typo or whatever, like @car and @param.
  2. One patch of scalars that provide default values.
  3. A followup patch of scalars that don't provide default values.
  4. One patch of arrays that provide default values, correctly typed to what the array is. Usually we can be more specific than plain-old array
  5. Whatever's left, and enable the rule.

Thanks!

zaporylie’s picture

So what do you prefer - one issue per item from list in #14 or split patch in #12 into several patch files and upload them all here?

zaporylie’s picture

Title: Fix 'Drupal.Commenting.VariableComment.MissingVar' coding standard » [PP-4] Fix 'Drupal.Commenting.VariableComment.MissingVar' coding standard
Issue summary: View changes
Status: Needs work » Postponed
zaporylie’s picture

Title: [PP-4] Fix 'Drupal.Commenting.VariableComment.MissingVar' coding standard » [PP-2] Fix 'Drupal.Commenting.VariableComment.MissingVar' coding standard

Two already landed, another two to go.

zaporylie’s picture

StatusFileSize
new49.32 KB

This is reroll of #12.

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

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.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.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.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.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

osman’s picture

osman’s picture

Re-rolling without <exclude name="Drupal.Commenting.VariableComment.MissingVar"/>

mfernea’s picture

Status: Needs review » Needs work

I don't think it's correct to use ...|false. We should use ...|bool.
The change in core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php should be included in #2924782.

osman’s picture

I failed to find a documentation on this actually.

In mixed types, if the bool option is only one of the values, should it be defined specifically, or simply defined as its type?

For example, if the variable can return only a string or false, should it be @var string|bool or @var string|false?

Your suggestion makes sense, as we're defining types. But I would love to read more on that if you have any resource on that.

mfernea’s picture

Actually |false is ok, as can be seen here https://www.drupal.org/node/1354.
Only the other small problem remains.

osman’s picture

Status: Needs work » Needs review

Thank you for the documentation @mfernea, really good resource!

For convenience to others: https://www.drupal.org/node/1354#types

Marking this needs review per #2924782-14: Fix 'Drupal.Commenting.VariableComment.MissingVar' outside of Plugins

zaporylie’s picture

Title: [PP-2] Fix 'Drupal.Commenting.VariableComment.MissingVar' coding standard » [PP-1] Fix 'Drupal.Commenting.VariableComment.MissingVar' coding standard

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

quietone’s picture

Status: Needs review » Postponed

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Title: [PP-1] Fix 'Drupal.Commenting.VariableComment.MissingVar' coding standard » [PP-1] Enable 'Drupal.Commenting.VariableComment.MissingVar' coding standard
Issue summary: View changes

The child issue to enable rule had too many changes. So I split that up and this will become the final one to enable the sniff and fix any stragglers when all the children are committed.

quietone’s picture

Status: Postponed » Closed (duplicate)

The child issue #2924782: Fix 'Drupal.Commenting.VariableComment.MissingVar' outside of Plugins is small enough to fix the remaining violations and enable the sniff. So, I am closing this as a duplicate of that one and moving credit.

quietone’s picture

Title: [PP-1] Enable 'Drupal.Commenting.VariableComment.MissingVar' coding standard » Enable 'Drupal.Commenting.VariableComment.MissingVar' coding standard
Status: Closed (duplicate) » Active

Due to recent commits of coding standard fixes, there are too many changes to fix and enable this sniff in #2924782: Fix 'Drupal.Commenting.VariableComment.MissingVar' outside of Plugins. So, opening this up again to do the final enable and fixes.

quietone’s picture

Issue summary: View changes
Status: Active » Postponed

Created MR with what should be the remaining fixes.

And postponing on the last child.

quietone’s picture

Issue summary: View changes
quietone’s picture

Issue summary: View changes
quietone’s picture

quietone credited alexpott.

quietone credited daffie.

quietone credited larowlan.

quietone credited longwave.

quietone credited spokje.

quietone’s picture

Closed sibling issue #2924782: Fix 'Drupal.Commenting.VariableComment.MissingVar' outside of Plugins as a duplicate and transferring credit here.

quietone’s picture

Issue summary: View changes
Status: Postponed » Needs review

The child issues have been fixed, so time to fix the stragglers and enable the sniff.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

I think this is ready, the rule is enabled and the remaining issues are fixed.

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

nod_’s picture

Status: Reviewed & tested by the community » Fixed

Committed b9f3fe7 and pushed to 11.x. Thanks!

  • nod_ committed b9f3fe73 on 11.x
    Issue #2909372 by zaporylie, quietone, osman, mfernea, shkiper,...
nod_’s picture

Status: Fixed » Closed (fixed)

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

jannakha changed the visibility of the branch 2909372-enable-drupal.commenting.variablecomment.missingvar-coding to active.

jannakha changed the visibility of the branch 2909372-enable-drupal.commenting.variablecomment.missingvar-coding to hidden.