Fix the issues reported by phpcs

Created on 25 April 2023, over 1 year ago
Updated 28 January 2024, 10 months ago

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

FILE: /var/www/html/vbd7/web/modules/contrib/microblogging/microblogging.routing.yml
------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------
21 | WARNING | Open page callback found, please add a comment before the line why there is no access restriction
------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd7/web/modules/contrib/microblogging/src/StatusAccessControlHandler.php
------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------
30 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
52 | ERROR | [x] Expected 1 blank line after function; 2 found
55 | ERROR | [x] The closing brace for the class must have an empty line before it
------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd7/web/modules/contrib/microblogging/src/MicroBloggingHelper.php
---------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 19 ERRORS AFFECTING 15 LINES
---------------------------------------------------------------------------------------------------------------------------------------------------------
9 | ERROR | [x] Missing class doc comment
11 | ERROR | [ ] Class property $num_per_page should use lowerCamel naming without underscores
11 | ERROR | [ ] Missing member variable doc comment
16 | ERROR | [ ] Missing parameter comment
16 | ERROR | [ ] Missing parameter type
18 | ERROR | [ ] Description for the @return value is missing
19 | ERROR | [x] Separate the @return and @throws sections by a blank line.
28 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
34 | ERROR | [x] No space found before comment text; expected "// Get object of entity type manager." but found "//Get object of entity type manager."
40 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
96 | ERROR | [ ] Missing parameter comment
96 | ERROR | [ ] Missing parameter type
98 | ERROR | [ ] Description for the @return value is missing
118 | ERROR | [x] Expected 1 blank line after function; 2 found
124 | ERROR | [ ] Missing parameter comment
126 | ERROR | [ ] Description for the @return value is missing
137 | ERROR | [ ] Missing parameter comment
137 | ERROR | [ ] Missing parameter type
139 | ERROR | [ ] Description for the @return value is missing
---------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd7/web/modules/contrib/microblogging/src/Controller/TimelineController.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 16 ERRORS AND 2 WARNINGS AFFECTING 17 LINES
-------------------------------------------------------------------------------------------------------------------------------
23 | ERROR | [x] Doc comment short description must end with a full stop
26 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
30 | ERROR | [ ] Missing short description in doc comment
35 | ERROR | [ ] Missing short description in doc comment
40 | ERROR | [ ] Missing short description in doc comment
48 | ERROR | [ ] Missing parameter comment
49 | ERROR | [ ] Missing parameter comment
50 | ERROR | [ ] Missing parameter comment
51 | ERROR | [ ] Missing parameter comment
52 | ERROR | [ ] Missing parameter comment
60 | WARNING | [ ] User::load calls should be avoided in classes, use dependency injection instead
82 | ERROR | [ ] Missing parameter comment
84 | ERROR | [ ] Description for the @return value is missing
94 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
115 | ERROR | [ ] Missing parameter comment
126 | ERROR | [x] Expected 1 space after TRY keyword; 0 found
135 | ERROR | [x] Expected newline after closing brace
135 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd7/web/modules/contrib/microblogging/src/Form/StatusForm.php
----------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------
37 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------

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

FILE: /var/www/html/vbd7/web/modules/contrib/microblogging/src/Form/Frontend/StatusAddForm.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 12 ERRORS AND 4 WARNINGS AFFECTING 14 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
19 | ERROR | [x] Doc comment short description must end with a full stop
22 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
25 | ERROR | [ ] Missing short description in doc comment
26 | ERROR | [x] Data types in @var tags need to be fully namespaced
26 | ERROR | [x] Do not append variable name "$account" to the type declaration in a member variable comment
30 | ERROR | [ ] Missing short description in doc comment
74 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
118 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
124 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
160 | ERROR | [x] Doc comment short description must end with a full stop
162 | ERROR | [ ] Description for the @return value is missing
201 | ERROR | [ ] Missing parameter comment
202 | ERROR | [ ] Missing parameter comment
228 | ERROR | [x] Inline comments must start with a capital letter
228 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
230 | WARNING | [ ] File::load calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd7/web/modules/contrib/microblogging/src/Plugin/Field/FieldFormatter/AuthorHeader.php
------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------------------------------
29 | WARNING | [x] There must be no blank line following an inline comment
29 | WARNING | [x] 'Todo: Below code is not independent.' should match the format '@todo Fix problem X here.'
29 | WARNING | [ ] There must be no blank line following an inline comment
35 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
36 | ERROR | [x] Object operator not indented correctly; expected 6 spaces but found 8
39 | WARNING | [x] The variable name should be defined after the type
41 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd7/web/modules/contrib/microblogging/src/Ajax/UpdateTimelineCommand.php
---------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
---------------------------------------------------------------------------------------------
10 | ERROR | [x] Doc comment long description must end with a full stop
16 | ERROR | [ ] Missing member variable doc comment
18 | ERROR | [ ] Missing member variable doc comment
20 | ERROR | [ ] Missing member variable doc comment
22 | ERROR | [x] Missing function doc comment
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------

FILE: /var/www/html/vbd7/web/modules/contrib/microblogging/src/StatusListBuilder.php
------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------
29 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------

FILE: /var/www/html/vbd7/web/modules/contrib/microblogging/assets/dist/css/timeline.css
---------------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 7 LINES
---------------------------------------------------------------------------------------
124 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 5
125 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 10
175 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 5
176 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 10
228 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 5
229 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 10
457 | ERROR | [x] Expected 1 newline at end of file; 0 found
---------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------

FILE: /var/www/html/vbd7/web/modules/contrib/microblogging/microblogging.permissions.yml
----------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------
19 | ERROR | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------

