Fix the issues reported by phpcs

Created on 22 December 2022, over 1 year ago
Updated 7 June 2024, 17 days ago

Running phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/extra_field/returns the following warnings/errors, which should be fixed.

FILE: ./extra_field_8.x-2.x/modules/extra_field_example/src/Plugin/ExtraField/Form/ExampleMarkup.php
 39 | WARNING | #description values usually have to run through t() for translation

FILE: ./extra_field_8.x-2.x/modules/extra_field_example/src/Plugin/ExtraField/Form/CustomSubmit.php
 55 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t()
    |         | instead

FILE: ./extra_field_8.x-2.x/src/Plugin/ExtraFieldDisplayFormattedBase.php
 134 | WARNING | [x] 'TODO Add this to the interface in the 3.0.0 release.' should match the format '@todo Fix problem X here.'

FILE: ./extra_field_8.x-2.x/src/Plugin/ExtraFieldManagerBase.php
 30 | WARNING | [x] 'TODO Add this to the interface in the 3.0.0 release.' should match the format '@todo Fix problem X here.'

FILE: ./extra_field_8.x-2.x/src/Generators/extra-field-form.twig
  1 | ERROR   | [ ] An error occurred during processing; checking has been aborted. The error message was: Undefined index:
    |         |     scope_condition in
    |         |     /home/kiamlaluno/.config/composer/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php
    |         |     on line 288
  4 | ERROR   | [x] There should be no white space after an opening "{"
  4 | ERROR   | [x] Closing brace must be on a line by itself
  4 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
  6 | ERROR   | [x] Expected 1 space before "%"; 0 found
  6 | ERROR   | [x] Inline control structures are not allowed
  6 | ERROR   | [x] Expected 1 space after "%"; 0 found
  9 | ERROR   | [x] There should be no white space after an opening "{"
  9 | ERROR   | [x] Concat operator must be surrounded by a single space
  9 | ERROR   | [x] There should be no white space before a closing "}"
  9 | ERROR   | [x] Expected 1 space before "%"; 0 found
  9 | ERROR   | [x] Expected 1 space after "%"; 0 found
 11 | WARNING | [x] Unused use statement
 26 | ERROR   | [x] There should be no white space after an opening "{"
 26 | WARNING | [ ] Possible parse error: class missing opening or closing brace
 26 | ERROR   | [x] Missing class doc comment
 26 | ERROR   | [x] There should be no white space before a closing "}"
 26 | ERROR   | [x] Closing brace must be on a line by itself
 26 | ERROR   | [x] Expected 1 space before "%"; 0 found
 26 | ERROR   | [x] Expected 1 space after "%"; 0 found
 26 | ERROR   | [x] Expected 1 space before "%"; 0 found
 26 | ERROR   | [x] Expected 1 space after "%"; 0 found
 28 | WARNING | [x] Unused use statement
 28 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 28 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
 30 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 30 | ERROR   | [x] Expected 1 space before "%"; 0 found
 30 | ERROR   | [x] Inline control structures are not allowed
 30 | ERROR   | [x] Expected 1 space after "%"; 0 found
 31 | ERROR   | [x] There should be no white space after an opening "{"
 31 | ERROR   | [x] Concat operator must be surrounded by a single space
 31 | ERROR   | [x] There should be no white space before a closing "}"
 33 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 42 | ERROR   | [x] Doc comment star missing
 42 | ERROR   | [x] Parameter comment indentation must be 3 spaces, found 1 spaces
 42 | ERROR   | [x] Parameter comment must end with a full stop
 44 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 45 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 46 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 0
 47 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 49 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 52 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 53 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 55 | ERROR   | [x] Line indented incorrectly; expected at least 2 spaces, found 0
 57 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 60 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 63 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 64 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 71 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 72 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 74 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 82 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 83 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 84 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 85 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 6
 86 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 87 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2

