Problem/Motivation

Drupal coding standard and Practice issues need to resolve.

FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\conflict\conflict.api.php
----------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------------------
3 | ERROR | Missing short description in doc comment
47 | ERROR | Doc comment is empty
----------------------------------------------------------------------------------

FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\conflict\conflict.module
--------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------
115 | ERROR | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
--------------------------------------------------------------------------------------------------------------------------------------------

FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\conflict\modules\conflict_paragraphs\conflict_paragraphs.module
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
3 | ERROR | Missing short description in doc comment
------------------------------------------------------------------------------------------------------------------------

FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\conflict\modules\conflict_paragraphs\src\Plugin\Conflict\FieldComparator\FieldComparatorParagraphReference.php
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
256 | WARNING | Unused variable $removed_entity_form_display.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\conflict\src\Entity\ContentEntityConflictHandler.php
--------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------
197 | ERROR | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
--------------------------------------------------------------------------------------------------------------------------------------------

Time: 893ms; Memory: 14MB

Steps to reproduce

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml conflict/

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork conflict-3293562

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:

  • 3293562-drupal-coding-standard Comparecompare
  • 1 hidden branch
  • 8.x-2.x Comparecompare

Comments

arunkumark created an issue. See original summary.

immaculatexavier’s picture

Assigned: Unassigned » immaculatexavier
immaculatexavier’s picture

Assigned: immaculatexavier » Unassigned
Status: Active » Needs review
StatusFileSize
new19.3 KB

The phpcs issues mentioned in Problem/Motivation have been resolved.

arunkumark’s picture

Status: Needs review » Needs work
StatusFileSize
new4.68 KB
new25.36 KB

@immaculatexavier

Patch #3, only resolve a few issues. Please find the complete list of Drupal coding standards and best practices for the conflict module.

indrapatil’s picture

Assigned: Unassigned » indrapatil
indrapatil’s picture

Assigned: indrapatil » Unassigned
Status: Needs work » Needs review
StatusFileSize
new31.67 KB
new24.59 KB

Hi,
Please review this patch.

lucasbaralm’s picture

Status: Needs review » Needs work
StatusFileSize
new14.25 KB

Good Morning! Thanks for the work, the patch fixes a lot of standard issues. Some standard issues still persist, in the attached file I mention them.

pflora’s picture

Assigned: Unassigned » pflora

I'll work on it.

pflora’s picture

Assigned: pflora » Unassigned
StatusFileSize
new50.98 KB

Here's the new patch with the requested changes.

pflora’s picture

Status: Needs work » Needs review
ramonvasconcelos’s picture

Assigned: Unassigned » ramonvasconcelos

I'll review it.

ramonvasconcelos’s picture

Status: Needs review » Needs work

After checking the module files again with PHPCS there are still some errors.
I'll try to fix them.

FILE: /home/ramonsv/Documents/Projects/Drupal/web/modules/contrib/conflict/conflict.module
--------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------
 115 | ERROR | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
--------------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/ramonsv/Documents/Projects/Drupal/web/modules/contrib/conflict/modules/conflict_paragraphs/src/Plugin/Conflict/FieldComparator/FieldComparatorParagraphReference.php
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 256 | WARNING | Unused variable $removed_entity_form_display.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/ramonsv/Documents/Projects/Drupal/web/modules/contrib/conflict/modules/conflict_paragraphs/conflict_paragraphs.module
---------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------
 3 | ERROR | Missing short description in doc comment
---------------------------------------------------------------------------------------------------------------------------------


FILE: /home/ramonsv/Documents/Projects/Drupal/web/modules/contrib/conflict/src/Form/ConflictResolutionDialogFormBuilder.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 11 WARNINGS AFFECTING 10 LINES
------------------------------------------------------------------------------------------------------------------------------------------
  52 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  54 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  58 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  63 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  78 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  92 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 103 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 185 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 185 | ERROR   | The array declaration extends to column 176 (the limit is 80). The array content should be split up over multiple lines
 189 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 197 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 197 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/ramonsv/Documents/Projects/Drupal/web/modules/contrib/conflict/src/Entity/ContentEntityConflictHandler.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 4 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
 197 | ERROR   | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
 212 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 225 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 295 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 296 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
----------------------------------------------------------------------------------------------------------------------------------------------

Time: 616ms; Memory: 14MB
ramonvasconcelos’s picture

StatusFileSize
new55.13 KB

Please, review it.

alexanderj’s picture

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

I will review it.

