WordPress / WordPress-Coding-Standards

PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions
MIT License
2.57k stars 491 forks source link

Squiz.Commenting.InlineComment.InvalidEndChar triggers on translators comment #1723

Open marekdedic opened 5 years ago

marekdedic commented 5 years ago

Bug Description

When I have a "translators" comment, phpcs complains about it not ending in a period. IMHO, this doesn't really make sense as translators comments are not regular comments and they are in my case usually not sentences, so they shouldn't need to end with a period

Minimal Code Snippet

// translators: 1: Start of link to the settings 2: End of link to the settings

For bugs with fixers: How was the code fixed? How did you expect the code to be fixed?

Error Code

 88 | ERROR | Inline comments must end in full-stops, exclamation marks, or question marks
    |       | (Squiz.Commenting.InlineComment.InvalidEndChar)

Environment

Question Answer
PHP version 7.3
PHP_CodeSniffer version 3.4.2
WPCS version 2.1.1
WPCS install type Composer project local

Tested Against develop branch?

jrfnl commented 5 years ago

@marekdedic At this time, WPCS uses non-WP specific documentation sniffs which don't take things like translators comments into account properly.

For the more commonly used /* ... */ style for translators comments, you'll find that you will not get an error about the end character not being punctuation. However, for the (less common) // ...-style translators comments, you will receive this error for now, until WPCS has its own set of documentation sniffs.

Does that help ?

marekdedic commented 5 years ago

Hi, I can confirm that this is a functioning workaround for the issue.

As far as I am concerned, this is just that - a workaround, not a solution. But I get that this depends on a lot of moving parts... Just wanted to say please don't close the issue as solved, until it really is (and other people might find your comment helpful as well...).

Thanks for the feedback.

jrfnl commented 5 years ago

@marekdedic No worries, not closing this (yet), though you may be interested in this issue: #1760, which was partially inspired by your question.