FILE: /var/www/html/vbd7/web/modules/contrib/microblogging/microblogging.module
--------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------
9 | ERROR | [x] Function comment short description must start with exactly one space
--------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------

FILE: /var/www/html/vbd7/web/modules/contrib/microblogging/status.page.inc
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
24 | WARNING | Unused variable $status.
--------------------------------------------------------------------------

Time: 1.08 secs; Memory: 14MB

RUN:

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

๐Ÿ“Œ Task
Status

RTBC

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia dineshkumarbollu

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 @dineshkumarbollu
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dineshkumarbollu

    Hi

    I fixed all the issues except Dependency injections

    please review.

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines kenyoOwen

    Hi dineshkumarbollu

    I applied patch #2 to the โ€œMicro Bloggingโ€ module and confirmed that the phpcs issue mentioned are resolved except for the Dependency injections. Needs work for others can fix the remaining issue. Please see the screenshots attached.

    For your review.
    Thank you.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia _pratik_ Banglore
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    -    _access: 'TRUE'
    +    _access: true

    The warning is: Open page callback found, please add a comment before the line why there is no access restriction. No comment has been added to explain why the access to that route is not restricted.

    _access: 'TRUE' is correct and it is used by Drupal core too.

    system.401:
      path: '/system/401'
      defaults:
        _controller: '\Drupal\system\Controller\Http4xxController:on401'
        _title: 'Unauthorized'
      requirements:
        _access: 'TRUE'
    
    system.403:
      path: '/system/403'
      defaults:
        _controller: '\Drupal\system\Controller\Http4xxController:on403'
        _title: 'Access denied'
      requirements:
        _access: 'TRUE'
    
    system.404:
      path: '/system/404'
      defaults:
        _controller: '\Drupal\system\Controller\Http4xxController:on404'
        _title: 'Page not found'
      requirements:
        _access: 'TRUE'
    
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Ashutosh Ahirwal India

    Addressed #5.
    Providing patch with updated work

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    - * Class UpdateTimelineCommand
    + * Class UpdateTimelineCommand.

    It is not necessary to report the class name in a class documentation comment.

    +  /**
    +   * Defines status.
    +   *
    +   * @var string
    +   */
       protected $status;
    -
    +  /**
    +   * Wrapper.
    +   *
    +   * @var int
    +   */
       protected $wrapper;
    -
    +  /**
    +   * Html variable.
    +   *
    +   * @var int
    +   */
       protected $html;

    Those descriptions are not much helpful and need to be improved.

    +  /**
    +   * {@inheritdoc}
    +   */
       public function __construct($status, $wrapper, $html) {

    {@inheritdoc} is not used in documentation comments for constructors.

     /**
    - * Class TimelineController
    + * Defines TimelineController class.
      *
      * @package Drupal\microblogging\Controller

    That description is still repeating the class name, instead of describing the class purpose.

    +   * Route match service.
    +   *
        * @var \Drupal\Core\Routing\RouteMatchInterface

    A definite article is missing from the description.

       /**
    +   * The user service.
    +   *
        * @var \Drupal\user\UserInterface
        */
       protected $currentUser;

    That is not a correct description, since $currentUser does not contain a service, but a specific entity instance.

       /**
    +   * Renderer service.
    +   *
        * @var \Drupal\Core\Render\Renderer
        * @param \Drupal\Core\Routing\RouteMatchInterface $routeMatch
    +   *   Route match object.
        * @param \Drupal\Core\Session\AccountProxyInterface $account
    +   *   Account Proxy service.
        * @param \Drupal\Core\Form\FormBuilderInterface $formBuilder
    +   *   Form Builder service.
        * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
    +   *   Entity type service.
        * @param \Drupal\Core\Render\Renderer $renderer
    +   *   Renderer service.
    

    A definite article is missing from each of those descriptions too.

        * @return array
    +   *   Returns array.

    The return value description must say what is returned not its type, which is already given with @return array.

    -    // Load status
    +    // Load status.
         $data = MicroBloggingHelper::getStatus($user->id());

    That comment is not necessary, since it describes something that is already clear.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    Addressed the issue in #7. Please review is that fine.

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

    Hi @sakthi_dev, thanks for the patch, I have reviewed your patch.

    These are the steps I followed:

    1. Took clone from git version 1.0.x in drupal 10.1.x

    2. Ran this command:

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

    3. Applied patch and again ran phpcs command,

    Found 1 white space error after applying patch.

    Found errors after ran phpcs command.

    4. I ran phpcbf to fix errors and created a patch and fixed the remaining errors,

    then again check with phpcs command found no errors.

    Attached patch file and screenshots.

    Please Review.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia mrinalini9 New Delhi

    Hi,

    I have reviewed patch #10, looks good to me. It applied cleanly and fixed phpcs issues but still few of them are remaining that need to be fixed:

    FILE: /microblogging/assets/js/timeline.js
    ------------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AFFECTING 3 LINES
    ------------------------------------------------------------------------------------------------
      4 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
      7 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
     22 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
    ------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------
    
    
    FILE: /microblogging/src/Ajax/UpdateTimelineCommand.php
    ---------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------
     42 | ERROR | Type hint "array" missing for $html
    ---------------------------------------------------------------------------------------------------------
    

    Please fix these errors as well.

    Thanks & Regards,
    Mrinalini

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

    Please review. Addressed the comment #11.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia mrinalini9 New Delhi

    Reviewed patch #12, looks good to me. It applied cleanly and fixed all the phpcs issues.
    So, for me, it is RTBC.

    Thanks!

  • Status changed to RTBC 10 months ago
  • Hi,
    I have reviewed patch #12, it looks good to me. It applied cleanly and fixed phpcs errors and warning.
    So changing the status to RTBC.
    Thankyou.

Production build 0.71.5 2024