Fix the errors/warnings reported by PHP_CodeSniffer

Created on 30 June 2022, almost 2 years ago
Updated 31 May 2024, 2 days ago

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

๐Ÿ“Œ Task
Status

Needs work

Version

2.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia arunkumark Coimbatore

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +/**
    + * @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.)

  • First commit to issue fork.
  • bindu r โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

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

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia zkhan.aamir

    Updated issue summary.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

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

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

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

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    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.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
Production build 0.69.0 2024