Fix the issues reported by phpcs

Created on 13 May 2023, over 1 year ago
Updated 7 June 2024, 7 months ago
šŸ“Œ Task
Status

Needs work

Component

Code

Created by

šŸ‡®šŸ‡³India Shanu Chouhan

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 @Shanu Chouhan
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India Shanu Chouhan

    Here's a patch for it.

  • Status changed to Needs work over 1 year ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
    +/**
    + * {@inheritdoc}
    + */
     class DecoupledOneTimeLoginMailer implements DecoupledOneTimeLoginMailerInterface {
    

    {@inheritdoc} is not used in the documentation comment for classes.

    +  /**
    +   * The config factory used by the config entity query.
    +   *
    +   * @var \Drupal\Core\Config\ConfigFactoryInterface
    +   */
       protected ConfigFactoryInterface $configFactory;

    The config factory. is sufficient.

    +  /**
    +   * Constructs a EntityActionBase object.
    +   *
    +   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
    +   *   The entity type manager.
    +   * @param \Drupal\Core\Mail\MailManagerInterface $mail_manager
    +   *   The mail manager.
    +   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
    +   *   The config factory.
    +   */
    +
    +  /**
    +   * Constructs a Plugin object.
    +   */
       public function __construct(EntityTypeManagerInterface $entity_type_manager, MailManagerInterface $mail_manager, ConfigFactoryInterface $config_factory) {
         $this->entityTypeManager = $entity_type_manager;
         $this->mailManager = $mail_manager;
         $this->configFactory = $config_factory;
       }

    There are two documentation comments for the same method, but neither of them are correct.

    The description for a constructor must start with Constructs a new followed by the class name (including its namespace), and end with object.
    The documentation comment for a method must also describe the parameters.

    +/**
    + * Provides an interface  Decoupled One Time Login Mail.
    + */
     interface DecoupledOneTimeLoginMailerInterface {
    

    It is not necessary to say that an interface provides an interface.
    The description must say that the interface does.

    +  /**
    +   * Constructs a cron object.
    +   *
    +   * @param \Drupal\Component\Datetime\TimeInterface $time
    +   *   The time service.
    +   */
    +
    +  /**
    +   * Constructs a Plugin object.
    +   */
       public function __construct(TimeInterface $time) {
         $this->time = $time;
       }

    Given than the class is DecoupledOneTimeLoginTokens, how can the constructor construct a cron object?
    Still, there are two documentation comments for the same method.

    +  /**
    +   * Gets a one time login URL.
    +   *
    +   * @see user_pass_reset_url()
    +   */
       public function oneTimeLogin(UserInterface $account): string {

    Parameters and return value must be described.

    +/**
    + * {@inheritdoc}
    + */
     interface DecoupledOneTimeLoginTokensInterface {

    {@inheritdoc} is not used in the documentation comment for an interface.

     /**
    + * Build email addresses.
      *
      * @EmailBuilder(

    The description must be less generic.

  • Assigned to arpitk
  • šŸ‡®šŸ‡³India arpitk

    Updating the patch.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India arpitk

    worked on the patch. Please review.

    Thanks!

  • Status changed to Needs work over 1 year ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
    +/**
    + * @file
    + * Contains decoupled_one_time_login.module.
    + */
    +

    The usual module description is Hook implementations for the [module name] module. where [module name] is replaced by the module name as shown in the .info.yml file.

    +/**
    + * @file
    + * Hooks related to the Token system.
    + */

    Token must be spelled in lowercase characters, since it is not referring to a class.

    +  /**
    +   * The config factory used by the config entity query.
    +   *

    It is sufficient to say The config factory.

    +  /**
    +   * Constructs a new DecoupledOneTimeLoginMailer object.
    +   *

    The description for a constructor must start with Constructs a new followed by the class name (including its namespace), and end with object.

    +/**
    + * Provides Interface for Decoupled One Time Login Mail.
    + */
     interface DecoupledOneTimeLoginMailerInterface {
    

    The description for an interface must not start with Provides Interface, Provides an interface, or similar phrases.

    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function sendMail(string $op = 'password_reset', AccountInterface $account = NULL, string $langcode = NULL);

    Since interfaces just define their own methods, {@inheritdoc} is never used for interface methods.

    +   * @see user_pass_reset_url()
    +   *
    +   * @return string
    +   *   A string with one time login url.

    The line containing @see must be the last line in a documentation comment.
    The return value description must describe what the return value is, not its type.

     /**
    + * Defines the Email Builder plug-in for decoupled_one_time_login module.

    There is no need to say which module implements a class, nor even by giving the module machine name.
    Email and Builder must be spelled with lowercase characters.
    The description must say what the class does.

  • šŸ‡®šŸ‡³India _pratik_ Banglore

    In response to #6.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
    +/**
    + * @file
    + * Hook implementations for the Decoupled on time login module.
    + */

    The module name reported in its .info.yml file is Decoupled one time login.

    +/**
    + * Provides Interface for Decoupled One Time Login Mail.
    + */

    Similarly to what done for the other description, this description should be changed too.

    +  /**
    +   * Constructs a DecoupledOneTimeLoginTokens object.
    +   *
    +   * @param \Drupal\Component\Datetime\TimeInterface $time

    The description for a constructor must start with Constructs a new followed by the class name (including its namespace), and end with object.

    +   * @return string
    +   *   Returns one time login url.

    Return value descriptions must not start with Returns nor Return.
    url is misspelled because it is an acronym and it must be written with uppercase letters.

    +/**
    + * Provides an interface defining oneTimeLogin tokens.
    + */

    The correct description is probably Provides an interface to handle one-time login tokens.

     /**
    + * Defines the Email Builder plug-in for decoupled_one_time_login module.
      *

    There is no need to say which module implements that plugin. Instead, the description should say what that plugin does.

  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India sakthi_dev

    Please review.

  • Status changed to Needs work 7 months ago
  • Hi @sakthi_dev,

    Applied your patch successfully, however, it still threw an error. Please see below:

    Giuseppe87-3359929 git:(main) curl https://www.drupal.org/files/issues/2023-05-18/phpcs-3360159-9.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    100  6572  100  6572    0     0  19711      0 --:--:-- --:--:-- --:--:-- 20159
    patching file decoupled_one_time_login.module
    patching file decoupled_one_time_login.tokens.inc
    patching file src/DecoupledOneTimeLoginMailer.php
    patching file src/DecoupledOneTimeLoginMailerInterface.php
    patching file src/DecoupledOneTimeLoginTokens.php
    patching file src/DecoupledOneTimeLoginTokensInterface.php
    patching file src/Plugin/EmailBuilder/PasswordResetBuilder.php
    āžœ  Giuseppe87-3359929 git:(main)
    āžœ  Giuseppe87-3359929 git:(main) āœ— cd ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig Giuseppe87-3359929
    
    FILE: ...es/contrib/Giuseppe87-3359929/src/DecoupledOneTimeLoginMailerInterface.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     12 | ERROR | [x] Missing function doc comment
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...web/modules/contrib/Giuseppe87-3359929/src/DecoupledOneTimeLoginMailer.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     37 | WARNING | Line exceeds 80 characters; contains 90 characters
    --------------------------------------------------------------------------------
    
    
    FILE: ...web/modules/contrib/Giuseppe87-3359929/src/DecoupledOneTimeLoginTokens.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    --------------------------------------------------------------------------------
     21 | WARNING | [ ] Line exceeds 80 characters; contains 89 characters
     41 | ERROR   | [x] Additional blank lines found at end of doc comment
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    Time: 169ms; Memory: 10MB

    Kindly check.

    Thanks,
    Jake

  • Pipeline finished with Success
    7 months ago
    Total: 138s
    #193819
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
Production build 0.71.5 2024