Fix the issues reported by phpcs (i18n_contact module)

Created on 19 April 2023, over 2 years ago
Updated 25 April 2023, over 2 years ago

Problem/Motivation

Running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md i18n/i18n_contact/ reports the following issues that should be fixed.

FILE: /Users/vimalnadar/www/Travelopia/domino-leboat/docroot/profiles/leboat/modules/contrib/i18n/i18n_contact/i18n_contact.i18n.inc
------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
------------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
4 | ERROR | [x] Doc comment short description must end with a full stop
45 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
54 | WARNING | [x] A comma should follow the last multiline array item. Found: )
------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------

FILE: /Users/vimalnadar/www/Travelopia/domino-leboat/docroot/profiles/leboat/modules/contrib/i18n/i18n_contact/i18n_contact.module
--------------------------------------------------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AND 3 WARNINGS AFFECTING 12 LINES
--------------------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
4 | ERROR | [x] Doc comment short description must end with a full stop
6 | WARNING | [ ] @author tags are not usually used in Drupal, because over time multiple contributors will touch the code anyway
41 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
42 | ERROR | [x] Array indentation error, expected 6 spaces but found 4
43 | ERROR | [x] Array indentation error, expected 6 spaces but found 4
44 | ERROR | [x] Array indentation error, expected 6 spaces but found 4
45 | ERROR | [x] Array closing indentation error, expected 4 spaces but found 2
66 | WARNING | [ ] Line exceeds 80 characters; contains 110 characters
66 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
76 | ERROR | [ ] The array declaration extends to column 104 (the limit is 80). The array content should be split up over multiple lines
82 | ERROR | [ ] The array declaration extends to column 93 (the limit is 80). The array content should be split up over multiple lines
87 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
--------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------

Time: 70ms; Memory: 10MB

Steps to reproduce

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md i18n/i18n_contact/

Proposed resolution

Fix all the above issues reported by phpcs.

📌 Task
Status

Fixed

Version

1.0

Component

Miscellaneous

Created by

🇮🇳India vimal_nadar

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 @vimal_nadar
  • Issue was unassigned.
  • Status changed to Needs review over 2 years ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 8.2 & MySQL 8
    last update over 2 years ago
    92 pass
  • Status changed to Needs work over 2 years ago
  • 🇵🇭Philippines clarkssquared

    Hi vimal_nadar,

    I applied your patch #2, and I noticed that there is still phpcs errors and warnings being flagged in i18n_contact/i18n_contact.module,

    FILE: /Users/studenttrainees/i18n/i18n_contact/i18n_contact.module
    --------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 5 ERRORS AND 1 WARNING AFFECTING 5 LINES
    --------------------------------------------------------------------------------------------------------------------------------------------
    1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
    6 | ERROR | [x] Additional blank lines found at end of doc comment
    65 | WARNING | [ ] Line exceeds 80 characters; contains 110 characters
    65 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    75 | ERROR | [ ] The array declaration extends to column 104 (the limit is 80). The array content should be split up over multiple lines
    81 | ERROR | [ ] The array declaration extends to column 93 (the limit is 80). The array content should be split up over multiple lines
    --------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------------

    Please look at the screenshot attached for your reference.

  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 5.3 & MySQL 5.5
    last update over 2 years ago
    run-tests.sh fatal error
  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 7.4 & MySQL 5.5
    last update over 2 years ago
    92 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 8.1 & MySQL 8
    last update over 2 years ago
    92 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 8.0 & MySQL 5.7
    last update over 2 years ago
    92 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 8.2 & pgsql-13.5
    last update over 2 years ago
    92 pass
  • 🇨🇦Canada joseph.olstad

    The above patch breaks PHP 5.3

  • Assigned to vimal_nadar
  • Issue was unassigned.
  • Status changed to Needs review over 2 years ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 8.2 & MySQL 8
    last update over 2 years ago
    92 pass
  • Status changed to RTBC over 2 years ago
  • 🇵🇭Philippines clarkssquared

    Hi vimal_nadar,

    I applied your patch #7, and I confirmed that the phpcs issues were fixed and resolved.

    Please look at the screenshot attached for your reference

    Thank you.

  • Status changed to Needs work over 2 years ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, show which command has been used, which arguments have been used, and which report that command shown.

  • Status changed to Needs review over 2 years ago
  • 🇮🇳India vimal_nadar

    Updated issue summary.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs work over 2 years ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -  if (in_array($message['id'], array('contact_page_mail', 'contact_page_copy', 'contact_page_autoreply'))) {
    +  if (in_array($message['id'], array(
    +    'contact_page_mail',
    +    'contact_page_copy',
    +    'contact_page_autoreply',
    +  ))) {

    That is code written as per PSR12 coding standards. Drupal coding standards say:

    Control structure conditions may exceed 80 characters, if they are simple to read and understand.

    In this case, the existing code is simpler to read and understand; the proposed change is not.

    -      // Overwrite the whole message body. Maybe this is not entirely responsible
    -      // (it might overwrite other existing items altered in by others),
    -      // but unfortunately Drupal core cotact module does not make its item
    -      // identifiable easily.
    +      // Overwrite the whole message body. Maybe this is not entirely
    +      // responsible (it might overwrite other existing items altered in by
    +      // others), but unfortunately Drupal core cotact module does not make
    +      // its item identifiable easily.

    Since that comment is edited, there is a typo that should be fixed too: cotact is supposed to be Contact. (Yes, it is a capitalized word because that is the name of a module.)

  • Assigned to vimal_nadar
  • Issue was unassigned.
  • Status changed to Needs review over 2 years ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 8.2 & MySQL 8
    last update over 2 years ago
    92 pass
  • Status changed to Fixed over 2 years ago
  • 🇨🇦Canada joseph.olstad

    Thanks @vimal_nadar, great work along with @apadermo, committed and credited.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024