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.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Gab. created an issue. See original summary.

aayushmankotia’s picture

Status: Needs review » Needs work
StatusFileSize
new189.75 KB

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.

alt

Moving to Needs work.
Thanks.

chetan 11 made their first commit to this issue’s fork.

chetan 11’s picture

Status: Needs work » Needs review
chetan 11’s picture

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

aayushmankotia’s picture

Status: Needs review » Needs work
StatusFileSize
new132.49 KB

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.

alt

Moving to Needs work.
Thanks.

imustakim’s picture

Assigned: Unassigned » imustakim
imustakim’s picture

Assigned: imustakim » Unassigned
Status: Needs work » Needs review

MR Updated.
Please review.

clarkssquared’s picture

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) ✗ 
gautam_105@’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new23.34 KB

@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.

rcodina made their first commit to this issue’s fork.

rcodina’s picture

Title: Fix issues reported by phpcs » Fix issues reported by phpcs and enable gitlab pipeline
rcodina’s picture

Thanks!

  • rcodina committed fdb699a5 on 2.x authored by chetan 11
    Issue #3390583 by rcodina, chetan 11, gab., imustakim: Fix issues...
rcodina’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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