alexanderj’s picture

After reviewing the module, i found more PHPCS terrors.
I'll try to fix them.

FILE: /home/alexanderj/contrib/contrib-9/web/modules/contrib/conflict/js/conflict_resolution.js
-----------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------
 25 | ERROR | [x] Expected 1 space before "!=="; 2 found
 25 | ERROR | [x] Expected 1 space before "!=="; 2 found
-----------------------------------------------------------------------------------------------

FILE: /home/alexanderj/contrib/contrib-9/web/modules/contrib/conflict/src/Form/ConflictResolutionDialogFormBuilder.php
---------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------
 185 | ERROR | The array declaration extends to column 183 (the limit is 80). The array content should be split up over multiple lines
---------------------------------------------------------------------------------------------------------------------------------------

Please, review it.

alexanderj’s picture

Assigned: alexanderj » Unassigned
ramonvasconcelos’s picture

Assigned: Unassigned » ramonvasconcelos

I'll review it.

ramonvasconcelos’s picture

Assigned: ramonvasconcelos » Unassigned
Status: Needs review » Reviewed & tested by the community

Everything in order. There are some minor warnings in JS a file but i dont think they would improve code readability.

avpaderno’s picture

Priority: Major » Minor
Status: Reviewed & tested by the community » Needs work
+/**
+ * @file
+ */
+

The usual short description for a module is Hook implementations for the [module name] module. Using an empty comment is just a workaround.

-
-  // auto merge
+  // Auto merge

That comment is meaningless. Instead of fixing a word spelling, it would be better to remove the comment.

+/**
+ * Resolves conflicts on content entities.
+ */
 class MergeRemoteStructure extends MergeStrategyBase {
 

That short description could be correct, but it needs to be more specific, as that class does not removed every content entity conflict.

-        $local_paragraph_ids_unsorted = array_map(function ($value) {return $value['target_id'];}, $local_entity->get($property)->getValue());
-        $server_paragraph_ids_unsorted = array_map(function ($value) {return $value['target_id'];}, $remote_entity->get($property)->getValue());
-        $original_paragraph_ids_unsorted = array_map(function ($value) {return $value['target_id'];}, $original_entity->get($property)->getValue());
+        $local_paragraph_ids_unsorted = array_map(function ($value) {
+          return $value['target_id'];
+
+        }, $local_entity->get($property)->getValue());
+        $server_paragraph_ids_unsorted = array_map(function ($value) {
+          return $value['target_id'];
+
+        }, $remote_entity->get($property)->getValue());
+        $original_paragraph_ids_unsorted = array_map(function ($value) {
+          return $value['target_id'];
+
+        }, $original_entity->get($property)->getValue());

The changed code is not more readable.

-          // TODO this supports only paragraphs at first level.
+          // @todo this supports only paragraphs at first level.
           if ($form_state) {
             $this->reorderWidgetState($field_item_list, $form_state);

What follows @todo is a sentence: It starts with a capitalized word and it ends with a period.

-            // TODO not yet supported.
+            // @todo not yet supported.
             if ($form_state) {

The sentence following @todo must describe what needs to be changed. In this case, it just describes the actual code.

+/**
+ * Conflict Discovery Interface.
+ */

The short description is missing an article.
Those words are misspelled, since in English words are spelled capitalized basing on specific rules.

+/**
+ * Discover conflicts on content entities.
+ */
 class DefaultConflictDiscovery extends ConflictDiscoveryBase {

If the first word in a short description is a verb, it must use the third-person singular (eats, drinks, tastes.)

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

bindu r made their first commit to this issue’s fork.

avpaderno’s picture

Also, why only a ruleset is used instead of the two existing rulesets PHP_CodeSniffer has for Drupal?

zkhan.aamir’s picture

Issue summary: View changes

Updated issue summary.

silvi.addweb’s picture

StatusFileSize
new51.89 KB

I've applied all patches but found some phpcs issues so I created with all fixes. Please review it.

apaderno changed the visibility of the branch 8.x-2.x to hidden.

avpaderno’s picture

Title: Drupal Coding standard issue » Fix the errors/warnings reported by PHP_CodeSniffer
avpaderno’s picture

Version: 8.x-2.x-dev » 3.0.x-dev
Issue tags: +Needs reroll

The 8.x-2.x branch is not the recommended branch, which instead is the 3.0.x branch. Issues should be fixed in that branch.

avpaderno’s picture

Version: 3.0.x-dev » 8.x-2.x-dev