Fix the errors/warnings reported by Php_CodeSniffer

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

Problem/Motivation

Upon running phpcs on the module, it throws the following errors and warnings:

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 stripe_webform_payment
FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\stripe_webform_payment\src\Plugin\WebformElement\StripeWebformPayment.php
-------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
-------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 262 | ERROR   | [x] Missing function doc comment
 472 | ERROR   | [x] Data types in @param tags need to be fully namespaced
 481 | WARNING | [ ] Unused variable $key.
 551 | WARNING | [ ] Unused variable $input.
-------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\stripe_webform_payment\src\StripteWebformPaymentStripe.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 7 WARNINGS AFFECTING 8 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  76 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 111 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 136 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 188 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 221 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 270 | WARNING | [ ] Unused private method getApiWebhookSecret()
 314 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\stripe_webform_payment\src\StripteWebformPaymentWebform.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 11 ERRORS AND 2 WARNINGS AFFECTING 13 LINES
-----------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 163 | WARNING | [ ] #options values usually have to run through t() for translation
 164 | WARNING | [ ] #options values usually have to run through t() for translation
 274 | ERROR   | [x] Array indentation error, expected 6 spaces but found 0
 275 | ERROR   | [x] Array indentation error, expected 6 spaces but found 0
 276 | ERROR   | [x] Array indentation error, expected 6 spaces but found 0
 277 | ERROR   | [x] Array indentation error, expected 6 spaces but found 0
 278 | ERROR   | [x] Array indentation error, expected 6 spaces but found 0
 279 | ERROR   | [x] Array indentation error, expected 6 spaces but found 0
 280 | ERROR   | [x] Array indentation error, expected 6 spaces but found 0
 281 | ERROR   | [x] Array indentation error, expected 6 spaces but found 0
 282 | ERROR   | [x] Array indentation error, expected 6 spaces but found 0
 283 | ERROR   | [x] Array indentation error, expected 6 spaces but found 0
-----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 11 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\stripe_webform_payment\stripe_webform_payment.info.yml
------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------
 1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
 1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
 1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\stripe_webform_payment\stripe_webform_payment.module
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 42 ERRORS AND 3 WARNINGS AFFECTING 40 LINES
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
   6 | ERROR   | [x] There must be exactly one blank line after the file comment
  19 | WARNING | [ ] Line exceeds 80 characters; contains 86 characters
  48 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  48 | ERROR   | [x] Closing brace indented incorrectly; expected 2 spaces, found 4
  58 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  59 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 6
  60 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 6
  62 | WARNING | [ ] Line exceeds 80 characters; contains 83 characters
  62 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 6
  63 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 6
  64 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 6
  65 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 8
  67 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 8
  68 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 10
  69 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 10
  70 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 12
  71 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 10
  72 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 10
  73 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 12
  74 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 12
  75 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 12
  76 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 12
  77 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 12
  78 | ERROR   | [x] Line indented incorrectly; expected 12 spaces, found 14
  79 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 12
  80 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 10
  82 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 10
  83 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 12
  84 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 10
  86 | WARNING | [ ] Line exceeds 80 characters; contains 83 characters
  86 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 10
  87 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 10
  88 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 12
  89 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 10
  90 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 8
  91 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 6
  92 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  95 | ERROR   | [x] Expected 1 blank line after function; 2 found
 108 | ERROR   | [x] There must be no blank lines after the function comment
 110 | ERROR   | [ ] Invalid function name, expected get_replacements but found getReplacements
 110 | ERROR   | [ ] All functions defined in a module file must be prefixed with the module's name, found "getReplacements" but expected "stripe_webform_payment_getReplacements"
 127 | ERROR   | [ ] Missing short description in doc comment
 134 | ERROR   | [ ] Invalid function name, expected get_payment_intent but found getPaymentIntent
 134 | ERROR   | [ ] All functions defined in a module file must be prefixed with the module's name, found "getPaymentIntent" but expected "stripe_webform_payment_getPaymentIntent"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 37 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Steps to reproduce

Run the phpcs command on the module.

Proposed resolution

I will provide an MR which solves the issues.

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

  • Issue created by @sidharth_soman
  • @sidharth_soman opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India sidharth_soman Bangalore

    I have fixed most of the errors. The ones remaining are:
    - Line exceeds 80 characters: Leaving this as it is due to readability purposes.
    - Unused variables: Leaving this since they may become useful in the future.
    - Function names (snake_case vs camelCase): Leaving this as it is up to the maintainers to decide on the naming conventions.

    Please review the MR

  • First commit to issue fork.
  • 🇸🇾Syria hodba Dubai

    Thanks sidharth_soman. I added your fix to the latest 1.0.x-dev

  • Status changed to Fixed over 1 year ago
Production build 0.71.5 2024