Problem/Motivation

Getting following errors and warning

$ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig pagerer/ 

FILE: pagerer/pagerer_example/pagerer_example.routing.yml
-----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
 9 | WARNING | Open page callback found, please add a comment before the line why there is no access restriction
-----------------------------------------------------------------------------------------------------------------


FILE: pagerer/pagerer_example/src/Controller/PagererExampleController.php
-----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------
 20 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 38 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 54 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 71 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 83 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
-----------------------------------------------------------------------------------------------


FILE: pagerer/tests/modules/pagerer_test/pagerer_test.module
----------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------
 18 | WARNING | Unused variable $index.
----------------------------------------------------------------------------------


FILE: pagerer/tests/src/Functional/PagererTest.php
------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------
 570 | WARNING | Unused variable $match_querystring.
------------------------------------------------------------------------


FILE: pagerer/tests/src/FunctionalJavascript/CorePagerReplacePaginationAJAXTest.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
 36 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: pagerer/README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 32 WARNINGS AFFECTING 32 LINES
----------------------------------------------------------------------
  38 | WARNING | Line exceeds 80 characters; contains 81 characters
  51 | WARNING | Line exceeds 80 characters; contains 93 characters
  57 | WARNING | Line exceeds 80 characters; contains 83 characters
  58 | WARNING | Line exceeds 80 characters; contains 85 characters
 256 | WARNING | Line exceeds 80 characters; contains 82 characters
 265 | WARNING | Line exceeds 80 characters; contains 81 characters
 281 | WARNING | Line exceeds 80 characters; contains 84 characters
 286 | WARNING | Line exceeds 80 characters; contains 81 characters
 313 | WARNING | Line exceeds 80 characters; contains 82 characters
 320 | WARNING | Line exceeds 80 characters; contains 82 characters
 328 | WARNING | Line exceeds 80 characters; contains 85 characters
 331 | WARNING | Line exceeds 80 characters; contains 83 characters
 340 | WARNING | Line exceeds 80 characters; contains 82 characters
 344 | WARNING | Line exceeds 80 characters; contains 83 characters
 351 | WARNING | Line exceeds 80 characters; contains 83 characters
 354 | WARNING | Line exceeds 80 characters; contains 83 characters
 361 | WARNING | Line exceeds 80 characters; contains 81 characters
 363 | WARNING | Line exceeds 80 characters; contains 81 characters
 365 | WARNING | Line exceeds 80 characters; contains 87 characters
 368 | WARNING | Line exceeds 80 characters; contains 97 characters
 374 | WARNING | Line exceeds 80 characters; contains 87 characters
 379 | WARNING | Line exceeds 80 characters; contains 87 characters
 382 | WARNING | Line exceeds 80 characters; contains 81 characters
 384 | WARNING | Line exceeds 80 characters; contains 81 characters
 391 | WARNING | Line exceeds 80 characters; contains 81 characters
 394 | WARNING | Line exceeds 80 characters; contains 81 characters
 403 | WARNING | Line exceeds 80 characters; contains 82 characters
 405 | WARNING | Line exceeds 80 characters; contains 84 characters
 432 | WARNING | Line exceeds 80 characters; contains 84 characters
 435 | WARNING | Line exceeds 80 characters; contains 81 characters
 444 | WARNING | Line exceeds 80 characters; contains 83 characters
 463 | WARNING | Line exceeds 80 characters; contains 81 characters
----------------------------------------------------------------------


FILE: pagerer/interdiff_21-22.txt
----------------------------------------------------------------------
FOUND 0 ERRORS AND 12 WARNINGS AFFECTING 12 LINES
----------------------------------------------------------------------
  25 | WARNING | Line exceeds 80 characters; contains 99 characters
  33 | WARNING | Line exceeds 80 characters; contains 81 characters
  58 | WARNING | Line exceeds 80 characters; contains 132 characters
  66 | WARNING | Line exceeds 80 characters; contains 92 characters
  69 | WARNING | Line exceeds 80 characters; contains 172 characters
  84 | WARNING | Line exceeds 80 characters; contains 81 characters
  88 | WARNING | Line exceeds 80 characters; contains 97 characters
 112 | WARNING | Line exceeds 80 characters; contains 116 characters
 120 | WARNING | Line exceeds 80 characters; contains 131 characters
 145 | WARNING | Line exceeds 80 characters; contains 81 characters
 164 | WARNING | Line exceeds 80 characters; contains 85 characters
 175 | WARNING | Line exceeds 80 characters; contains 151 characters
