Issue reported by Drupal coding standards

Created on 26 November 2023, almost 2 years ago

Problem/Motivation

Resolved issues reported by Drupal coding standards.

Steps to reproduce

1. Run PHP coding standard to regenerate the report
the report is generated using following command

vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml private_taxonomy

FILE: private_taxonomy/private_taxonomy.tokens.inc
-------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------
 37 | WARNING | Unused variable $token_service.
-------------------------------------------------------------------------------------------------------------------

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

FILE: private_taxonomy/src/Plugin/Field/FieldFormatter/PrivateTaxonomyFormatterBase.php
--------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
--------------------------------------------------------------------------------------------------------------------------------------------------------
  6 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\FieldDefinitionInterface.
 75 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
 77 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
 80 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
--------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: private_taxonomy/src/Plugin/Field/FieldType/PrivateTaxonomyTermReferenceItem.php
-------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------------------
 75 | ERROR | The array declaration extends to column 94 (the limit is 80). The array content should be split up over multiple lines
-------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: private_taxonomy/src/Plugin/Field/FieldWidget/PrivateTaxonomyAutocompleteWidget.php
----------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------------
  12 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\taxonomy\Entity\Term.
 110 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
 148 | WARNING | [ ] Unused variable $result.
----------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: private_taxonomy/src/Controller/TermAutocompleteController.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 6 WARNINGS AFFECTING 7 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
  11 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Symfony\Component\HttpFoundation\JsonResponse.
  87 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 134 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 163 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 178 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 179 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 206 | WARNING | [ ] Unused variable $tid.
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------

FILE: private_taxonomy/private_taxonomy.module
--------------------------------------------------------------------------------------------------------------------------------
FOUND 9 ERRORS AND 3 WARNINGS AFFECTING 11 LINES
--------------------------------------------------------------------------------------------------------------------------------
  12 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityInterface.
  82 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  86 | ERROR   | [x] Expected 1 space before "="; 0 found
  89 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 112 | ERROR   | [x] Expected 1 space after closing parenthesis; found 0
 217 | ERROR   | [x] Separate the @param and @return sections by a blank line.
 233 | ERROR   | [x] list(...) is forbidden, use [...] instead.
 233 | WARNING | [ ] Unused variable $table.
 306 | WARNING | [ ] Unused variable $result.
 352 | ERROR   | [x] Expected "arrayint" but found "array/int" for parameter type
 389 | ERROR   | [x] Expected "arrayint" but found "array/int" for parameter type
 862 | WARNING | [ ] Unused variable $result.
--------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------

FILE: private_taxonomy/tests/src/Functional/PrivateTaxonomyTestBase.php
----------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\taxonomy\Entity\Vocabulary.
----------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------

FILE: private_taxonomy/tests/src/Functional/PrivateTaxonomySettingsTest.php
--------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------
 97 | WARNING | Unused variable $user.
--------------------------------------------------------------------------------------------------------------------------------------------

FILE: private_taxonomy/tests/src/Functional/PrivateTaxonomyViewsTest.php
----------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------
  19 | ERROR   | Do not disable strict config schema checking in tests. Instead ensure your module properly declares its schema for configurations.
 115 | WARNING | Unused variable $private_vocabulary.
----------------------------------------------------------------------------------------------------------------------------------------------------

FILE: private_taxonomy/tests/src/Functional/PrivateTaxonomyPermissionsTest.php
-----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------------------------------------------
 184 | WARNING | Unused variable $public_vocabulary.
 289 | WARNING | Unused variable $admin_user.
 439 | WARNING | Unused variable $user.
-----------------------------------------------------------------------------------------------------------------------------------------------
Time: 315ms; Memory: 18MB

Proposed resolution

Remaining tasks


FILE: private_taxonomy/private_taxonomy.module
---------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------
 234 | WARNING | Unused variable $table.
---------------------------------------------------------------------------------------------------------------

FILE: private_taxonomy/tests/src/Functional/PrivateTaxonomyViewsTest.php
-------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------------
 19 | ERROR | Do not disable strict config schema checking in tests. Instead ensure your module properly declares its schema for configurations.
-------------------------------------------------------------------------------------------------------------------------------------------------
Time: 315ms; Memory: 18MB

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇳India adwivedi008

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 @adwivedi008
  • Status changed to Needs review almost 2 years ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update almost 2 years ago
    17 pass
  • 🇮🇳India adwivedi008

    Resolved all issues

    The remaining issues after applying the patch are

    
    FILE: private_taxonomy/private_taxonomy.module
    ---------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------
     234 | WARNING | Unused variable $table.
    ---------------------------------------------------------------------------------------------------------------
    
    FILE: private_taxonomy/tests/src/Functional/PrivateTaxonomyViewsTest.php
    -------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------------
     19 | ERROR | Do not disable strict config schema checking in tests. Instead ensure your module properly declares its schema for configurations.
    -------------------------------------------------------------------------------------------------------------------------------------------------
    Time: 315ms; Memory: 18MB
    
  • Status changed to Needs work over 1 year ago
  • 🇮🇳India ashutosh ahirwal India

    Confirming the #2 comment and moving to Need work for remaining issue.

  • Assigned to nitin_lama
  • 🇮🇳India nitin_lama India

    Providing updated patch.

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    1 pass, 8 fail
  • Issue was unassigned.
  • 🇮🇳India zkhan.aamir

    Hi,

    Patch #5 applied successfully.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/private_taxonomy (8.x-2.x)
    $ curl https://www.drupal.org/files/issues/2024-02-07/3404201-5.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 18305  100 18305    0     0  27131      0 --:--:-- --:--:-- --:--:-- 27158
    patching file private_taxonomy.module
    patching file private_taxonomy.tokens.inc
    patching file src/Controller/TermAutocompleteController.php
    patching file src/Form/PrivateTaxonomySettingsForm.php
    patching file src/Plugin/Field/FieldFormatter/PrivateTaxonomyFormatterBase.php
    patching file src/Plugin/Field/FieldType/PrivateTaxonomyTermReferenceItem.php
    patching file src/Plugin/Field/FieldWidget/PrivateTaxonomyAutocompleteWidget.php
    patching file tests/src/Functional/PrivateTaxonomyPermissionsTest.php
    patching file tests/src/Functional/PrivateTaxonomySettingsTest.php
    patching file tests/src/Functional/PrivateTaxonomyTestBase.php
    patching file tests/src/Functional/PrivateTaxonomyViewsTest.php
    

    Remaining issue.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules
    $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml private_taxonomy/
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\private_taxonomy\tests\src\Functional\PrivateTaxonomyViewsTest.php
    -------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------------
     19 | ERROR | Do not disable strict config schema checking in tests. Instead ensure your module properly declares its schema for configurations.
    -------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 875ms; Memory: 16MB
    
  • 🇮🇳India zkhan.aamir

    Issue summary updated.

  • Assigned to amit.rawat777
  • 🇮🇳India amit.rawat777

    I am working on this.

  • 🇮🇳India amit.rawat777

    I have fixed the issues. Please review.

  • 🇺🇸United States cmlara
Production build 0.71.5 2024