Fix the issues reported by phpcs

Created on 5 May 2023, about 2 years ago
Updated 8 May 2023, about 2 years ago

Problem/Motivation

FILE: ...on/drupal10/web/modules/contrib/media_orientation/media_orientation.module
--------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
--------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
11 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced
| | with use statements
12 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced
| | with use statements
27 | ERROR | [ ] Inline doc block comments are not allowed; use "/* Comment
| | */" or "// Comment" instead
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...n/drupal10/web/modules/contrib/media_orientation/src/OrientationHelper.php
--------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
83 | ERROR | Missing parameter comment
85 | ERROR | If there is no return value for a function, there must not be a
| | @return tag.
85 | ERROR | Description for the @return value is missing
--------------------------------------------------------------------------------

FILE: ...odules/contrib/media_orientation/src/Commands/MediaOrientationCommands.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
--------------------------------------------------------------------------------
25 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
27 | ERROR | [x] Separate the @param and @usage sections by a blank line.
37 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
42 | WARNING | [ ] Media::loadMultiple calls should be avoided in classes, use
| | dependency injection instead
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: .../drupal10/web/modules/contrib/media_orientation/media_orientation.info.yml
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
1 | WARNING | Remove "version" from the info file, it will be added by
| | drupal.org packaging automatically
--------------------------------------------------------------------------------

Time: 572ms; Memory: 10MB

Steps to reproduce

Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,yml,twig media_orientation/

Proposed resolution

Fix the issues reported for Drupal and DrupalPractice coding standards

Remaining tasks

Patch review.

๐Ÿ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia urvashi_vora Madhya Pradesh, India

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

Comments & Activities

  • Issue created by @urvashi_vora
  • Status changed to RTBC about 2 years ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines kenyoOwen

    Hi urvashi_vora

    I applied patch to the โ€œMedia orientatonโ€ module and confirmed that the mentioned PHPCS issues are resolved. Please see the screenshots attached.

    For your review.
    Thank you.

  • Status changed to Needs work about 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +/**
    + * @file
    + * Module file.
    + */

    The description for a module file is Hook implementations for the Media orientation module. (in this specific case).

    +  /**
    +   * Entity Query.
    +   *
    +   * @var \Drupal\Core\Entity\Query\QueryFactory

    Only the first word in the description must be capitalized.

    +  /**
    +   * The Get EntityTypeManagerInterface.
    +   *
    +   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
    +   */
    +  protected $entityTypeManager;

    That is The entity type manager.

    +  /**
    +   * Constructs object.
    +   *
    +   * @param \Drupal\Core\Entity\Query\QueryFactory $entityQuery
    

    Description for constructors starts with Constructs a new (the trailing space is included) followed by the class name (namespace included) and ends with object. (The space before object and the period after object are included.)

    +   *   Query Factory.
    +   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
    +   *   Entity Manager Interface.

    Only the first word in a description must be capitalized.
    It is The entity type manager.

        * @param \Drupal\Core\Entity\EntityInterface $entity
    -   *
    -   * @return void
    +   *   Entity Interface.

    The @return line is missing.
    The description is too generic. Also, a return value cannot be an interface; it can eventually be an object that implements an interface, but there is not an Entity interface.

  • Assigned to imustakim
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada imustakim Canada

    Working on this.

  • Issue was unassigned.
  • Status changed to Needs review about 2 years ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada imustakim Canada

    Patch updated as per #3 suggestions.
    Only error remaining is exceeding 80 characters in line, because of the constructor description containing class namespace.
    Assuming this cane be ignored.

    Please review.

Production build 0.71.5 2024