FILE: ./extra_field_8.x-2.x/src/Generators/extra-field-display.twig
  4 | ERROR   | [x] There should be no white space after an opening "{"
  4 | ERROR   | [x] Closing brace must be on a line by itself
  4 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
  6 | ERROR   | [x] Expected 1 space before "%"; 0 found
  6 | ERROR   | [x] Inline control structures are not allowed
  6 | ERROR   | [x] Expected 1 space after "%"; 0 found
  9 | ERROR   | [x] There should be no white space after an opening "{"
  9 | ERROR   | [x] Concat operator must be surrounded by a single space
  9 | ERROR   | [x] There should be no white space before a closing "}"
  9 | ERROR   | [x] Expected 1 space before "%"; 0 found
  9 | ERROR   | [x] Expected 1 space after "%"; 0 found
 24 | ERROR   | [x] There should be no white space after an opening "{"
 24 | WARNING | [ ] Possible parse error: class missing opening or closing brace
 24 | ERROR   | [x] Missing class doc comment
 24 | ERROR   | [x] There should be no white space before a closing "}"
 24 | ERROR   | [x] Closing brace must be on a line by itself
 24 | ERROR   | [x] Expected 1 space before "%"; 0 found
 24 | ERROR   | [x] Expected 1 space after "%"; 0 found
 24 | ERROR   | [x] Expected 1 space before "%"; 0 found
 24 | ERROR   | [x] Expected 1 space after "%"; 0 found
 26 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 26 | ERROR   | [x] Expected 1 space before "%"; 0 found
 26 | ERROR   | [x] Inline control structures are not allowed
 26 | ERROR   | [x] Expected 1 space after "%"; 0 found
 27 | ERROR   | [x] There should be no white space after an opening "{"
 27 | ERROR   | [x] Concat operator must be surrounded by a single space
 27 | ERROR   | [x] There should be no white space before a closing "}"
 29 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 38 | ERROR   | [x] Doc comment star missing
 38 | ERROR   | [x] Parameter comment indentation must be 3 spaces, found 1 spaces
 38 | ERROR   | [x] Parameter comment must end with a full stop
 40 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 41 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 42 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 0
 43 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 45 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 48 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 49 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 51 | ERROR   | [x] Line indented incorrectly; expected at least 2 spaces, found 0
 53 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 56 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 59 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
 60 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 61 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 62 | ERROR   | [x] Line indented incorrectly; expected 0 spaces, found 2
📌 Task
Status

Needs review

Version

2.0

Component

Code

Created by

🇮🇳India samit.310@gmail.com

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.

  • 🇮🇳India Charchil Khandelwal

    I will review this patch.

  • 🇮🇳India Charchil Khandelwal

    Thanks @samit.310@gmail.com, patch #2 applied cleanly, all warnings are fixed.
    And i also created MR for same.
    Please review.

  • Status changed to RTBC about 1 year ago
  • 🇵🇭Philippines paraderojether

    Hi Charchil Khandelwal

    I reviewed MR!10, and verified it fixes the issues reported by the phpcs. Drupal core version 9.5.8, Extra Field 8.x-2.x-dev.

    I added screenshots for reference.
    Thank You.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    If I run phpcs for the 8.x-2.x branch of this module, I get a longer report.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update 7 months ago
    41 pass
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs review 4 months ago
  • 🇮🇳India zkhan.aamir

    Hi,

    MR #11 applied successfully.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/extra_field (8.x-2.x)
    $ curl https://git.drupalcode.org/project/extra_field/-/merge_requests/10.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4437    0  4437    0     0  12768      0 --:--:-- --:--:-- --:--:-- 12823
    patching file modules/extra_field_example/src/Plugin/ExtraField/Form/CustomSubmit.php
    patching file modules/extra_field_example/src/Plugin/ExtraField/Form/ExampleCustomInput.php
    patching file modules/extra_field_example/src/Plugin/ExtraField/Form/ExampleMarkup.php
    patching file src/Plugin/ExtraFieldDisplayFormattedBase.php
    Hunk #1 succeeded at 131 (offset -7 lines).
    patching file src/Plugin/ExtraFieldManagerBase.php
    patching file tests/src/Kernel/ExtraFieldDisplayPluginTest.php
    

    No issues remaining.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules
    $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,js,yml extra_field/
    
    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules
    $
    
    
    
  • 🇮🇳India dev16.addweb

    I received the phpcs error that is mentioned below, along with the patch that fixes the issues.

    
    phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml extra_field/
    
    FILE: /home/addweb/Drupal8-vagrant/web/web/patches/extra_field/src/Plugin/ExtraFieldDisplayManager.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------------------
       9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Cache\CacheBackendInterface.
     159 | ERROR | [x] list(...) is forbidden, use [...] instead.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
  • Status changed to Needs work 18 days ago
  • Hi @silvi.addweb,

    Your patch applied unsuccessfully

    extra_field git:(8335a0e) curl https://www.drupal.org/files/issues/2024-06-06/extra_field-3328761-14.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  1235  100  1235    0     0   2364      0 --:--:-- --:--:-- --:--:--  2416
    patching file src/Plugin/ExtraFieldDisplayManager.php
    Hunk #1 FAILED at 2.
    Hunk #2 FAILED at 156.
    2 out of 2 hunks FAILED -- saving rejects to file src/Plugin/ExtraFieldDisplayManager.php.rej

    Kindly check.

    Thanks,
    Jake

  • 🇮🇳India Prem Suthar gujrat

    The patch resolves all PHPCS issues once applied. Additionally, if possible, please create a Merge Request following the Drupal standard process.

  • Status changed to Needs review 17 days ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 5.7
    last update 17 days ago
    41 pass
  • Pipeline finished with Success
    17 days ago
    Total: 152s
    #193407
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
Production build 0.69.0 2024