Fix the issues reported by phpcs

Created on 13 July 2022, over 2 years ago
Updated 18 July 2024, 7 months ago

GitLab CI reports PHP_CodeSniffer errors/warnings which should be fixed. There are still 16 errors and two warnings to fix.

šŸ“Œ Task
Status

Needs work

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

Merge Requests

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 almost 2 years ago
  • šŸ‡ØšŸ‡¦Canada imustakim Canada

    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 almost 2 years ago
  • Status changed to Needs work almost 2 years 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
  • Merge request !1#3295666 ā†’ (Open) created by nitin_lama
  • Issue was unassigned.
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Status changed to Needs review over 1 year ago
  • Status changed to Needs work over 1 year 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
  • šŸ‡ØšŸ‡¦Canada imustakim Canada
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡ØšŸ‡¦Canada imustakim Canada

    MR is updated.
    Please review.

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

    Your changes in MR!1 was applied not-so successfully, might be the reason the errors below were still reported. Please see:

    sessionless git:(1.x) curl https://git.drupalcode.org/project/sessionless/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 20609    0 20609    0     0  49569      0 --:--:-- --:--:-- --:--:-- 51012
    patching file sessionless_forms/sessionless_forms.module
    Hunk #2 succeeded at 24 with fuzz 2 (offset 2 lines).
    patching file sessionless_forms/src/SessionlessFormCache.php
    patching file sessionless_forms/src/SessionlessFormsServiceProvider.php
    patching file sessionless_session/sessionless_session.info.yml
    patching file sessionless_session/src/SessionlessSession.php
    Hunk #1 FAILED at 11.
    1 out of 1 hunk FAILED -- saving rejects to file sessionless_session/src/SessionlessSession.php.rej
    patching file sessionless_session/src/SessionlessStickyQueryFactory.php
    patching file sessionless_session/src/StickyQueryStorageEncryptionDecorator.php
    patching file src/CryptoKeyStorage.php
    patching file src/CryptoService.php
    patching file src/Element/SessionlessElementTrait.php
    patching file src/Element/SignedEncryptedData.php
    āžœ  sessionless git:(1.x) āœ— cd ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig sessionless
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/sessionless/sessionless_session/src/SessionlessStickyQueryFactory.php
    ----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------------------------
     31 | WARNING | Line exceeds 80 characters; contains 87 characters
    ----------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/sessionless/sessionless_session/src/SessionlessSession.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 25 ERRORS AFFECTING 25 LINES
    -----------------------------------------------------------------------------------------------------------------------------------
      15 | ERROR | [ ] Missing member variable doc comment
      17 | ERROR | [ ] Missing member variable doc comment
      22 | ERROR | [x] Expected 1 blank line after function; 2 found
      25 | ERROR | [x] Missing function doc comment
      26 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
      29 | ERROR | [x] Missing function doc comment
      33 | ERROR | [x] Missing function doc comment
      35 | ERROR | [x] Missing function doc comment
      39 | ERROR | [x] Missing function doc comment
      41 | ERROR | [x] Missing function doc comment
      43 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
      46 | ERROR | [x] Missing function doc comment
      47 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
      50 | ERROR | [x] Missing function doc comment
      52 | ERROR | [x] Missing function doc comment
      57 | ERROR | [x] Missing function doc comment
      62 | ERROR | [x] Missing function doc comment
      68 | ERROR | [x] Missing function doc comment
      72 | ERROR | [x] Missing function doc comment
      78 | 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
      98 | ERROR | [x] Missing function doc comment
     102 | ERROR | [x] Missing function doc comment
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 23 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/sessionless/sessionless_session/src/StickyQueryStorageEncryptionDecorator.php
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------------------------
     35 | WARNING | Line exceeds 80 characters; contains 95 characters
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 282ms; Memory: 10MB

    Kindly check

    Thanks,
    Jake

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    apaderno ā†’ changed the visibility of the branch 3295666-fix-the-issues to hidden.

  • Pipeline finished with Failed
    7 months ago
    Total: 128s
    #228005
  • Pipeline finished with Failed
    7 months ago
    Total: 128s
    #228011
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    apaderno ā†’ changed the visibility of the branch 3295666-gitlab-ci-reports to hidden.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
Production build 0.71.5 2024