FILE: ...arn/modules/git/entity_usage/src/Annotation/EntityUsageTrack.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 46 | ERROR | Class property $field_types should use lowerCamel
    |       | naming without underscores
----------------------------------------------------------------------


FILE: ...ar/www/html/tolearn/modules/git/entity_usage/src/EntityUsage.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 317 | ERROR | [x] There must be exactly one blank line before the
     |       |     tags in a doc comment
 320 | ERROR | [ ] Parameter tags must be defined first in a doc
     |       |     comment
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: .../modules/git/entity_usage/src/Controller/ListUsageController.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 12 | WARNING | [x] Unused use statement
----------------------------------------------------------------------

FILE: ...ty_usage/src/Plugin/EntityUsage/Track/DynamicEntityReference.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 24 | ERROR | Inline doc block comments are not allowed; use "/*
    |       | Comment */" or "// Comment" instead
----------------------------------------------------------------------

Comments

deepanker_bhalla created an issue. See original summary.

deepanker_bhalla’s picture

Status: Needs work » Needs review
StatusFileSize
new6.51 KB

Fixed the coding standard issues.

deepanker_bhalla’s picture

StatusFileSize
new7.03 KB

I have found some more issues while checking it with latest version. Thus updating the patch with all the issues resolved.

msankhala’s picture

