Fix the issues reported by phpcs

Created on 13 July 2022, almost 2 years ago
Updated 24 October 2023, 8 months ago

Problem/Motivation

FILE: D:\xampp\htdocs\drupal9.5\web\modules\contrib\sessionless\sessionless_forms\sessionless_forms.module
----------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] Missing file doc comment
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 20 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\drupal9.5\web\modules\contrib\sessionless\sessionless_forms\src\SessionlessFormCache.php
--------------------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AFFECTING 10 LINES
--------------------------------------------------------------------------------------------------------------
   1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
  25 | ERROR | [ ] Missing member variable doc comment
  27 | ERROR | [ ] Missing member variable doc comment
  29 | ERROR | [ ] Missing member variable doc comment
  31 | ERROR | [ ] Missing member variable doc comment
  33 | ERROR | [ ] Missing member variable doc comment
  35 | ERROR | [ ] Missing member variable doc comment
  37 | ERROR | [x] Missing function doc comment
  46 | ERROR | [x] Missing function doc comment
 123 | ERROR | [x] Missing function doc comment
--------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\drupal9.5\web\modules\contrib\sessionless\sessionless_forms\src\SessionlessFormsServiceProvider.php
-------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-------------------------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
  9 | ERROR | [x] Missing class doc comment
 11 | ERROR | [x] Missing function doc comment
-------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\drupal9.5\web\modules\contrib\sessionless\sessionless_session\sessionless_session.info.yml
----------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------
 7 | ERROR | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\drupal9.5\web\modules\contrib\sessionless\sessionless_session\src\SessionlessSession.php
--------------------------------------------------------------------------------------------------------------
FOUND 24 ERRORS AFFECTING 24 LINES
--------------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 14 | ERROR | [ ] Missing member variable doc comment
 16 | ERROR | [ ] Missing member variable doc comment
 18 | ERROR | [x] Missing function doc comment
 21 | ERROR | [x] Expected 1 blank line after function; 2 found
 24 | ERROR | [x] Missing function doc comment
 26 | ERROR | [x] Missing function doc comment
 30 | ERROR | [x] Missing function doc comment
 32 | ERROR | [x] Missing function doc comment
 36 | ERROR | [x] Missing function doc comment
 38 | ERROR | [x] Missing function doc comment
 42 | ERROR | [x] Missing function doc comment
 44 | ERROR | [x] Missing function doc comment
 46 | ERROR | [x] Missing function doc comment
 51 | ERROR | [x] Missing function doc comment
 56 | ERROR | [x] Missing function doc comment
 62 | ERROR | [x] Missing function doc comment
 66 | ERROR | [x] Missing function doc comment
 72 | ERROR | [x] Missing function doc comment
 78 | ERROR | [x] Missing function doc comment
 82 | ERROR | [x] Missing function doc comment
 86 | ERROR | [x] Missing function doc comment
 90 | ERROR | [x] Missing function doc comment
 94 | ERROR | [x] Missing function doc comment
--------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 22 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\drupal9.5\web\modules\contrib\sessionless\sessionless_session\src\SessionlessStickyQueryFactory.php
-------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 6 LINES
-------------------------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 11 | ERROR | [x] Missing class doc comment
 13 | ERROR | [ ] Missing member variable doc comment
 15 | ERROR | [ ] Missing member variable doc comment
 17 | ERROR | [x] Missing function doc comment
 22 | ERROR | [x] Missing function doc comment
-------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\drupal9.5\web\modules\contrib\sessionless\sessionless_session\src\StickyQueryStorageEncryptionDecorator.php
---------------------------------------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AFFECTING 10 LINES
---------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 13 | ERROR | [ ] Missing member variable doc comment
 15 | ERROR | [ ] Missing member variable doc comment
 17 | ERROR | [ ] Missing member variable doc comment
 19 | ERROR | [ ] Missing short description in doc comment
 20 | ERROR | [ ] Missing parameter comment
 21 | ERROR | [ ] Missing parameter comment
 22 | ERROR | [ ] Missing parameter comment
 30 | ERROR | [x] Missing function doc comment
 41 | ERROR | [x] Missing function doc comment
---------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\drupal9.5\web\modules\contrib\sessionless\src\CryptoKeyStorage.php
----------------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 7 LINES
----------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 10 | ERROR | [x] Doc comment short description must end with a full stop
 22 | ERROR | [ ] Missing member variable doc comment
 24 | ERROR | [x] Missing function doc comment
 26 | ERROR | [x] Expected 1 blank line after function; 2 found
 29 | ERROR | [x] Missing function doc comment
 39 | ERROR | [x] Missing function doc comment
