Fix the warnings/errors reported by PHP_CodeSniffer

Created on 22 June 2023, over 1 year ago
Updated 10 July 2024, 4 months ago

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

FILE: ./zurb_views/views_zurb.theme.inc
-------------------------------------------------------------------------
FOUND 3 ERRORS AND 3 WARNINGS AFFECTING 5 LINES
-------------------------------------------------------------------------
  9 | WARNING | [x] Unused use statement
  9 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Template\Attribute.
 35 | WARNING | [x] '@TODO: This would be better as valdiation errors on the style plugin options form.' should match the format
    |         |     '@todo Fix problem X here.'
 43 | WARNING | [x] '@TODO: Make sure that $vars['rows'] is rendered array.' should match the format '@todo Fix problem X here.'
 48 | ERROR   | [x] Missing function doc comment
 63 | ERROR   | [x] Expected 1 newline at end of file; 2 found
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

FILE: ./zurb_views/views_zurb.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: ./zurb_views/src/ViewsZurb.php
-------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------
 35 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
 38 | ERROR | [x] Expected 1 blank line after function; 2 found
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

FILE: ./zurb_views/src/Plugin/views/style/ViewsZurbAccordion.php
-------------------------------------------------------------------------
FOUND 5 ERRORS AND 10 WARNINGS AFFECTING 15 LINES
-------------------------------------------------------------------------
  7 | WARNING | [x] Unused use statement
 65 | ERROR   | [x] Short array syntax must be used to define arrays
 66 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         |     $this->t() instead
 67 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         |     $this->t() instead
 69 | ERROR   | [x] Short array syntax must be used to define arrays
 71 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         |     $this->t() instead
 73 | ERROR   | [x] Short array syntax must be used to define arrays
 75 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         |     $this->t() instead
 78 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         |     $this->t() instead
 80 | ERROR   | [x] Short array syntax must be used to define arrays
 82 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         |     $this->t() instead
 85 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         |     $this->t() instead
 87 | ERROR   | [x] Short array syntax must be used to define arrays
 89 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         |     $this->t() instead
 92 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
    |         |     $this->t() instead
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

FILE: ./zurb_views/src/Plugin/views/style/ViewsZurbBlockGrid.php
-------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------
 74 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 91 | ERROR | [x] Use null coalesce operator instead of ternary operator.
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

FILE: ./zurb_views/templates/views-zurb-block-grid.html.twig
-------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------
 26 | ERROR | [x] Expected 1 newline at end of file; 0 found
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

FILE: ./zurb_views/README.md
-------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------
 44 | WARNING | Line exceeds 80 characters; contains 86 characters
-------------------------------------------------------------------------

FILE: ./zurb_views/views_zurb.module
-------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------
  1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
 13 | ERROR | [ ] All functions defined in a module file must be prefixed with the module's name, found "views_bootstrap_help" but
    |       |     expected "views_zurb_views_bootstrap_help"
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

Time: 101ms; Memory: 10MB
๐Ÿ“Œ Task
Status

