Add phpcs and drupal-check fixes

Created on 25 February 2022, over 2 years ago
Updated 7 May 2024, 7 months ago

Problem/Motivation

Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib
$ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,js,yml seckit/

FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\contrib\seckit\src\EventSubscriber\SecKitEventSubscriber.php
---------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------
 413 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\contrib\seckit\tests\src\Functional\SecKitTestCaseTest.php
------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------------------------
 481 | ERROR | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request instead
------------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 792ms; Memory: 16MB

Steps to reproduce

Run following command

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml seckit/

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Needs review

Version

2.0

Component

Code

Created by

🇮🇳India bendale

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.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    Patch Failed to Apply
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    Patch Failed to Apply
  • 🇬🇧United Kingdom mcdruid 🇬🇧🇪🇺

    Unfortunately these patches tend to need a lot of rerolls... and this one apparently does.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    Patch Failed to Apply
  • 🇮🇳India sourabhjain

    Rerolled the patch @mcdruid. Please review.
    I have not included the below issue as its already in the https://www.drupal.org/project/seckit/issues/3117054 📌 Fix the warnings/errors reported by PHP_CodeSniffer Fixed
    [x] Expected 1 space after FUNCTION keyword; 0 found

  • Status changed to Needs work over 1 year ago
  • 🇬🇧United Kingdom mcdruid 🇬🇧🇪🇺

    Is there anything left to do here now that 📌 Fix the warnings/errors reported by PHP_CodeSniffer Fixed has landed?

    If so, we'll need a new patch/MR please.

  • Assigned to imustakim
  • Issue was unassigned.
  • 🇮🇳India zkhan.aamir

    Issue summary updated

  • Status changed to Needs review 11 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.2 & MySQL 8
    last update 11 months ago
    2 fail
  • 🇮🇳India chaitanyadessai Goa

    phpcs fixes, Drupal check, please review patch.

  • Status changed to Needs work 11 months ago
  • 🇮🇳India zkhan.aamir

    Hi,

    I applied patch #16, Patch applied cleanly.
    Still getting error.
    Please check.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib/seckit (2.x)
    $ curl https://www.drupal.org/files/issues/2023-12-26/3266561-16.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 24774  100 24774    0     0  61149      0 --:--:-- --:--:-- --:--:-- 61321
    patching file seckit.services.yml
    patching file src/EventSubscriber/SecKitEventSubscriber.php
    patching file src/Form/SecKitSettingsForm.php
    patching file tests/src/Functional/SecKitTestCaseTest.php
    
    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib/seckit (2.x)
    $ cd ../
    
    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib
    $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml seckit/
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\contrib\seckit\tests\src\Functional\SecKitTestCaseTest.php
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
     484 | ERROR | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request instead
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 611ms; Memory: 16MB
    
    
  • 🇮🇳India Yashaswi18

    I tried applying the patch provided in #16, it applied successfully.
    git apply 3266561-16.patch -v
    Checking patch seckit.services.yml...
    Checking patch src/EventSubscriber/SecKitEventSubscriber.php...
    Checking patch src/Form/SecKitSettingsForm.php...
    Checking patch tests/src/Functional/SecKitTestCaseTest.php...
    Applied patch seckit.services.yml cleanly.
    Applied patch src/EventSubscriber/SecKitEventSubscriber.php cleanly.
    Applied patch src/Form/SecKitSettingsForm.php cleanly.
    Applied patch tests/src/Functional/SecKitTestCaseTest.php cleanly.

     phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml seckit/
    
    FILE: C:\Users\YASHASWI\OneDrive\Desktop\Contrib\seckit\src\EventSubscriber\SecKitEventSubscriber.php
    -----------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------
     1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
    -----------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------
    
    
    FILE: C:\Users\YASHASWI\OneDrive\Desktop\Contrib\seckit\src\Form\SecKitSettingsForm.php
    ---------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------
     1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
    ---------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------
    
    
    FILE: C:\Users\YASHASWI\OneDrive\Desktop\Contrib\seckit\tests\src\Functional\SecKitTestCaseTest.php
    ---------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------
     1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
    ---------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------
    
    Time: 1.7 secs; Memory: 14MB
    

    Shows only these now.

  • 🇷🇺Russia zniki.ru
    +++ b/tests/src/Functional/SecKitTestCaseTest.php
    @@ -73,7 +76,7 @@ class SecKitTestCaseTest extends BrowserTestBase {
    +    $this->submitForm($form, $this->t('Save configuration'));
    

    No need for t() method in this test.
    These test are not language related tests, just use string.

    $this->submitForm($form, 'Save configuration');
    
  • Assigned to nitin_lama
  • Open on Drupal.org →
    Core: 7.x + Environment: PHP 7.4 & MySQL 5.7
    last update 10 months ago
    Not currently mergeable.
  • Issue was unassigned.
  • 🇷🇺Russia zniki.ru

    @nitin_lama issue is about Version 2.x-dev, and MR target branch is 7.x-1.x.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.2 & MySQL 8
    last update 10 months ago
    34 pass
  • 🇮🇳India zkhan.aamir

    Hi,

    MR #21 applied successfully

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib/seckit (2.x)
    $ curl https://git.drupalcode.org/project/seckit/-/merge_requests/21.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 21313    0 21313    0     0  47823      0 --:--:-- --:--:-- --:--:-- 47894
    patching file src/Form/SecKitSettingsForm.php
    patching file tests/src/Functional/SecKitTestCaseTest.php
    

    Still errors are remaining. Please check

    
    
    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib
    $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,js,yml seckit/
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\contrib\seckit\src\EventSubscriber\SecKitEventSubscriber.php
    ---------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------
     413 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ---------------------------------------------------------------------------------------------------------------------
    
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\contrib\seckit\tests\src\Functional\SecKitTestCaseTest.php
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
     481 | ERROR | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request instead
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 792ms; Memory: 16MB
    
  • 🇮🇳India zkhan.aamir

    Issue summary updated.

  • Assigned to nitin_lama
  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.2 & MySQL 8
    last update 9 months ago
    34 pass
  • Status changed to Needs review 9 months ago
  • 🇮🇳India sonvir249 Pune

    Fixed the errors mentioned in #25

  • 🇮🇳India Yashaswi18

    Cloned the repository, and ran the command phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,js,yml seckit/
    , only found this error remaining:

    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | ERROR | [x] End of line character is invalid; expected "\n" but found
       |       |     "\r\n"
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
  • 🇮🇳India nitin_lama India

    @Yashaswi18 did you clone the forked repo and switched to the recent MR branch and ran the command ?
    I don't see this error on "3266561-add-phpcs-and" branch.

  • Issue was unassigned.
  • Status changed to Needs work 7 months ago
  • 🇮🇳India dev16.addweb

    Hi,
    I have checked phpcs and found some errors in SecKitSettingsForm.php

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.2 & MySQL 8
    last update 7 months ago
    34 pass
  • Status changed to Needs review 7 months ago
Production build 0.71.5 2024