Fix the issues reported by phpcs

Created on 19 October 2023, 8 months ago
Updated 6 June 2024, 20 days ago

Problem/Motivation

FILE: ...contribution/web/modules/contrib/entitytype_filter/src/Form/FilterEntityTypesForm.php
-------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 7 WARNINGS AFFECTING 11 LINES
-------------------------------------------------------------------------------------------
   7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one
     |         |     is Drupal\Core\Entity\EntityTypeManagerInterface.
  79 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection
     |         |     instead
 113 | WARNING | [ ] Only string literals should be passed to t() where possible
 119 | WARNING | [ ] Only string literals should be passed to t() where possible
 162 | WARNING | [ ] #options values usually have to run through t() for translation
 163 | WARNING | [ ] #options values usually have to run through t() for translation
 164 | WARNING | [ ] #options values usually have to run through t() for translation
 196 | WARNING | [ ] Translatable strings must not begin or end with white spaces, use
     |         |     placeholders with t() for variables
 196 | ERROR   | [ ] Concatenating translatable strings is not allowed, use placeholders
     |         |     instead and only one string literal
 268 | ERROR   | [ ] Concatenating translatable strings is not allowed, use placeholders
     |         |     instead and only one string literal
 271 | ERROR   | [ ] Concatenating translatable strings is not allowed, use placeholders
     |         |     instead and only one string literal
 274 | ERROR   | [ ] Concatenating translatable strings is not allowed, use placeholders
     |         |     instead and only one string literal
-------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------


FILE: .../contribution/web/modules/contrib/entitytype_filter/src/Form/FilterFieldTypesForm.php
-------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
-------------------------------------------------------------------------------------------
   7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one
     |         |     is Drupal\Core\Entity\EntityTypeManagerInterface.
 130 | WARNING | [ ] Unused variable $key.
 195 | WARNING | [ ] Unused variable $category.
-------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------


FILE: ...b/modules/contrib/entitytype_filter/src/Controller/EntitiesAutoCompleteController.php
-------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
   |       |     Drupal\Core\Entity\EntityTypeManagerInterface.
-------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------


FILE: .../web/modules/contrib/entitytype_filter/src/Controller/FilterEntityTypesController.php
-------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------
 21 | WARNING | \Drupal calls should be avoided in classes, use dependency injection
    |         | instead
-------------------------------------------------------------------------------------------


FILE: ...n/web/modules/contrib/entitytype_filter/src/Controller/FilterFieldTypesController.php
-------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------
 16 | WARNING | \Drupal calls should be avoided in classes, use dependency injection
    |         | instead
-------------------------------------------------------------------------------------------

Steps to reproduce

Run following command

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

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ“Œ Task
Status

RTBC

Version

2.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Harsh

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.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Harsh
  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Harsh

    I have fixed the phpcs issues.Please review the patch

  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +  /**
    +   * The form builder service.
    +   *
    +   * @var \Drupal\Core\Form\FormBuilderInterface

    The form builder. is sufficient.

    +  /**
    +   * FilterEntityTypesController constructor.
    +   *
    +   * @param \Drupal\Core\Form\FormBuilderInterface $formBuilder
    +   *   The form builder service.
    +   */
    +  public function __construct(FormBuilderInterface $formBuilder) {

    The documentation comment for constructors is not mandatory anymore, If it is given, the description must be Constructs a new [class name] object. where [class name] includes the class namespace.

    -   * @return The `content()` function is returning a Drupal form object generated by the `getForm()`
    -   *   method of the `Drupal\formBuilder()` service. The form being returned is
    +   * @return \Drupal\Core\Form\FormInterface
    +   *   A Drupal form object generated by the `getForm()` method
    +   *   of the `Drupal\formBuilder()` service. The form being returned is
        *   an instance of the `FilterEntityTypesForm` form defined in the
        *   `Drupal\entitytype_filter\Form` namespace.

    Code shown in documentation comments is not quoted with `.

    +  /**
    +   * Creates an instance of the FilterFieldTypesController class.
    +   *
    +   * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
    +   *   The service container.
    +   *
    +   * @return static
    +   *   A new instance of the FilterFieldTypesController class.
    +   */

    The documentation comment for a method inherited from a parent class or defined in an interface is different.

     /**
      * Class of FilterFieldTypesController.
      */

    Since that documentation comment is changed, also the class description must be changed, as the description must not repeat the class name.

  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Harsh

    I have updated the patch as per comment #3.Please review

  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function __construct(FormBuilderInterface $formBuilder) {

    That is not the documentation comment for constructors. Also, the documentation comment for constructors is not mandatory anymore.

    +   * @return \Drupal\Core\Form\FormInterface
    +   *   Returns form object.

    The return value description must not start with Returns.
    Since that comment is changed, also the method description must be changed, as it must not start with The function returns.

     /**
    - * Class of FilterFieldTypesController.
    + * Manages the filtering of field types in Drupal.
      */

    in Drupal is not necessary.

  • Gaurav Gupta Jaipur, Rajasthsan

    Gaurav Gupta โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rakesh.regar Rajasthan, India

    rakesh.regar โ†’ made their first commit to this issueโ€™s fork.

  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rakesh.regar Rajasthan, India

    MR raised updating status to needs review.

  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rakesh.regar Rajasthan, India
  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rakesh.regar Rajasthan, India
  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    A summary must describe what needs to be changed, and eventually why. A screenshot is not sufficient, even in the case a patch/MR is provided.
    In the case of bug reports, the steps to reproduce the bug should be provided too. In the case of coding standards issues found using an automatic tool, the report given by that tool must be quoted too, including the arguments passed to that tool, if it is a command line tool.

    Also, since the MR is changing more files than the ones reported in the issue summary, I take the issue summary must be updated.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rakesh.regar Rajasthan, India

    Hey @apaderno

    I have made some changes in PR and had some confution about the comment, please check it.
    Thanks.

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

    The issue summary update does not say which command has been used to obtain the quoted report nor which CLI arguments have been passed to the command.

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

    Issue summary updated

  • First commit to issue fork.
  • Status changed to Needs review 2 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia manish-31

    I have updated the MR with the changes required as per the MR feedback. Needs review.

    I confirmed that there are no errors when running PHP CodeSniffer now, so I'm updating the issue status to 'Needs Review'.

  • Status changed to RTBC 20 days ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia deepak5423

    After applying !MR5 no phpcs error was found.
    Looks good to me.

  • Pipeline finished with Success
    20 days ago
    Total: 150s
    #192830
Production build 0.69.0 2024