When running the module code against Drupal coding standards based on Drupal standard, the module shows errors

phpcs -s --standard=Drupal sites/default/modules/like_and_dislike/

FILE: .../default/modules/like_and_dislike/src/LikeDislikePermissions.php
----------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
----------------------------------------------------------------------
  3 | ERROR | [x] Namespaced classes, interfaces and traits should not
    |       |     begin with a file doc comment
    |       |     (Drupal.Commenting.FileComment.NamespaceNoFileDoc)
 30 | ERROR | [x] Separate the @return and @see sections by a blank
    |       |     line. (Drupal.Commenting.DocComment.TagGroupSpacing)
 58 | ERROR | [ ] Expected type hint "VoteType"; found
    |       |     "ConfigEntityInterface" for $type
    |       |     (Drupal.Commenting.FunctionComment.IncorrectTypeHint)
 79 | ERROR | [x] Missing function doc comment
    |       |     (Drupal.Commenting.FunctionComment.Missing)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...sites/default/modules/like_and_dislike/src/Form/SettingsForm.php
----------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
   3 | ERROR | [x] Namespaced classes, interfaces and traits should not
     |       |     begin with a file doc comment
     |       |     (Drupal.Commenting.FileComment.NamespaceNoFileDoc)
   6 | ERROR | [ ] Doc comment short description must be on a single
     |       |     line, further text should be a separate paragraph
     |       |     (Drupal.Commenting.DocComment.ShortSingleLine)
 106 | ERROR | [x] Expected 1 newline at end of file; 0 found
     |       |     (Drupal.Files.EndFileNewline.NoneFound)
 106 | ERROR | [x] The closing brace for the class must have an empty
     |       |     line before it
     |       |     (Drupal.Classes.ClassDeclaration.CloseBraceAfterBody)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...ult/modules/like_and_dislike/src/LikeDislikeAccessController.php
----------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
  8 | ERROR | [x] Missing class doc comment
    |       |     (Drupal.Commenting.ClassComment.Missing)
 10 | ERROR | [x] Missing function doc comment
    |       |     (Drupal.Commenting.FunctionComment.Missing)
 13 | ERROR | [x] Expected 1 newline at end of file; 0 found
    |       |     (Drupal.Files.EndFileNewline.NoneFound)
 13 | ERROR | [x] The closing brace for the class must have an empty line
    |       |     before it
    |       |     (Drupal.Classes.ClassDeclaration.CloseBraceAfterBody)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...fault/modules/like_and_dislike/src/Controller/VoteController.php
----------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 5 LINES
----------------------------------------------------------------------
  3 | ERROR   | [x] Namespaced classes, interfaces and traits should not
    |         |     begin with a file doc comment
    |         |     (Drupal.Commenting.FileComment.NamespaceNoFileDoc)
 27 | ERROR   | [ ] Visibility must be declared on method "vote"
    |         |     (Squiz.Scope.MethodScope.Missing)
 47 | WARNING | [x] A comma should follow the last multiline array item.
    |         |     Found: $vote_type_id
    |         |     (Drupal.Array.Array.CommaLastItem)
 53 | ERROR   | [x] Space found before comma in function call
    |         |     (Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma)
 59 | ERROR   | [x] Expected 1 newline at end of file; 0 found
    |         |     (Drupal.Files.EndFileNewline.NoneFound)
 59 | ERROR   | [x] The closing brace for the class must have an empty
    |         |     line before it
    |         |     (Drupal.Classes.ClassDeclaration.CloseBraceAfterBody)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 100ms; Memory: 6Mb

Comments

anoopjohn created an issue. See original summary.

anoopjohn’s picture

Status: Active » Needs review
StatusFileSize
new3.66 KB

Please find attached a patch that fixes the issues reported.

mbovan’s picture

Status: Needs review » Needs work

The patch #2 doesn't apply anymore. @anoopjohn, could you please reroll it?

mbovan’s picture

Priority: Normal » Minor
Status: Needs work » Needs review
Issue tags: +Novice
StatusFileSize
new3.05 KB

Quickly rebased with 8.x-1.x.

I think there are more changes to make here, but we could do it when touching the files in other issues.

berdir’s picture

Status: Needs review » Postponed

Already doesn't apply anymore. Lets finish the current refactoring phase and then get back to this.

berdir’s picture

Status: Postponed » Needs review

The last submitted patch, 2: like_and_dislike-coding-standard-fixes-2732401-2.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 4: fix_coding_standard-2732401-4.patch, failed testing.

mbovan’s picture

Status: Needs work » Needs review

Lots of changes in the previous patches are either removed or already fixed.
Here is a quick update.

However, there are many deprecated methods, documentation and other code style fixes that we can work on...

mbovan’s picture

StatusFileSize
new1.35 KB

Forgot the patch.

amit.drupal’s picture

StatusFileSize
new2.89 KB
new1.63 KB
berdir’s picture

Status: Needs review » Needs work
+++ b/like_and_dislike.module
@@ -1,9 +1,8 @@
- * This module provides 2 voting widgets: Like and Dislike. The behavior is
- * similar to Facebook and other social networks, but with negative rating also.
+ * This module provides 2 voting widgets: Like and Dislikoe.
  */

what is a Dislikoe? :)

shruti1803’s picture

Assigned: Unassigned » shruti1803
shruti1803’s picture

Status: Needs work » Needs review
StatusFileSize
new3.02 KB
new491 bytes

Adding patch as mentioned concern in #12.

shruti1803’s picture

Assigned: shruti1803 » Unassigned
berdir’s picture

Status: Needs review » Fixed

Thanks everyone. Time for a new release.

  • Berdir committed 13b265d on 8.x-1.x authored by shruti1803
    Issue #2732401 by mbovan, shruti1803, amit.drupal, anoopjohn: Fix coding...
mbovan’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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