Hey, I came across some best practices issues and coding standards, example of Drupal practices :

phpcs --standard=Drupal modules/contrib/taxonomy_machine_name/

FILE: /var/www/drupal-8/modules/contrib/taxonomy_machine_name/src/Plugin/views/filter/TaxonomyIndexMachineName.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 17 ERRORS AND 1 WARNING AFFECTING 16 LINES
-------------------------------------------------------------------------------------------------------------------------------
  25 | ERROR   | [ ] Class property $validated_exposed_input should use lowerCamel naming without underscores
  25 | ERROR   | [x] You must use "/**" style comments for a member variable comment
  85 | ERROR   | [x] Missing function doc comment
  96 | ERROR   | [x] Missing function doc comment
 108 | ERROR   | [x] Missing function doc comment
 152 | ERROR   | [x] Missing function doc comment
 228 | WARNING | [ ] Line exceeds 80 characters; contains 88 characters
 256 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 264 | ERROR   | [x] Missing function doc comment
 279 | ERROR   | [x] Missing function doc comment
 291 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 318 | ERROR   | [x] Missing function doc comment
 344 | ERROR   | [x] Missing function doc comment
 345 | ERROR   | [x] Inline comments must start with a capital letter
 348 | ERROR   | [x] Missing function doc comment
 360 | ERROR   | [x] Missing function doc comment
 361 | ERROR   | [x] Inline comments must start with a capital letter
 361 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 16 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/drupal-8/modules/contrib/taxonomy_machine_name/src/Plugin/views/argument_validator/TermMachineName.php
---------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
---------------------------------------------------------------------------------------------------------------------
   7 | WARNING | [x] Unused use statement
  86 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 101 | ERROR   | [x] Expected 1 blank line after function; 0 found
 102 | ERROR   | [x] The closing brace for the class must have an empty line before it
---------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------


FILE: /var/www/drupal-8/modules/contrib/taxonomy_machine_name/taxonomy_machine_name.api.php
-------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------
 4 | ERROR | [x] The second line in the file doc comment must be "@file"
-------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------


FILE: /var/www/drupal-8/modules/contrib/taxonomy_machine_name/taxonomy_machine_name.module
----------------------------------------------------------------------------------------------------------------
FOUND 32 ERRORS AND 11 WARNINGS AFFECTING 30 LINES
----------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] Missing file doc comment
  11 | WARNING | [ ] Hook implementations should not duplicate @param documentation
  11 | ERROR   | [ ] Missing parameter comment
  13 | WARNING | [ ] Hook implementations should not duplicate @return documentation
  13 | ERROR   | [ ] Description for the @return value is missing
  15 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
  19 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
  31 | WARNING | [ ] Hook implementations should not duplicate @param documentation
  31 | ERROR   | [ ] Missing parameter comment
  32 | WARNING | [ ] Hook implementations should not duplicate @param documentation
  32 | ERROR   | [ ] Missing parameter comment
  33 | WARNING | [ ] Hook implementations should not duplicate @param documentation
  33 | ERROR   | [ ] Missing parameter comment
  35 | ERROR   | [ ] Type hint "array" missing for $form
  37 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
  46 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
  78 | WARNING | [ ] Hook implementations should not duplicate @param documentation
  78 | ERROR   | [ ] Missing parameter comment
  79 | WARNING | [ ] Hook implementations should not duplicate @param documentation
  79 | ERROR   | [ ] Missing parameter comment
  80 | WARNING | [ ] Hook implementations should not duplicate @param documentation
  80 | ERROR   | [ ] Missing parameter comment
  82 | ERROR   | [ ] Type hint "array" missing for $form
  84 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
  91 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 121 | WARNING | [ ] Hook implementations should not duplicate @param documentation
 121 | ERROR   | [ ] Missing parameter comment
 122 | WARNING | [ ] Hook implementations should not duplicate @param documentation
 122 | ERROR   | [ ] Missing parameter comment
 124 | ERROR   | [ ] Type hint "array" missing for $form
 124 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
 150 | ERROR   | [x] Data types in @param tags need to be fully namespaced
 186 | WARNING | [ ] Hook implementations should not duplicate @param documentation
 186 | ERROR   | [ ] Missing parameter comment
 188 | ERROR   | [ ] Expected type hint "EntityInterface"; found "Drupal\Core\Entity\EntityInterface" for $term
 188 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
 190 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 243 | ERROR   | [x] Data types in @param tags need to be fully namespaced
 247 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 271 | ERROR   | [ ] Missing parameter comment
 273 | ERROR   | [ ] Description for the @return value is missing
 288 | ERROR   | [x] Short array syntax must be used to define arrays
 302 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
----------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 15 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------


FILE: /var/www/drupal-8/modules/contrib/taxonomy_machine_name/taxonomy_machine_name.install
-------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------
  1 | ERROR | [x] Missing file doc comment
 37 | ERROR | [ ] Missing parameter type
-------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------


FILE: /var/www/drupal-8/modules/contrib/taxonomy_machine_name/taxonomy_machine_name.views.inc
---------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
 1 | ERROR | [x] Missing file doc comment
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------


FILE: /var/www/drupal-8/modules/contrib/taxonomy_machine_name/README.md
-----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------
 65 | ERROR | [x] Expected 1 newline at end of file; 2 found
-----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------

Time: 337ms; Memory: 12MB

Comments

Sergiu Stici created an issue. See original summary.

sergiu stici’s picture

Status: Active » Needs review
StatusFileSize
new15.01 KB

Here is the patch, please review.

sdstyles’s picture

StatusFileSize
new16.14 KB

  • sdstyles committed 15071bb on 8.x-1.x authored by Sergiu Stici
    Issue #3065995 by Sergiu Stici, sdstyles: Drupal best practices and...
sdstyles’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

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