Fix the errors reported by phpcs

Created on 7 July 2023, over 1 year ago
Updated 11 July 2023, over 1 year ago

Problem/Motivation

PHPCS throws errors for the ReportForm.php file:

C:\xampp\htdocs\backendassignment\web\modules\contrib>phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig layout_builder_usage_reports

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\layout_builder_usage_reports\src\Form\ReportForm.php
--------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 21 WARNINGS AFFECTING 27 LINES
--------------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  11 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
  33 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
  34 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
  35 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
  36 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
  37 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
  48 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
  90 | ERROR   | [ ] unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
  93 | WARNING | [ ] Unused variable $components_id.
 108 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
 115 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
 204 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 232 | WARNING | [ ] Unused variable $key.
 233 | WARNING | [x] '@TODO: Validate fields.' should match the format '@todo Fix problem X here.'
 242 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 243 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 244 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 245 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 246 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 253 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 254 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 255 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 256 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 257 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 258 | ERROR   | [x] Expected 1 blank line after function; 0 found
 259 | ERROR   | [x] The closing brace for the class must have an empty line before it
--------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------------

Time: 1.06 secs; Memory: 6MB

Steps to reproduce

Run the phpcs command on the module.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

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

Comments & Activities

Production build 0.71.5 2024