Fix the issue reported by phpcs

Created on 26 June 2023, over 1 year ago
Updated 22 July 2023, over 1 year ago

Running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig shows the following warnings/errors, which should be fixed.

FILE: ./date_range_picker/css/date_range_picker.css
-------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------
 4 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

FILE: ./date_range_picker/src/Plugin/Field/FieldWidget/DateRangePickerFieldWidget.php
-------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------
 33 | ERROR | The array declaration extends to column 100 (the limit is 80). The array content should be split up over multiple
    |       | lines
-------------------------------------------------------------------------

FILE: ./date_range_picker/date_range_picker.libraries.yml
-------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------
 10 | ERROR | [x] Expected 1 newline at end of file; 0 found
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

Time: 44ms; Memory: 10MB
📌 Task
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

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 @sonam_sharma
  • Status changed to Needs work over 1 year ago
  • 🇵🇭Philippines paraderojether

    Hi I reviewed patch #2, and there are still remaining issues reported by phpcs shown below:

    FILE: /Users/studenttrainees/Drupal.org/drupalorg-site/docroot/modules/contrib/date_range_picker/css/date_range_picker.css
    --------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------
     4 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    --------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: ...drupalorg-site/docroot/modules/contrib/date_range_picker/src/Plugin/Field/FieldWidget/DateRangePickerFieldWidget.php
    --------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------
     33 | ERROR | The array declaration extends to column 100 (the limit is 80). The array content should be split up over
        |       | multiple lines
    --------------------------------------------------------------------------------------------------------------------------
    
    Time: 299ms; Memory: 10MB

    Please check.
    Thank You.

  • Status changed to Needs review over 1 year ago
  • I have fixed remaining issues,
    please retest the patch @paraderojether

  • Issue was unassigned.
  • Status changed to Needs work over 1 year 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 and arguments have been used and which report that command shown. In this way, project maintainers can verify the patch/MR fixes all the warnings/errors.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Ashutosh Ahirwal India

    I have updated all the issue summary with all the warnings/errors generated by phpcs.

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    In JavaScript true, false, and null are used. PHP_CodeSniffer is applying PHP rules to JavaScript files. It is sufficient to run phpcs --standard=Drupal,DrupalPractice -s --extensions=js to notice that.

    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 12 ERRORS AFFECTING 11 LINES
    -----------------------------------------------------------------------------------------------------------------------------------
     10 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
        |       |     (Generic.PHP.UpperCaseConstant.Found)
     11 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
        |       |     (Generic.PHP.UpperCaseConstant.Found)
     28 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
        |       |     (Generic.PHP.UpperCaseConstant.Found)
     28 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
        |       |     (Generic.PHP.UpperCaseConstant.Found)
     37 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
        |       |     (Generic.PHP.UpperCaseConstant.Found)
     45 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
        |       |     (Generic.PHP.UpperCaseConstant.Found)
     46 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
        |       |     (Generic.PHP.UpperCaseConstant.Found)
     47 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
        |       |     (Generic.PHP.UpperCaseConstant.Found)
     48 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
        |       |     (Generic.PHP.UpperCaseConstant.Found)
     55 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
        |       |     (Generic.PHP.UpperCaseConstant.Found)
     68 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
        |       |     (Generic.PHP.UpperCaseConstant.Found)
     99 | ERROR | [x] Expected 1 newline at end of file; 0 found (Drupal.Files.EndFileNewline.NoneFound)
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 12 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    

    Generic.PHP.UpperCaseConstant.Found is a rule for PHP, not for JavaScript.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India mrinalini9 New Delhi

    Updated patch #4 by addressing #7, please review it.

    Thanks & Regards,
    Mrinalini

  • Status changed to RTBC over 1 year ago
  • 🇵🇭Philippines paraderojether

    I reviewed patch #10, applied it against Date range picker 8.x-1.x-dev, and confirmed it fixes all the issues reported by phpcs.

    I added screenshots for reference.
    Thank You.

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -    var startDate = null;
    -    var endDate = null;
    +    var startDate = NULL;
    +    var endDate = NULL;
    -      allowRepick: false,
    +      allowRepick: FALSE,

    See my previous comment and the report in the issue summary. NULL, TRUE, and FALSE are not used in JavaScript, where those predefined values are written in lower-case characters.

    -    $uniqueString = implode('-', array_merge($element['#field_parents'], [$items->getName(), $delta]));
    +    $uniqueString = implode('-', array_merge($element['#field_parents'],
    +    [$items->getName(), $delta]));
    

    Code lines are allowed to exceed 80 characters, if they are easier to understand. With the changed code is harder to understand that [$items->getName(), $delta] is an argument for array_merge().

  • Assigned to sourabhjain
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India sourabhjain

    Updated the changes suggested in #12. Please review.

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -    if (startDate === null && endDate === null) {
    +    if (startDate === NULL && endDate === NULL) {

    JavaScript code needs to use true, false, and null, written exactly like that.
    Please see the issue summary: It is not about changing JavaScript files, since PHP_CodeSniffer suggests the wrong changes for those files.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India mrinalini9 New Delhi

    Updated patch #14 by addressing #15, please review it.

    Thanks!

  • Status changed to RTBC over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The last patch correctly changes the files, without touching any JavaScript file.

  • Status changed to Closed: won't fix over 1 year ago
  • 🇩🇪Germany k4v

    Hey, I'm doing this in my free time, if you like to fix such minor nitpicks I can add you as a co maintainer.

Production build 0.71.5 2024