Fix the errors/warnings reported by PHP_CodeSniffer

Created on 24 April 2023, about 1 year ago
Updated 4 March 2024, 4 months ago

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

FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\acknowledgements\sign_for_acknowledgement.module
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 3 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  55 | 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."
 144 | 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."
 283 | 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."
 411 | ERROR   | Invalid function name, expected send_mail_bcc but found sendMailBcc
 411 | ERROR   | All functions defined in a module file must be prefixed with the module's name, found "sendMailBcc" but expected "sign_for_acknowledgement_sendMailBcc"
 445 | ERROR   | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\acknowledgements\src\Access\NodeTypeAccessCheck.php
------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------
 25 | ERROR | Missing parameter comment
 27 | ERROR | Parameter comment must start with a capital letter
------------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\acknowledgements\src\Controller\AcknowledgementsController.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------
 18 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 25 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
-----------------------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\acknowledgements\src\Form\AdminSettingsForm.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------------------------------
 137 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
 143 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
 149 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
 155 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
 321 | WARNING | #options values usually have to run through t() for translation
-----------------------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\acknowledgements\src\Form\AlternateForm.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 7 WARNINGS AFFECTING 6 LINES
------------------------------------------------------------------------------------------------------------------------------------------
  25 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
  42 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  68 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  68 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  75 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  84 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 109 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\acknowledgements\src\Form\CheckboxForm.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 7 WARNINGS AFFECTING 7 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
 24 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 41 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 56 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 60 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 72 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 78 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 82 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\acknowledgements\src\Form\FilterForm.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 14 ERRORS AND 7 WARNINGS AFFECTING 19 LINES
------------------------------------------------------------------------------------------------------------------------------------------
  27 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
  41 | ERROR   | Parameter comment must start with a capital letter
  43 | ERROR   | Description for the @return value must be on the next line
 135 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 165 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 172 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 177 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 182 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 189 | ERROR   | Doc comment is empty
 196 | ERROR   | Doc comment is empty
 207 | WARNING | Line exceeds 80 characters; contains 81 characters
 215 | ERROR   | Doc comment is empty
 227 | ERROR   | Doc comment is empty
 273 | ERROR   | Missing short description in doc comment
 274 | ERROR   | Missing parameter comment
 274 | ERROR   | Missing parameter name
 275 | ERROR   | Description for the @return value must be on the next line
 281 | ERROR   | Missing short description in doc comment
 282 | ERROR   | Missing parameter comment
 282 | ERROR   | Missing parameter name
 283 | ERROR   | Description for the @return value must be on the next line
------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\acknowledgements\src\Form\TableForm.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 15 WARNINGS AFFECTING 16 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
  24 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
  34 | ERROR   | Doc comment is empty
  39 | WARNING | Unused variable $session.
  40 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
  41 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
  44 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
  57 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  57 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
  64 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  73 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
  76 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  77 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  77 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
  77 | WARNING | Do not concatenate strings to translatable strings, they should be part of the t() argument and you should use placeholders
  82 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  92 | ERROR   | Doc comment is empty
  96 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 108 | ERROR   | Doc comment is empty
 111 | ERROR   | Public method name "TableForm::sign_submitForm" is not in lowerCamel format
---------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\acknowledgements\src\Plugin\views\field\SfaStatus.php
------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------
 18 | ERROR | Missing short description in doc comment
 27 | ERROR | Doc comment short description must end with a full stop
 27 | ERROR | Doc comment short description must be on a single line, further text should be a separate paragraph
------------------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\acknowledgements\src\Service\AcknowledgementsDatabase.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 36 ERRORS AND 25 WARNINGS AFFECTING 46 LINES
------------------------------------------------------------------------------------------------------------------------------------------
  34 | ERROR   | Missing @var tag in member variable comment
  37 | ERROR   | Parameter $database is not described in comment
  49 | ERROR   | Parameter $signature_timestamp is not described in comment
  49 | ERROR   | Parameter $alternate is not described in comment
  49 | ERROR   | Parameter $annotation is not described in comment
  53 | ERROR   | Parameter comment must start with a capital letter
  55 | ERROR   | Parameter comment must start with a capital letter
  56 | ERROR   | Doc comment for parameter $signature does not match actual variable name $annotation
  57 | ERROR   | Parameter comment must start with a capital letter
  79 | ERROR   | Parameter $annotation is not described in comment
  83 | ERROR   | Parameter comment must start with a capital letter
  85 | ERROR   | Parameter comment must start with a capital letter
  94 | WARNING | Unused variable $sign_id.
 106 | ERROR   | Parameter $agreement is not described in comment
 106 | ERROR   | Parameter $annotation is not described in comment
 110 | ERROR   | Parameter comment must start with a capital letter
 112 | ERROR   | Parameter comment must start with a capital letter
 113 | ERROR   | Missing parameter name
 123 | WARNING | Unused variable $sign_id.
 140 | ERROR   | Parameter comment must start with a capital letter
 142 | ERROR   | Parameter comment must start with a capital letter
 153 | ERROR   | Doc comment is empty
 164 | ERROR   | Parameter comment must start with a capital letter
 172 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 177 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 182 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 187 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 196 | ERROR   | Missing short description in doc comment
 198 | ERROR   | Parameter comment must start with a capital letter
 200 | ERROR   | Parameter comment must start with a capital letter
 201 | ERROR   | Description for the @return value must be on the next line
 238 | ERROR   | Doc comment is empty
 245 | ERROR   | Parameter $timestamp is not described in comment
 245 | ERROR   | Parameter $session_name is not described in comment
 245 | ERROR   | Parameter $csv is not described in comment
 249 | ERROR   | Parameter comment must start with a capital letter
 251 | ERROR   | Parameter comment must start with a capital letter
 253 | ERROR   | Parameter comment must start with a capital letter
 263 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 263 | ERROR   | The array declaration extends to column 118 (the limit is 80). The array content should be split up over multiple lines
 263 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 266 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 269 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 276 | WARNING | User::load calls should be avoided in classes, use dependency injection instead
 276 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 282 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 282 | ERROR   | The array declaration extends to column 111 (the limit is 80). The array content should be split up over multiple lines
 282 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 285 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 285 | ERROR   | The array declaration extends to column 115 (the limit is 80). The array content should be split up over multiple lines
 285 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 288 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 288 | ERROR   | The array declaration extends to column 91 (the limit is 80). The array content should be split up over multiple lines
 288 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 291 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 294 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 443 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 446 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 448 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 448 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 450 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------------------------------------------