RTBC

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.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @sonam_sharma
  • First commit to issue fork.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia gowthamrajkrishnasamy

    Fixed phpcs warnings. Please review

  • Assigned to sonam_sharma
  • I have fixed missing function doc also which is error not a warning
    kindly please review the patch!

  • 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 issue summary.

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +/**
    + * Implements template_preprocess_hook().
    + */
     function template_preprocess_views_zurb_block_grid(array &$vars) {

    The correct documentation comment is similar to the one used for template_preprocess_node(), for example.

    /**
     * Prepares variables for node templates.
     *
     * Default template: node.html.twig.
     *
     * Most themes use their own copy of node.html.twig. The default is located
     * inside "/core/modules/node/templates/node.html.twig". Look in there for the
     * full list of variables.
     *
     * By default this function performs special preprocessing of some base fields
     * so they are available as variables in the template. For example 'title'
     * appears as 'label'. This preprocessing is skipped if:
     * - a module makes the field's display configurable via the field UI by means
     *   of BaseFieldDefinition::setDisplayConfigurable()
     * - AND the additional entity type property
     *   'enable_base_field_custom_preprocess_skipping' has been set using
     *   hook_entity_type_build().
     *
     * @param array $variables
     *   An associative array containing:
     *   - elements: An array of elements to display in view mode.
     *   - node: The node object.
     *   - view_mode: View mode; e.g., 'full', 'teaser', etc.
     *
     * @see hook_entity_type_build()
     * @see \Drupal\Core\Field\BaseFieldDefinition::setDisplayConfigurable()
     */
    

    If then I run the command reported in the issue summary, I get more warnings/errors.

    FILE: ./zurb_views/views_zurb.theme.inc
    -------------------------------------------------------------------------
    FOUND 3 ERRORS AND 3 WARNINGS AFFECTING 5 LINES
    -------------------------------------------------------------------------
      9 | WARNING | [x] Unused use statement
      9 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Template\Attribute.
     35 | WARNING | [x] '@TODO: This would be better as valdiation errors on the style plugin options form.' should match the format
        |         |     '@todo Fix problem X here.'
     43 | WARNING | [x] '@TODO: Make sure that $vars['rows'] is rendered array.' should match the format '@todo Fix problem X here.'
     48 | ERROR   | [x] Missing function doc comment
     63 | ERROR   | [x] Expected 1 newline at end of file; 2 found
    -------------------------------------------------------------------------
    PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------
    
    FILE: ./zurb_views/views_zurb.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: ./zurb_views/src/ViewsZurb.php
    -------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -------------------------------------------------------------------------
     35 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
     38 | ERROR | [x] Expected 1 blank line after function; 2 found
    -------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------
    
    FILE: ./zurb_views/src/Plugin/views/style/ViewsZurbAccordion.php
    -------------------------------------------------------------------------
    FOUND 5 ERRORS AND 10 WARNINGS AFFECTING 15 LINES
    -------------------------------------------------------------------------
      7 | WARNING | [x] Unused use statement
     65 | ERROR   | [x] Short array syntax must be used to define arrays
     66 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
        |         |     $this->t() instead
     67 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
        |         |     $this->t() instead
     69 | ERROR   | [x] Short array syntax must be used to define arrays
     71 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
        |         |     $this->t() instead
     73 | ERROR   | [x] Short array syntax must be used to define arrays
     75 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
        |         |     $this->t() instead
     78 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
        |         |     $this->t() instead
     80 | ERROR   | [x] Short array syntax must be used to define arrays
     82 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
        |         |     $this->t() instead
     85 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
        |         |     $this->t() instead
     87 | ERROR   | [x] Short array syntax must be used to define arrays
     89 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
        |         |     $this->t() instead
     92 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
        |         |     $this->t() instead
    -------------------------------------------------------------------------
    PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------
    
    FILE: ./zurb_views/src/Plugin/views/style/ViewsZurbBlockGrid.php
    -------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -------------------------------------------------------------------------
     74 | ERROR | [x] Use null coalesce operator instead of ternary operator.
     91 | ERROR | [x] Use null coalesce operator instead of ternary operator.
    -------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------
    
    FILE: ./zurb_views/templates/views-zurb-block-grid.html.twig
    -------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------
     26 | ERROR | [x] Expected 1 newline at end of file; 0 found
    -------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------
    
    FILE: ./zurb_views/README.md
    -------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------
     44 | WARNING | Line exceeds 80 characters; contains 86 characters
    -------------------------------------------------------------------------
    
    FILE: ./zurb_views/views_zurb.module
    -------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -------------------------------------------------------------------------
      1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
     13 | ERROR | [ ] All functions defined in a module file must be prefixed with the module's name, found "views_bootstrap_help" but
        |       |     expected "views_zurb_views_bootstrap_help"
    -------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------
    
    Time: 101ms; Memory: 10MB
    
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia chaitanyadessai Goa

    Added patch please review.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia mrinalini9 New Delhi

    Hi,

    I have reviewed patch #12, it applied cleanly.

    But has some trailing whitespace issues in the patch that need to be fixed:

    drupal.org_files_issues_2023-10-10_3368542-12.patch:12: trailing whitespace.
     
    drupal.org_files_issues_2023-10-10_3368542-12.patch:16: trailing whitespace.
     
    drupal.org_files_issues_2023-10-10_3368542-12.patch:72: trailing whitespace.
     
    drupal.org_files_issues_2023-10-10_3368542-12.patch:103: trailing whitespace.
     
    drupal.org_files_issues_2023-10-10_3368542-12.patch:107: trailing whitespace.
     
    warning: squelched 5 whitespace errors
    warning: 10 lines add whitespace errors.
    
    

    Also, there are still few phpcs errors left that need to be fixed:

    FILE: /zurb_views/js/views-zurb.js
    ------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AFFECTING 4 LINES
    ------------------------------------------------------------------------------------------------
     10 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
     17 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 3 empty lines
     19 | ERROR | [ ] More than 2 empty lines are not allowed
     20 | ERROR | [x] Expected 1 newline at end of file; 0 found
    ------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------
    

    Please fix all of these things.

    Thanks & Regards,
    Mrinalini

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    Please review. Addressed the comment in #14.

  • Status changed to Needs review 10 months ago
  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    Let's use the issue fork which has been already created.

  • Assigned to pray_12
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia pray_12
  • Issue was unassigned.
  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia pray_12

    Addressed the #16 comment. Please review

  • Venkatraman Ganesan โ†’ made their first commit to this issueโ€™s fork.

  • Status changed to RTBC 4 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines cleavinjosh

    Hi @Preethy_ray,

    I applied MR!1, it was applied smoothly and fixed the phpcs issues.

    โžœ  zurb_views git:(1.0.x) curl https://git.drupalcode.org/project/zurb_views/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  8689    0  8689    0     0  19763      0 --:--:-- --:--:-- --:--:-- 19792
    patching file README.md
    patching file src/Plugin/views/style/ViewsZurbAccordion.php
    patching file src/Plugin/views/style/ViewsZurbBlockGrid.php
    patching file src/ViewsZurb.php
    patching file templates/views-zurb-block-grid.html.twig
    patching file views_zurb.info.yml
    patching file views_zurb.module
    patching file views_zurb.theme.inc
    โžœ  zurb_views git:(1.0.x) โœ— ..
    โžœ  contrib git:(main) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml zurb_views
    โžœ  contrib git:(main) โœ—

    Thank you.

  • Pipeline finished with Success
    4 months ago
    Total: 125s
    #220974
  • Pipeline finished with Success
    4 months ago
    Total: 124s
    #220976
Production build 0.71.5 2024