Fix the issues reported by phpcs

Created on 4 July 2023, over 1 year ago
Updated 4 October 2023, about 1 year ago

Problem/Motivation

FILE: /var/www/html/vb/d_cont/remove_meta_info/remove_meta_info.module
--------------------------------------------------------------------------------
FOUND 9 ERRORS AND 1 WARNING AFFECTING 9 LINES
--------------------------------------------------------------------------------
9 | WARNING | [ ] Format should be "* Implements hook_foo().", "* Implements
| | hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements
| | hook_foo_BAR_ID_bar() for xyz-bar.html.twig.", "*
| | Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or
| | "* Implements hook_foo_BAR_ID_bar() for block templates."
10 | ERROR | [x] There must be exactly one blank line before the tags in a
| | doc comment
10 | ERROR | [ ] Missing parameter comment
13 | ERROR | [x] Opening brace should be on the same line as the declaration
14 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
15 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
16 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
17 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
18 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
19 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/remove_meta_info/remove_meta_info.info.yml
------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------
5 | ERROR | [x] Expected 1 newline at end of file; 0 found
------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------

FILE: .../remove_meta_info/src/EventSubscriber/RemoveMetaInfoResponseSubscriber.php
--------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
--------------------------------------------------------------------------------
13 | ERROR | [x] Opening brace should be on the same line as the declaration
21 | ERROR | [ ] Public method name
| | "RemoveMetaInfoResponseSubscriber::HeadersManagerOptions" is
| | not in lowerCamel format
22 | ERROR | [x] Opening brace should be on the same line as the declaration
31 | ERROR | [x] Opening brace should be on the same line as the declaration
35 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 79ms; Memory: 8MB

Steps to reproduce

Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig remove_meta_info/

Remaining tasks

Patch review

šŸ“Œ Task
Status

RTBC

Version

1.0

Component

Code

Created by

šŸ‡®šŸ‡³India urvashi_vora Madhya Pradesh, India

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 @urvashi_vora
  • Status changed to Needs work about 1 year ago
  • šŸ‡®šŸ‡³India Ashutosh Ahirwal India

    I reviewed attached patch its showing error while applying and didn't get applied cleanly.

    Output is

    remove_meta_info % git apply -v coding-standard-fixes_4.patch
    Checking patch remove_meta_info.info.yml...
    error: while searching for:
    description: Custom Module created to manage meta-info from head and headers
    package: 'Contrib'
    type: module
    core_version_requirement: ^8 || ^9 || ^10
    error: patch failed: remove_meta_info.info.yml:2
    error: remove_meta_info.info.yml: patch does not apply
    Checking patch remove_meta_info.module...
    error: while searching for:

    /**
    * Implements hook_page_attachements_alter().
    * @param array $attachments
    */
    function remove_meta_info_page_attachments_alter(array &$attachments)
    {
    foreach ($attachments['#attached']['html_head'] as $key => $attachment) {
    if ($attachment[1] == 'system_meta_generator') {
    unset($attachments['#attached']['html_head'][$key]);
    }
    }
    }
    error: patch failed: remove_meta_info.module:7
    error: remove_meta_info.module: patch does not apply
    Checking patch src/EventSubscriber/RemoveMetaInfoResponseSubscriber.php...
    error: while searching for:
    * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
    * The event to process.
    */
    public function HeadersManagerOptions(FilterResponseEvent $event)
    {
    $response = $event->getResponse();
    $response->headers->remove('X-Generator');
    }

    error: patch failed: src/EventSubscriber/RemoveMetaInfoResponseSubscriber.php:18
    error: src/EventSubscriber/RemoveMetaInfoResponseSubscriber.php: patch does not apply

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

    Created a patch, please review. Also adding screenshot.

  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi sakthi_dev,

    I applied your patch #3 and I confirmed that it resolve all the PHPCS issues.

    āžœ  remove_meta_info git:(1.0.x) curl https://www.drupal.org/files/issues/2023-09-28/phpcs-3372170-3.patch | git apply -v
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3138  100  3138    0     0  10283      0 --:--:-- --:--:-- --:--:-- 10530
    Checking patch README.md...
    Checking patch remove_meta_info.module...
    Checking patch src/EventSubscriber/RemoveMetaInfoResponseSubscriber.php...
    Applied patch README.md cleanly.
    Applied patch remove_meta_info.module cleanly.
    Applied patch src/EventSubscriber/RemoveMetaInfoResponseSubscriber.php cleanly.
    āžœ  remove_meta_info git:(1.0.x) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml remove_meta_info 
    āžœ  contrib git:(master) āœ— 
    

    retaining the status to needs review, RTBC +1 for me

  • šŸ‡¬šŸ‡§United Kingdom schillerm

    Hi, I also applied the patch to version 1.0.x-dev on a Drupal 10 site.
    All PHPCS errors are resolved. RTBC +1 from me.

  • Status changed to RTBC about 1 year ago
  • šŸ‡®šŸ‡³India aayushDrupal

    Hi sakthi_dev,

    I have applied patch #3 and addressed all the PHPCS issues. I have included a screenshot for your convenience.

    Moving to RTBC.
    Thank you.

Production build 0.71.5 2024