Fix the issues reported by phpcs and phpstan

Created on 18 May 2023, over 1 year ago
Updated 4 June 2024, 6 months ago

Problem/Motivation

Running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml . returns errors. See pipelines.

๐Ÿ“Œ Task
Status

Fixed

Version

2.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia arpitk

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 @arpitk
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia arpitk
  • Issue was unassigned.
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia arpitk
  • Status changed to Needs review over 1 year ago
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • First commit to issue fork.
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dineshkumarbollu

    Hi

    After applied the patch i run the phpcs command it shows some errors

    vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig web/modules/contrib/session_limit-3361326/

    FILE: /var/www/html/vbd9/web/modules/contrib/session_limit-3361326/src/Services/SessionLimit.php
    -------------------------------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
    -------------------------------------------------------------------------------------------------------------------
    251 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    308 | ERROR | Protected method name "SessionLimit::_onSessionCollision__Ask" is not in lowerCamel format
    324 | ERROR | Protected method name "SessionLimit::_onSessionCollision__PreventNew" is not in lowerCamel format
    341 | ERROR | Protected method name "SessionLimit::_onSessionCollision__DropOldest" is not in lowerCamel format
    -------------------------------------------------------------------------------------------------------------------

    FILE: /var/www/html/vbd9/web/modules/contrib/session_limit-3361326/src/Form/SessionLimitForm.php
    ------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------
    135 | ERROR | Doc comment is empty
    ------------------------------------------------------------------------------------------------

    FILE: /var/www/html/vbd9/web/modules/contrib/session_limit-3361326/src/Form/SettingsForm.php
    -----------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------
    16 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
    -----------------------------------------------------------------------------------------------------------------

    FILE: /var/www/html/vbd9/web/modules/contrib/session_limit-3361326/src/Event/SessionLimitCollisionEvent.php
    -----------------------------------------------------------------------------------------------------------
    FOUND 5 ERRORS AFFECTING 5 LINES
    -----------------------------------------------------------------------------------------------------------
    8 | ERROR | Doc comment is empty
    13 | ERROR | Missing short description in doc comment
    18 | ERROR | Missing short description in doc comment
    23 | ERROR | Missing short description in doc comment
    28 | ERROR | Missing short description in doc comment
    -----------------------------------------------------------------------------------------------------------

    FILE: /var/www/html/vbd9/web/modules/contrib/session_limit-3361326/src/Event/SessionLimitDisconnectEvent.php
    ------------------------------------------------------------------------------------------------------------
    FOUND 5 ERRORS AFFECTING 5 LINES
    ------------------------------------------------------------------------------------------------------------
    7 | ERROR | Doc comment is empty
    12 | ERROR | Missing short description in doc comment
    17 | ERROR | Missing short description in doc comment
    22 | ERROR | Missing short description in doc comment
    27 | ERROR | Missing short description in doc comment
    ------------------------------------------------------------------------------------------------------------

    Time: 1.97 secs; Memory: 16MB

    thanks,

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia arpitk

    Hi @dineshkumarbollu I have mentioned in the remaining task in the issue summary these need to fixed. that's why i kept the status to need work.

    Thanks!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dineshkumarbollu

    Hi

    Someone cahnged the status to reviewed that's why i test the module.

    Thanks

  • Status changed to Needs review over 1 year ago
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    Created a patch along with the remaining issues. Please review.

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
       /**
    +   * The bypass.
    +   *
        * @var bool
        */

    That description is repeating the property name.

       /**
    +   * Implements shouldBypass()
    +   *

    Method descriptions must not start with Implements/Implement nor repeat the method name.

    +/**
    + * Implements Session limit collision event.
    + */

    Class descriptions must not start with Implements/Implement nor repeat the class name.

       /**
    +   * The useractivesessions value.
    +   *
        * @var int
        */
       protected $userActiveSessions;

    The description is repeating the property name without saying what is its purpose.

    * @param int $sessionId
    - * @param AccountInterface $account
    + * The sessionId.
    + * @param \Drupal\Core\Session\AccountInterface $account
    + * The account.
    * @param int $userActiveSessions
    + * The userActiveSessions.
    * @param int $userMaxSessions
    + * The userMaxSessions.

    All those descriptions are repeating the parameter name.

       /**
    +   * Implements getSessionId().
    +   *
        * @return int
    +   *   Returns int.
        */
       public function getSessionId() {

    The return value description must not start with Returns/Return nor repeat the return value type, which is already given in the previous line.

    +  /**
    +   * The current user.
    +   *
    +   * @var \Drupal\session_limit\Services\SessionLimit
    +   */
    +  protected $sessionLimit;

    The description is not for that property.

    +  /**
    +   * Constructs a new SessionLimitForm object.
    +   *
    +   * @param \Drupal\Core\Session\AccountInterface $current_user
    +   *   The current user instance.
    +   * @param \Drupal\session_limit\Services\SessionLimit $session_limit
    +   *   The current user instance.
    +   * @param \Drupal\Core\Session\SessionManagerInterface $session_manager
    +   *   The session manager service.
    +   * @param \Drupal\Core\Datetime\DateFormatter $dateFormatter
    +   *   The date formatter.
    +   */

    The class name is missing its namespace.
    There is no need to say instance in the parameter description.
    The same description is given for two different parameters.

  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India

    Addressed #10. Updated patch.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +   * Constructs a new \Drupal\session_limit\Event\SessionLimitCollisionEvent
    +   * constructor.
        *

    A constructor constructs a new object, not a new constructor.
    The description must be in a single line.

    -   * @param AccountInterface $account
    +   *   The sessionId.

    It should be The session ID.

        * @param int $userActiveSessions
    +   *   The user active session ID.
        * @param int $userMaxSessions
    +   *   The maximum user session.

    Given the parameter names, those descriptions are not correct.

    + * Get session ID.

    A definite article is missing before session.
    The verb needs to be declined on the third person singular.

  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India

    Addressed #14. Updated patch.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    Thanks for patch, here is feedback for patch #16.
    Please remove all the t() methods from Test files. And check my comments below.

    1. +++ b/tests/session_limit.test
      @@ -66,17 +73,17 @@ class SessionLimitBaseTestCase extends DrupalWebTestCase {
      +      $this->assertText($this->t('Log out'), $this->t('User is logged in under session @no.', ['@no' => $session_number]));
      

      no need for t() method here, use string and sprintf.

    2. +++ b/tests/session_limit.test
      @@ -299,18 +306,18 @@ class SessionLimitBaseTestCase extends DrupalWebTestCase {
      -   * getInfo() returns properties that are displayed in the test selection form.
      +   * GetInfo() returns properties that are displayed in the test selection form.
      

      getInfo and GetInfo is 2 different methods. I would not make this change.

    3. +++ b/tests/session_limit.test
      @@ -427,29 +435,24 @@ class SessionLimitLogoutTestCase extends SessionLimitBaseTestCase {
      +    // $roles = $this->sessionLimitMakeRoles($user);
      

      Why this line is going to be removed?

    4. +++ b/tests/session_limit.test
      @@ -427,29 +435,24 @@ class SessionLimitLogoutTestCase extends SessionLimitBaseTestCase {
      +    // // @FIXME
      

      Let's add phpcs:disable

    There are a lot of changes, let's switch to MR workflow, to simplify review.

  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India

    Addressing #18.1 #18.2
    Providing updated patch.

  • Merge request !10#3361326: MR for the changes. โ†’ (Merged) created by nitin_lama
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 10 months ago
    Waiting for branch to pass
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 10 months ago
    Waiting for branch to pass
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India

    MR created. Please review.

  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Status changed to Needs review 10 months ago
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 10 months ago
    Waiting for branch to pass
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    Thanks, I provided review.

  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia mohd sahzad

    Mohd Sahzad โ†’ made their first commit to this issueโ€™s fork.

  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 10 months ago
    Waiting for branch to pass
  • Status changed to Needs review 10 months ago
  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • First commit to issue fork.
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 10 months ago
    Waiting for branch to pass
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • First commit to issue fork.
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Pipeline finished with Success
    9 months ago
    Total: 139s
    #110477
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Pipeline finished with Success
    9 months ago
    Total: 140s
    #110514
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Pipeline finished with Canceled
    9 months ago
    #110545
  • Pipeline finished with Running
    9 months ago
    #110547
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Pipeline finished with Canceled
    9 months ago
    Total: 23s
    #110548
  • Pipeline finished with Success
    9 months ago
    Total: 141s
    #110552
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Pipeline finished with Success
    9 months ago
    Total: 241s
    #110560
  • Pipeline finished with Success
    9 months ago
    Total: 226s
    #110563
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Pipeline finished with Success
    9 months ago
    #110594
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Pipeline finished with Success
    9 months ago
    Total: 139s
    #110598
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Pipeline finished with Success
    9 months ago
    Total: 133s
    #110602
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Pipeline finished with Success
    9 months ago
    Total: 211s
    #110663
  • Pipeline finished with Success
    9 months ago
    Total: 140s
    #110678
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Pipeline finished with Success
    9 months ago
    Total: 139s
    #110706
  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom welly

    Right, I think this is ready to be looked at. There were some additional changes that needed making. Would be keen on any feedback on the changes made (this included enabling gitlab-ci for the module and then making updates to pass phpstan tests)

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia VladimirAus Brisbane, Australia
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia VladimirAus Brisbane, Australia
  • Status changed to Needs work 7 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia VladimirAus Brisbane, Australia
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia VladimirAus Brisbane, Australia
  • Status changed to Needs review 6 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia VladimirAus Brisbane, Australia

    PHPStan has only one issue and it depends on the other module.

  • Status changed to Needs work 6 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia jannakha Brisbane!
  • Status changed to Needs review 6 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia VladimirAus Brisbane, Australia

    Ready for review.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia VladimirAus Brisbane, Australia
  • Status changed to RTBC 6 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia jannakha Brisbane!

    That's great!
    Ready for release!

  • Pipeline finished with Skipped
    6 months ago
    #177970
  • Status changed to Fixed 6 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia VladimirAus Brisbane, Australia

    Committed and released! ๐Ÿป
    Thanks everyone!

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

Production build 0.71.5 2024