Status: Needs review » Needs work
  1. +++ b/src/Annotation/EntityUsageTrack.php
    @@ -43,6 +43,6 @@ class EntityUsageTrack extends Plugin {
    -  public $field_types = [];
    +  public $fieldtypes = [];
    

    This change may break the functionality as you are renaming the property. You should change the name of property at all places wherever it is being accessed. Also the correct name should be $fieldTypes.

  2. +++ b/tests/modules/entity_usage_test/entity_usage_test.info.yml
    @@ -3,7 +3,7 @@ type: module
    +version: ¶
    

    Remove trailing whitespace.

  3. +++ b/tests/src/Kernel/EntityUsageLegacyEntityReferenceKernelTest.php
    @@ -191,11 +190,10 @@ class EntityUsageLegacyEntityReferenceKernelTest extends EntityKernelTestBase {
    -//    $source_entity->{$field_name}->entity = $this->testEntities[1];
    -//    $source_entity->save();
    -//    $usage = $entity_usage->listSources($this->referencedEntity);
    -//    $this->assertSame([], $usage, 'Non-referenced usage is correctly empty.');
    -
    +    // $source_entity->{$field_name}->entity = $this->testEntities[1];
    +    // $source_entity->save();
    +    // $usage = $entity_usage->listSources($this->referencedEntity);
    +    // $this->assertSame([], $usage,'Non-referenced usage is correctly empty.');
    
    @@ -215,29 +213,27 @@ class EntityUsageLegacyEntityReferenceKernelTest extends EntityKernelTestBase {
    -//    $source_entity->delete();
    -//    $usage = $entity_usage->listSources($this->referencedEntity);
    -//    $this->assertSame([], $usage, 'Non-referenced usage is correctly empty.');
    -
    +    // $source_entity->delete();
    +    // $usage = $entity_usage->listSources($this->referencedEntity);
    +    // $this->assertSame([], $usage,'Non-referenced usage is correctly empty.');
         // Create a reference again, check the value is back to 1.
    -//    $source_entity = $this->testEntities[1];
    -//    $source_entity->{$field_name}->entity = $this->referencedEntity;
    -//    $source_entity->save();
    -//    $usage = $entity_usage->listSources($this->referencedEntity);
    -//    $this->assertEquals([
    -//      $source_entity->getEntityTypeId() => [
    -//        $source_entity->id() => [
    -//          0 => [
    -//            'source_langcode' => $source_entity->language()->getId(),
    -//            'source_vid' => $source_entity->getRevisionId() ?: 0,
    -//            'method' => 'entity_reference',
    -//            'field_name' => $field_name,
    -//            'count' => 1,
    -//          ],
    -//        ],
    -//      ],
    -//    ], $usage, 'The usage count is correct.');
    -
    +    // $source_entity = $this->testEntities[1];
    +    // $source_entity->{$field_name}->entity = $this->referencedEntity;
    +    // $source_entity->save();
    +    // $usage = $entity_usage->listSources($this->referencedEntity);
    +    // $this->assertEquals([
    +    // $source_entity->getEntityTypeId() => [
    +    // $source_entity->id() => [
    +    // 0 => [
    +    // 'source_langcode' => $source_entity->language()->getId(),
    +    // 'source_vid' => $source_entity->getRevisionId() ?: 0,
    +    // 'method' => 'entity_reference',
    +    // 'field_name' => $field_name,
    +    // 'count' => 1,
    +    // ],
    +    // ],
    +    // ],
    +    // ], $usage, 'The usage count is correct.');
    

    Commented code should be removed all together.

dhirendra.mishra’s picture

Assigned: Unassigned » dhirendra.mishra

Working on it.

dhirendra.mishra’s picture

Assigned: dhirendra.mishra » Unassigned
Status: Needs work » Needs review
StatusFileSize
new9.05 KB
new12.91 KB

Uploading fixes for #5.Hope it helps.

Status: Needs review » Needs work

The last submitted patch, 6: 3001167-coding-standard-6.patch, failed testing. View results

msankhala’s picture

+++ b/src/EntityUsageTrackBase.php
@@ -217,13 +217,13 @@ abstract class EntityUsageTrackBase extends PluginBase implements EntityUsageTra
-  public function getReferencingFields(EntityInterface $source_entity, array $field_types) {
+  public function getReferencingFields(EntityInterface $source_entity, array $fieldTypes) {

You do not need to change method parameter here because this is creating inconsistency. You can keep it $field_types.

Also, you will need to fix property name in test cases as well because the tests are still expecting field_types property in the class.

I wonder if this change may break the upgrade path of this module if there is any.

dhirendra.mishra’s picture

Assigned: Unassigned » dhirendra.mishra
dhirendra.mishra’s picture

Status: Needs work » Needs review
StatusFileSize
new7.44 KB
new11.3 KB

Thanks Mahesh for reviewing. As i checked there isn't any hardcoded property name used under the test cases. Also find below patch which is correction from #8. Thanks.

dhirendra.mishra’s picture

Assigned: dhirendra.mishra » Unassigned

Status: Needs review » Needs work

The last submitted patch, 10: 3001167-coding-standard-10.patch, failed testing. View results

deepanker_bhalla’s picture

Status: Needs work » Needs review
StatusFileSize
new11.3 KB

Please check the rerolled patch with the new changes.

msankhala’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/EntityUsage/Track/DynamicEntityReference.php
@@ -21,7 +21,7 @@ class DynamicEntityReference extends EntityUsageTrackBase {
-    /** @var \Drupal\dynamic_entity_reference\Plugin\Field\FieldType\DynamicEntityReferenceItem$item */
+    /* @var \Drupal\dynamic_entity_reference\Plugin\Field\FieldType\DynamicEntityReferenceItem$item */

This should has /** in starting and */ in end. There should be single space between the variable type and the variable $item. Something like:
/** @var \Drupal\dynamic_entity_reference\Plugin\Field\FieldType\DynamicEntityReferenceItem $item */

See #2305593: [policy] Set a standard for @var inline variable type declarations

Rest looks good.

dhirendra.mishra’s picture

Assigned: Unassigned » dhirendra.mishra

working on it.

dhirendra.mishra’s picture

Assigned: dhirendra.mishra » Unassigned
Status: Needs work » Needs review
StatusFileSize
new11.3 KB

Here is the update patch. This solves from #15

msankhala’s picture

Status: Needs review » Needs work

@dhirendra.mishra Please provide the interdiff as well whenever you are providing a patch which modifies something from the previous patch. This will help the reviewer to spend less time reviewing.

+++ b/src/Plugin/EntityUsage/Track/DynamicEntityReference.php
@@ -21,7 +21,7 @@ class DynamicEntityReference extends EntityUsageTrackBase {
-    /** @var \Drupal\dynamic_entity_reference\Plugin\Field\FieldType\DynamicEntityReferenceItem$item */
+    /* @var \Drupal\dynamic_entity_reference\Plugin\Field\FieldType\DynamicEntityReferenceItem $item */

I can see you have added a space between variable type and variable name $item. As per the standard inline @var comment should start with double asterisk /** not with single asterisk /*.

dhirendra.mishra’s picture

Status: Needs work » Needs review
StatusFileSize
new11.3 KB

Please find below updated patch.

msankhala’s picture

Status: Needs review » Reviewed & tested by the community

LGTM. @deepanker_bhalla good work. Moving this to RTBC.

marcoscano’s picture

Status: Reviewed & tested by the community » Fixed

This has apparently been fixed elsewhere. Thanks in any case for the help!

Status: Fixed » Closed (fixed)

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