----------------------------------------------------------------------


FILE: pagerer/pagerer.module
---------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------
   1 | ERROR | [x] Missing file doc comment
 103 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 173 | ERROR | [x] Use null coalesce operator instead of ternary operator.
---------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------


FILE: pagerer/interdiff_19-21.txt
----------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------
  43 | WARNING | Line exceeds 80 characters; contains 81 characters
  56 | WARNING | Line exceeds 80 characters; contains 81 characters
 198 | WARNING | Line exceeds 80 characters; contains 81 characters
 225 | WARNING | Line exceeds 80 characters; contains 81 characters
 234 | WARNING | Line exceeds 80 characters; contains 151 characters
----------------------------------------------------------------------


FILE: pagerer/src/Entity/PagererPreset.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 84 | ERROR | [x] list(...) is forbidden, use [...] instead.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: pagerer/src/PagererManager.php
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Pager\PagerManager.
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------


FILE: pagerer/src/Form/PagererConfigForm.php
----------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Pager\PagerManagerInterface.
----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------


FILE: pagerer/src/Form/PagererPresetEditForm.php
----------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------------------------
 191 | ERROR | The array declaration extends to column 129 (the limit is 120). The array content should be split up over multiple lines
 196 | ERROR | The array declaration extends to column 130 (the limit is 120). The array content should be split up over multiple lines
----------------------------------------------------------------------------------------------------------------------------------------


FILE: pagerer/src/Plugin/pagerer/PagererStyleBase.php
------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------


FILE: pagerer/src/Plugin/pagerer/Adaptive.php
----------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------
 125 | ERROR | The array declaration extends to column 132 (the limit is 120). The array content should be split up over multiple lines
----------------------------------------------------------------------------------------------------------------------------------------


FILE: pagerer/src/Plugin/pagerer/Multipane.php
------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------------------------------
  9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\pagerer\Entity\PagererPreset.
 73 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 74 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 75 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 89 | ERROR | [x] Use null coalesce operator instead of ternary operator.
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------


FILE: pagerer/src/Plugin/PagererStyleManager.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 18 | ERROR | [x] Missing function doc comment
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: pagerer/src/PagererPresetListBuilder.php
-----------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityHandlerInterface.
-----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------

Steps to reproduce

Run following command:

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

Proposed resolution

Run following command:

phpcbf --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml pagerer

and do more changes as per requirement.

Issue fork pagerer-3331519

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

shivam-kumar created an issue. See original summary.

shivam-kumar’s picture

Assigned: shivam-kumar » Unassigned
Status: Active » Needs review
StatusFileSize
new8.76 KB

Fixed the above errors,some phpcs errors needs to be fixed.

shivam-kumar’s picture

StatusFileSize
new8.11 KB

Updated patch to resolve above upcoming Issue.

atul_ghate’s picture

Assigned: Unassigned » atul_ghate

I will review this patch.

atul_ghate’s picture

Assigned: atul_ghate » Unassigned
Status: Needs review » Needs work
StatusFileSize
new103.12 KB

The patch has been reviewed and applied cleanly, but a few phpcs still remain

Neeraj333’s picture

Assigned: Unassigned » Neeraj333
Neeraj333’s picture

Assigned: Neeraj333 » Unassigned
hardikpandya’s picture

Assigned: Unassigned » hardikpandya
hardikpandya’s picture

Assigned: hardikpandya » Unassigned
Status: Needs work » Needs review
StatusFileSize
new32.28 KB
new25.25 KB

Fixed all phpcs issues.

Status: Needs review » Needs work

The last submitted patch, 9: 3331519-9.patch, failed testing. View results

akram khan’s picture

Status: Needs work » Needs review
Issue tags: -
StatusFileSize
new27.47 KB
new19.63 KB

Fixed remaining PHPCS error

Status: Needs review » Needs work

The last submitted patch, 11: 3331519-11.patch, failed testing. View results

avpaderno’s picture

Title: Drupal Coding Standards Issues | phpcs » Fix the issues reported by phpcs
Version: 3.0.0 » 3.0.x-dev
Category: Bug report » Task
Priority: Minor » Normal

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

vishaljd’s picture

Assigned: Unassigned » vishaljd
avpaderno’s picture

Assigned: vishaljd » Unassigned
urvashi_vora’s picture

Status: Needs work » Needs review
StatusFileSize
new22.66 KB
new25.68 KB

Please review this patch.

Thanks

Status: Needs review » Needs work

The last submitted patch, 17: 3331519-17.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