----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\drupal9.5\web\modules\contrib\sessionless\src\CryptoService.php
------------------------------------------------------------------------------------------------------------
FOUND 20 ERRORS AND 1 WARNING AFFECTING 21 LINES
------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
   6 | WARNING | [x] Unused use statement
  19 | ERROR   | [ ] Missing member variable doc comment
  21 | ERROR   | [ ] Missing member variable doc comment
  23 | ERROR   | [x] Missing function doc comment
  26 | ERROR   | [x] Expected 1 blank line after function; 2 found
  29 | ERROR   | [x] Missing function doc comment
  31 | ERROR   | [ ] Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead
  36 | ERROR   | [x] Missing function doc comment
  41 | ERROR   | [x] Expected newline after closing brace
  48 | ERROR   | [x] Missing function doc comment
  55 | ERROR   | [ ] Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead
  60 | ERROR   | [x] Missing function doc comment
  68 | ERROR   | [x] Missing function doc comment
  80 | ERROR   | [x] Missing function doc comment
  88 | ERROR   | [x] Missing function doc comment
  93 | ERROR   | [x] Missing function doc comment
  95 | ERROR   | [ ] Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead
 100 | ERROR   | [x] Missing function doc comment
 102 | ERROR   | [ ] Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead
 107 | ERROR   | [x] Missing function doc comment
------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 15 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\drupal9.5\web\modules\contrib\sessionless\src\Element\SessionlessElementTrait.php
----------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AFFECTING 8 LINES
----------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
  8 | ERROR | [x] Missing trait doc comment
 10 | ERROR | [x] Missing function doc comment
 11 | ERROR | [x] Language constructs must be followed by a single space; expected 1 space but found "  "
 12 | ERROR | [x] Expected 1 blank line after function; 0 found
 13 | ERROR | [x] Missing function doc comment
 18 | ERROR | [x] Missing function doc comment
 22 | ERROR | [x] Missing function doc comment
----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\drupal9.5\web\modules\contrib\sessionless\src\Element\SignedEncryptedData.php
---------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
---------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  5 | WARNING | [x] Unused use statement
 22 | ERROR   | [x] Missing function doc comment
---------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------

Steps to reproduce

Run following command
phpcs --standard=โ€œDrupal,DrupalPracticeโ€ --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml,css,js .

๐Ÿ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Harsh panchal

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

