Fix the errors/warnings reported by PHP_CodeSniffer & phpstan

Created on 16 January 2024, 6 months ago
Updated 5 February 2024, 5 months ago

Problem/Motivation

When running the module code against Drupal coding standards based on Drupal standard, the module shows errors

Steps to reproduce

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

Report:

FILE: /home/contribution/drupal/web/modules/contrib/microsoft_teams_notifier/src/MicrosoftTeamsConnector.php
--------------------------------------------------------------------------------------------------------------
FOUND 19 ERRORS AND 6 WARNINGS AFFECTING 20 LINES
--------------------------------------------------------------------------------------------------------------
  6 | ERROR   | [x] Doc comment short description must end with a full stop
  9 | ERROR   | [x] Opening brace should be on the same line as the declaration
 10 | ERROR   | [ ] Missing member variable doc comment
 12 | ERROR   | [x] Missing function doc comment
 13 | ERROR   | [x] Opening brace should be on the same line as the declaration
 17 | ERROR   | [x] Missing function doc comment
 20 | ERROR   | [x] Concat operator must be surrounded by a single space
 36 | WARNING | [x] A comma should follow the last multiline array item. Found: $currentRelease
 40 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 43 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
 47 | ERROR   | [x] Expected 1 space after "=>"; 2 found
 47 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 62 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
 63 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
 67 | ERROR   | [ ] Parameter $message is not described in comment
 68 | ERROR   | [x] Doc comment short description must end with a full stop
 70 | ERROR   | [ ] Parameter comment must start with a capital letter
 70 | ERROR   | [x] Parameter comment must be on the next line
 70 | ERROR   | [x] Parameter comment must end with a full stop
 71 | ERROR   | [ ] Parameter comment must start with a capital letter
 71 | ERROR   | [x] Parameter comment must be on the next line
 71 | ERROR   | [x] Parameter comment must end with a full stop
 81 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 86 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 97 | ERROR   | [x] Expected 1 blank line after function; 0 found
--------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 21 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/microsoft_teams_notifier/src/Form/SettingsForm.php
--------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------------------------------------
  7 | WARNING | [x] Unused use statement
  8 | WARNING | [x] Unused use statement
 37 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
--------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------

Phpstan Report:

 php vendor/bin/phpstan.phar
 ------ ------------------------------------------------------------------------------
  Line   src/MicrosoftTeamsConnector.php
 ------ ------------------------------------------------------------------------------
  23     \Drupal calls should be avoided in classes, use dependency injection instead
  62     \Drupal calls should be avoided in classes, use dependency injection instead
  63     \Drupal calls should be avoided in classes, use dependency injection instead
 ------ ------------------------------------------------------------------------------
📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India realsp

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

Production build 0.69.0 2024