adwivedi008’s picture

Status: Needs work » Needs review
Issue tags: +Coding standards, +Dependency Injection (DI)
StatusFileSize
new32.76 KB
new9.69 KB

Revised patch #18 and fixed remaining issues

FILE: pagerer/pagerer_example/src/Controller/PagererExampleController.php
------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------------
 20 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 38 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 54 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 71 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 83 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------------


FILE: pagerer/pagerer.module
---------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
---------------------------------------------------------------------------
 108 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 178 | ERROR | [x] Use null coalesce operator instead of ternary operator.
---------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------


FILE: pagerer/src/Form/PagererConfigForm.php
----------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Pager\PagerManagerInterface.
----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------


FILE: pagerer/src/Entity/PagererPreset.php
-----------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------
 84 | ERROR | [x] list(...) is forbidden, use [...] instead.
-----------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------


FILE: pagerer/src/PagererPresetListBuilder.php
-----------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityHandlerInterface.
-----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------


FILE: pagerer/src/Plugin/pagerer/PagererStyleBase.php
------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------


FILE: pagerer/src/Plugin/pagerer/Multipane.php
------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------------------------------
  9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\pagerer\Entity\PagererPreset.
 73 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 74 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 75 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 89 | ERROR | [x] Use null coalesce operator instead of ternary operator.
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------


FILE: pagerer/src/PagererManager.php
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Pager\PagerManager.
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

Time: 473ms; Memory: 18MB

Status: Needs review » Needs work

The last submitted patch, 19: 3331519-19.patch, failed testing. View results

nikolay shapovalov’s picture

Status: Needs work » Needs review
StatusFileSize
new33.83 KB
new12.76 KB

Thanks @adwivedi008 for you contribution,
Please double check that you remove trailing whitespaces.
I added StringTranslationTrait in test file and removed trailing whitespaces.

nikolay shapovalov’s picture

StatusFileSize
new32.53 KB
new7.28 KB

Made review of patch from #21.
Here is updated patch.

nikolay shapovalov’s picture

Create MR 19 to use gitlab ci.
Hide all patch files.

nikolay shapovalov’s picture

Issue summary: View changes

Update Issue summary, update phpcs violations.

nikolay shapovalov’s picture

I create separate MR to test fixes for eslint, phpstan, stylelint.
https://git.drupalcode.org/issue/pagerer-3331519/-/merge_requests/2

Updated: MR is closed, future work happens in #3402666

mondrake’s picture

Status: Needs review » Needs work

Thanks for working on this. I agree, let's only do PHPCS fixes in this issue.

I just added more configuration for GitlabCI testing - phpstan.neon and phpcs.xml.dist. PHPCS is now configured to skip README.md, so I would not touch that here.

Also, I dropped all DrupalCI configration and testing.

nikolay shapovalov’s picture

Status: Needs work » Needs review

Thanks for the feedback and changes you made.
I created separate issue #3402666 to work on PHPStan, eslint, stylelint.

@mondrake do you want to remove changes in README.md file.
We already made some changes in this file and I think we can keep it even the file will be excluded from code style check in the future.
What do you think?

I don't see other things that needs to be done for this issue, there is no phpcs violations left. Please let me know if I miss something?

mondrake’s picture

Status: Needs review » Needs work

Thanks! I made some comments inline the MR, that need work. For README.md, OK to keep, but please let's make sure that if we make changes because of the 80 chars limit per line, each changed line gets as close as possible to 80 chars.

nikolay shapovalov’s picture

Assigned: Unassigned » nikolay shapovalov

Thanks for feedback.

nikolay shapovalov’s picture

Assigned: nikolay shapovalov » Unassigned
Status: Needs work » Needs review

I changed my mind about README.md, I think we can keep it without changes.
I updated MR, and removed changes for README.md file, and left only fix for it.

mondrake’s picture

Status: Needs review » Needs work

Very close! Thanks for your work.

nikolay shapovalov’s picture

Status: Needs work » Needs review

Thanks for a review. I made suggested changes. MR is ready for review.

mondrake’s picture

This is first time I see this readonly property, I will not argue, fixed.

Drupal core is slowly introducing this. See for example #1014086-368: Stampedes and cold cache performance issues with css/js aggregation.

mondrake’s picture

Credit.

  • mondrake committed 768f39cd on 3.0.x authored by zniki.ru
    Issue #3331519 by zniki.ru, shivam-kumar, hardikpandya, Akram Khan,...
mondrake’s picture

Merged. Thank you!!

mondrake’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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