Not all content is available!

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

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

    The issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, show which command has been used, which arguments have been used, and which report that command shown.

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia imustakim Ahmedabad

    Issue summary updated.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Ashutosh Ahirwal India

    Providing patch with fixes.
    Please review.

  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dineshkumarbollu

    Hi

    The patch#6 applied cleanly with no phpcs errors.

    Moving +RTBC

  • Status changed to RTBC about 1 year ago
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +/**
    + * @file
    + * Provide some extra functionality for module.
    + */

    The usual description is Hook implementations for the [module name] module. (Indeed, [module name] must be replaced by the module name.)

    +  /**
    +   * The module handler service.
    +   *
    +   * @var \Drupal\Core\Extension\ModuleHandlerInterface
    +   */

    There is no need to say it is a service.

    +  /**
    +   * The cryptography service.
    +   *
    +   * @var \Drupal\Component\Utility\CryptoService
    +   */
       protected CryptoService $cryptoService;

    Drupal core does not have any \Drupal\Component\Utility\CryptoService class.

    +  /**
    +   * {@inheritdoc}
    +   */
       public function __construct(string $root, ModuleHandlerInterface $moduleHandler, AccountInterface $currentUser, CsrfTokenGenerator $csrfToken, LoggerChannelInterface $logger, CryptoService $cryptoService) {
    
    {@inheritdoc}

    is not used for constructors.

    +/**
    + * Class to providing functionality SessionlessFormsServiceProvider.
    + */

    Class descriptions must not start with Class not repeat the class name.
    That description does not make sense either.

    +  /**
    +   * The sticky query storage implementation used for storing sticky queries.
    +   *
    +   * @var \Drupal\sticky_query\StickyQueryStorage\StickyQueryStorageInterface
    +   */
       protected StickyQueryStorageInterface $storage;

    What is a sticky query storage?

     /**
    - * Key Storage
    + * Key Storage.
      *
      * @internal
      *

    The definite article is missing in the short description.

    +  /**
    +   * The key storage object for this class.
    +   *
    +   * @var \Drupal\Core\Encryption\CryptoKeyStorage
    +   */
    +  protected $keyStorage;

    There is no need to say for this class: Every property is for the class that defines it.

    -    /** @noinspection PhpUnnecessaryLocalVariableInspection */
    +    /* @noinspection PhpUnnecessaryLocalVariableInspection */

    That line is already correct as it is.

    +  /**
    +   * {@inheritdoc}
    +   */
       protected static function getCryptoService(): CryptoService {

    {@inheritdoc} cannot be used for traits that do not inherit from other traits.

  • Assigned to nitin_lama
  • @nitin_lama opened merge request.
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs review 8 months ago
  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +/**
    + * @file
    + * Sessionless Forms module for encrypting and signing form data.
    + */

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

    +  /**
    +   * The module handler service.
    +   *
    +   * @var \Drupal\Core\Extension\ModuleHandlerInterface
    +   */
    +  /**
    +   * The CSRF token generator service.
    +   *
    +   * @var \Drupal\Core\Access\CsrfTokenGenerator
    +   */
       protected CsrfTokenGenerator $csrfToken;
     
    +  /**
    +   * The logger channel service.
    +   *
    +   * @var \Drupal\Core\Logger\LoggerChannelInterface
    +   */
       protected LoggerChannelInterface $logger;

    There is no need to say service in the descriptions.

    +  /**
    +   * The CryptoService for handling encryption and signing.
    +   *
    +   * @var \Drupal\sessionless\CryptoService
    +   */
       protected CryptoService $cryptoService;

    The description must not include the class name.

    +  /**
    +   * Get cache.
    +   *
    +   * Retrieves the cached form data from encrypted fields.
    +   *
    +   * @param string $form_build_id
    +   *   The form build ID.
    +   * @param \Drupal\Core\Form\FormStateInterface $form_state
    +   *   The form state.
    +   *
    +   * @return mixed
    +   *   The cached form.
    +   */

    The verb in the short description must be declined to the third person singular.
    I am not sure the long description is correct, since the cached data is not retrieved from the encrypted fields. It is retrieved from the cache.

    +  /**
    +   * Delete cache.
    +   *
    +   * Deletes cached form data.
    +   *
    +   * @param string $form_build_id
    +   *   The form build ID to identify the cached data.

    There is no need to use short and long description, when the long description is an one-line description.

    +/**
    + * Service provider for Sessionless Forms module.
    + */
     class SessionlessFormsServiceProvider extends ServiceProviderBase {
     

    The description must not include the class name. It is also too generic.

    +  /**
    +   * The storage for session data.
    +   *
    +   * @var \Drupal\sticky_query\StickyQueryStorage\StickyQueryStorageInterface
    +   */
       protected StickyQueryStorageInterface $storage;

    It does not seem that is the session data storage.

    +  /**
    +   * SessionlessSession constructor.
    +   *
    +   * @param \Drupal\sticky_query\StickyQueryStorage\StickyQueryStorageInterface $storage
    +   *   The storage for session data.
    +   * @param bool $encrypt
    +   *   (Optional) TRUE to encrypt session data, FALSE to skip encryption.
    +   */
       public function __construct(StickyQueryStorageInterface $storage, bool $encrypt = TRUE) {

    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.

    +  /**
    +   * Start the session.
    +   */
       public function start() {}
     
    +  /**
    +   * Get the session ID.
    +   *
    +   * @return string
    +   *   The session ID.
    +   */
       public function getId() {
         return 'sessionless';
       }
     
    +  /**
    +   * Set the session ID.
    +   *
    +   * @param string $id
    +   *   The session ID.
    +   */

    The verb in the description must be declined to the third person singular.

    I would also check which of those methods are defined in an interface, as in that case the documentation comments are different.

    +   * @return \BadMethodCallException
    +   *   An exception indicating the method is not allowed.

    Thrown exceptions are documented with @throws, not @return.

     /**
    - * Key Storage
    + * Key Storage.

    Only the first word in the description is capitalized. A definite article is missing.

    +  /**
    +   * The state service for managing key storage.
    +   *
    +   * @var \Drupal\Core\State\StateInterface
    +   */
       protected StateInterface $state;

    The usual description of that service is The state key value store.

  • First commit to issue fork.
  • Assigned to imustakim
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia imustakim Ahmedabad
  • Issue was unassigned.
  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia imustakim Ahmedabad

    MR is updated.
    Please review.

Production build 0.69.0 2024