Fix issues reported by phpcs and enable gitlab pipeline

Created on 29 September 2023, about 1 year ago
Updated 3 September 2024, 3 months ago

Problem/Motivation

I ran this following phpcs command and errors were reported below.

phpcs \
--standard=Drupal,DrupalPractice -n \
--extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig \
--ignore="*.features.*,*.pages*.inc,*/node_modules/*" \
custom_view_filters/

FILE: /custom_view_filters/src/Plugin/views/filter/DateRangePickerFilter.php
-------------------------------------------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AFFECTING 10 LINES
-------------------------------------------------------------------------------------------------------------------------------------
   7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
     |       |     Drupal\views\Plugin\views\display\DisplayPluginBase.
  52 | ERROR | [x] Use null coalesce operator instead of ternary operator.
  58 | ERROR | [x] Use null coalesce operator instead of ternary operator.
  90 | ERROR | [x] Expected 1 blank line after function; 2 found
 111 | ERROR | [x] Expected 1 blank line after function; 2 found
 117 | ERROR | [ ] Missing parameter type
 119 | ERROR | [ ] Missing parameter type
 215 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 221 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 247 | ERROR | [x] Use null coalesce operator instead of ternary operator.
-------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------


FILE: /custom_view_filters/src/Plugin/views/filter/CustomAzFilter.php
-------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-------------------------------------------------------------------------------------------------------------------------------------
   7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
     |       |     Drupal\views\Plugin\views\display\DisplayPluginBase.
 211 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 238 | ERROR | [x] Use null coalesce operator instead of ternary operator.
-------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------


FILE: /custom_view_filters/src/Plugin/views/filter/NodeGranularDateFilter.php
-------------------------------------------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AFFECTING 10 LINES
-------------------------------------------------------------------------------------------------------------------------------------
   7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
     |       |     Drupal\views\Plugin\views\display\DisplayPluginBase.
 167 | ERROR | [x] Parameter comment must end with a full stop
 179 | ERROR | [ ] Missing parameter type
 181 | ERROR | [ ] Missing parameter type
 200 | ERROR | [x] Expected 1 space after "="; 2 found
 290 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 297 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 325 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 329 | ERROR | [x] Short array syntax must be used to define arrays
 337 | ERROR | [x] Short array syntax must be used to define arrays
-------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------

Time: 166ms; Memory: 12MB

I've uploaded a patch to fix these phpcs errors reported.

๐Ÿ“Œ Task
Status

Fixed

Version

2.0

Component

Code

Created by

๐Ÿ‡ต๐Ÿ‡ญPhilippines Zed9

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

Merge Requests

Comments & Activities

  • Issue created by @Zed9
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia aayushDrupal

    Hi,
    The patch 0001-Fix-the-errors-found-by-phpcs.patch has been successfully applied, but it does not completely resolve all the errors. Please check the attached screenshot.

    Moving to Needs work.
    Thanks.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia chetan 11

    chetan 11 โ†’ made their first commit to this issueโ€™s fork.

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia chetan 11

    Hi @Gab.
    I fixed the phpcs issues, please review & let me know if any updates required.

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

    Hi chetan 11,
    Merge request !6 has been successfully applied, but there are still remaining phpcs errors. A screenshot is attached for your reference. Please check.

    Moving to Needs work.
    Thnaks.

  • Assigned to imustakim
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia imustakim Ahmedabad
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia imustakim Ahmedabad

    MR Updated.
    Please review.

  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines clarkssquared

    Hi imustakim,

    I applied the updated MR !6 and I confirmed that it fixes all the PHPCS issues, the remaining issues being flagged are the project, version, and datestamp which I believe occurs when the module is installed via composer and I don't think this is a PHPCS issue, I will retain the status to needs review for others to review and give feedbacks to your patch. RTBC +1 from me.

    โžœ  custom_view_filters git:(main) โœ— curl https://git.drupalcode.org/project/custom_view_filters/-/merge_requests/6.diff | patch -p1  
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 13956    0 13956    0     0  15791      0 --:--:-- --:--:-- --:--:-- 15895
    patching file CHANGELOG.txt
    patching file 'src/Plugin/views/filter/CustomAzFilter.php'
    patching file 'src/Plugin/views/filter/DateRangePickerFilter.php'
    patching file 'src/Plugin/views/filter/NodeGranularDateFilter.php'
    โžœ  custom_view_filters git:(main) โœ— ..
    โžœ  contrib git:(main) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml custom_view_filters 
    
    FILE: ...pal10/web/modules/contrib/custom_view_filters/custom_view_filters.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
    --------------------------------------------------------------------------------
    
    Time: 335ms; Memory: 12MB
    
    โžœ  contrib git:(main) โœ— 
    
  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Gautam_105@

    @imustakim,
    I have applied the updated MR !6 and I confirmed that it fixes all the PHPCS issues.Moving to +RTBC. see the screenshot as well.

  • First commit to issue fork.
  • ๐Ÿ‡ช๐Ÿ‡ธSpain rcodina Barcelona
  • ๐Ÿ‡ช๐Ÿ‡ธSpain rcodina Barcelona

    Thanks!

  • Status changed to Fixed 3 months ago
  • ๐Ÿ‡ช๐Ÿ‡ธSpain rcodina Barcelona
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024