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

CommentFileSizeAuthor
#18 phpcs_fix.patch3.6 KBShreyas gowda
#4 3395184-4.patch11.33 KBharsh
#2 3395184-2.patch11.86 KBharsh
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

Harsh created an issue. See original summary.

harsh’s picture

Status: Active » Needs review
StatusFileSize
new11.86 KB

I have fixed the phpcs issues.Please review the patch

avpaderno’s picture

Status: Needs review » Needs work
+  /**
+   * 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.

harsh’s picture

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

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

avpaderno’s picture

Status: Needs review » Needs work
+  /**
+   * {@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 made their first commit to this issue’s fork.

rakesh.regar made their first commit to this issue’s fork.

rakesh.regar’s picture

Status: Needs work » Needs review

MR raised updating status to needs review.

avpaderno’s picture

Status: Needs review » Needs work
rakesh.regar’s picture

Status: Needs work » Needs review
avpaderno’s picture

Status: Needs review » Needs work
rakesh.regar’s picture

Status: Needs work » Needs review
avpaderno’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

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.

rakesh.regar’s picture

Hey @apaderno

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

avpaderno’s picture

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.

zkhan.aamir’s picture

Issue summary updated

Shreyas gowda’s picture

StatusFileSize
new3.6 KB

manish-31 made their first commit to this issue’s fork.

manish-31’s picture

Status: Needs work » Needs review

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'.

deepak5423’s picture

Status: Needs review » Reviewed & tested by the community

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

hetal.solanki’s picture

keshav patel’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone, I've merged the changes.

keshav patel’s picture

Status: Fixed » Closed (fixed)

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