Time: 1.74 secs; Memory: 14MB

๐Ÿ“Œ Task
Status

Needs work

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia sidharth_soman Bangalore

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 @sidharth_soman
  • Merge request !2Fixed phpcs issues. โ†’ (Open) created by sidharth_soman
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sidharth_soman Bangalore

    I fixed a total of 1180 coding standard errors in 21 different files using the automatic cbf command. There's a bunch of errors remaining... but they're mostly trivial stuff like editing or filling up doc comments and such. Meanwhile, I've issued an MR for the aforementioned fixes. Please review.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Assigned to arpitk
  • Status changed to Needs work about 1 year ago
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia arpitk

    Hi I have fixed the DI issues reported y phpcs. Still there is some errors/warning remaing that need to be fixed. Keeping the status as NW.
    Please review the MR https://git.drupalcode.org/project/acknowledgements/-/merge_requests/2

    Thanks!

  • Shruthi rao โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia zkhan.aamir

    Hi,

    MR#9 getting failed and rejected.

    $ curl https://git.drupalcode.org/project/acknowledgements/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  169k    0  169k    0     0   312k      0 --:--:-- --:--:-- --:--:--  314k
    patching file css/stylesheet.css
    Hunk #1 FAILED at 1 (different line endings).
    1 out of 1 hunk FAILED -- saving rejects to file css/stylesheet.css.rej
    patching file sign_for_acknowledgement.install
    patching file sign_for_acknowledgement.module
    patching file sign_for_acknowledgement.permissions.yml
    patching file sign_for_acknowledgement.routing.yml
    patching file sign_for_acknowledgement.services.yml
    patching file sign_for_acknowledgement.views.inc
    patching file src/Access/NodeTypeAccessCheck.php
    Hunk #1 FAILED at 1 (different line endings).
    1 out of 1 hunk FAILED -- saving rejects to file src/Access/NodeTypeAccessCheck.php.rej
    patching file src/Controller/AcknowledgementsController.php
    Hunk #1 FAILED at 1 (different line endings).
    1 out of 1 hunk FAILED -- saving rejects to file src/Controller/AcknowledgementsController.php.rej
    patching file src/Form/AdminSettingsForm.php
    patching file src/Form/AlternateForm.php
    Hunk #1 FAILED at 1 (different line endings).
    1 out of 1 hunk FAILED -- saving rejects to file src/Form/AlternateForm.php.rej
    patching file src/Form/CheckboxForm.php
    Hunk #1 FAILED at 1 (different line endings).
    1 out of 1 hunk FAILED -- saving rejects to file src/Form/CheckboxForm.php.rej
    patching file src/Form/FilterForm.php
    Hunk #1 FAILED at 1 (different line endings).
    1 out of 1 hunk FAILED -- saving rejects to file src/Form/FilterForm.php.rej
    patching file src/Form/TableForm.php
    Hunk #1 FAILED at 1 (different line endings).
    1 out of 1 hunk FAILED -- saving rejects to file src/Form/TableForm.php.rej
    patching file src/Plugin/views/argument/UserArgument.php
    patching file src/Plugin/views/field/SfaStatus.php
    Hunk #1 FAILED at 1 (different line endings).
    1 out of 1 hunk FAILED -- saving rejects to file src/Plugin/views/field/SfaStatus.php.rej
    patching file src/Plugin/views/field/User.php
    Hunk #1 FAILED at 1 (different line endings).
    1 out of 1 hunk FAILED -- saving rejects to file src/Plugin/views/field/User.php.rej
    patching file src/Plugin/views/filter/StatusFilter.php
    patching file src/Plugin/views/filter/UserFilter.php
    patching file src/Service/AcknowledgementsDatabase.php
    Hunk #1 FAILED at 1 (different line endings).
    1 out of 1 hunk FAILED -- saving rejects to file src/Service/AcknowledgementsDatabase.php.rej
    patching file src/Service/AcknowledgementsEmails.php
    patching file src/Service/AcknowledgementsNodeFields.php
    

    Updated issue summary.

Production build 0.69.0 2024