Fix the issues reported by phpcs

Created on 21 November 2023, about 1 year ago
Updated 22 November 2023, about 1 year ago

Problem/Motivation

FILE: ...nt_notification/src/Controller/ContentNotificationController.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 7 WARNINGS AFFECTING 7 LINES
----------------------------------------------------------------------
  15 | WARNING | The class short comment should describe what the
     |         | class does and not simply repeat the class name
 142 | WARNING | \Drupal calls should be avoided in classes, use
     |         | dependency injection instead
 143 | WARNING | \Drupal calls should be avoided in classes, use
     |         | dependency injection instead
 146 | WARNING | \Drupal calls should be avoided in classes, use
     |         | dependency injection instead
 163 | WARNING | \Drupal calls should be avoided in classes, use
     |         | dependency injection instead
 164 | WARNING | \Drupal calls should be avoided in classes, use
     |         | dependency injection instead
 167 | WARNING | \Drupal calls should be avoided in classes, use
     |         | dependency injection instead
----------------------------------------------------------------------


FILE: ...s/custom/content_notification/src/ContentNotificationService.php
----------------------------------------------------------------------
FOUND 3 ERRORS AND 14 WARNINGS AFFECTING 17 LINES
----------------------------------------------------------------------
  92 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 153 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 301 | ERROR   | [ ] unserialize() is insecure unless allowed classes
     |         |     are limited. Use a safe format like JSON or use
     |         |     the allowed_classes option.
 306 | ERROR   | [x] Use "elseif" in place of "else if"
 337 | WARNING | [ ] Only string literals should be passed to t()
     |         |     where possible
 339 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 343 | WARNING | [ ] Only string literals should be passed to t()
     |         |     where possible
 345 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 355 | WARNING | [ ] User::loadMultiple calls should be avoided in
     |         |     classes, use dependency injection instead
 367 | ERROR   | [x] Inline comments must start with a capital letter
 369 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 373 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 388 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 394 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 397 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 399 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 400 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...om/content_notification/src/Form/ContentNotificationEditForm.php
----------------------------------------------------------------------
FOUND 6 ERRORS AND 7 WARNINGS AFFECTING 12 LINES
----------------------------------------------------------------------
  57 | ERROR   | unserialize() is insecure unless allowed classes are
     |         | limited. Use a safe format like JSON or use the
     |         | allowed_classes option.
  83 | WARNING | #options values usually have to run through t() for
     |         | translation
  84 | WARNING | #options values usually have to run through t() for
     |         | translation
 186 | ERROR   | The array declaration extends to column 90 (the
     |         | limit is 80). The array content should be split up
     |         | over multiple lines
 229 | ERROR   | Missing short description in doc comment
 237 | WARNING | Avoid backslash escaping in translatable strings
     |         | when possible, use "" quotes instead
 243 | WARNING | Translatable strings must not begin or end with
     |         | white spaces, use placeholders with t() for
     |         | variables
 243 | ERROR   | Concatenating translatable strings is not allowed,
     |         | use placeholders instead and only one string literal
 250 | ERROR   | Concatenating translatable strings is not allowed,
     |         | use placeholders instead and only one string literal
 257 | ERROR   | Missing short description in doc comment
 279 | WARNING | \Drupal calls should be avoided in classes, use
     |         | dependency injection instead
 280 | WARNING | \Drupal calls should be avoided in classes, use
     |         | dependency injection instead
 283 | WARNING | \Drupal calls should be avoided in classes, use
     |         | dependency injection instead
----------------------------------------------------------------------


FILE: ...tom/content_notification/src/Form/ContentNotificationAddForm.php
----------------------------------------------------------------------
FOUND 4 ERRORS AND 8 WARNINGS AFFECTING 11 LINES
----------------------------------------------------------------------
  73 | WARNING | [ ] #options values usually have to run through t()
     |         |     for translation
  74 | WARNING | [ ] #options values usually have to run through t()
     |         |     for translation
 173 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: 'current-user'
 217 | ERROR   | [ ] Missing short description in doc comment
 225 | WARNING | [ ] Avoid backslash escaping in translatable strings
     |         |     when possible, use "" quotes instead
 231 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
 231 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
 238 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
 245 | ERROR   | [ ] Missing short description in doc comment
 267 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 268 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 271 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: .../content_notification/src/Form/ContentNotificationDeleteForm.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------
  59 | WARNING | t() calls should be avoided in classes, use
     |         | \Drupal\Core\StringTranslation\StringTranslationTrait
     |         | and $this->t() instead
  73 | WARNING | t() calls should be avoided in classes, use
     |         | \Drupal\Core\StringTranslation\StringTranslationTrait
     |         | and $this->t() instead
 100 | ERROR   | Missing short description in doc comment
----------------------------------------------------------------------

Steps to reproduce

If you are on a lando environment and phpcs is configured in your .lando.yml file, run the command lando phpcs <path location of the module>. If you are not using lando run the following command, phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,twig,yml <path location of the module>

📌 Task
Status

Fixed

Version

2.6

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024