-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow lines to be longer than 80 chars if they're the first line in multi-line comments or part of annotations #3938
Comments
The max line length is configurable for this sniff. The fact that Drupal enforces the short description to be single line is not something this sniff should take into account. That's something to discuss in the Drupal project. Also keep in mind that the short description is supposed to be exactly that : short. You can expand on it in a long description. For your example, that could look like this: /**
* Provides a configurable slideshow block.
*
* This slideshow block is used on static pages if they are top-level in the menu.
*
* @Block(
* ...
* )
*/
Aside from the max line length being configurable, you can also choose to ignore comments altogether. |
Only just realized this issue was opened in the Squizlabs repo. For the future, please open new issues in the https://github.com/PHPCSStandards/PHP_CodeSniffer repo. See #3932 for context. |
@jrfnl thanks for the feedback. Actually it is more complicated than I thought and the reason why I didn't find the Besides that, PhpStorm actually seems to use a combination of Editorconfig, PHPCS rules and it's own config when reformatting code on file save. That makes it more difficult to find out why a piece of code gets formatted the way it does and how to configure different tools to work nicely together (I had similar problems with Jetbrains IDEs and ESLint + Prettier). Because the comment line only got broken up when PhpStorm was configured to use "PHP Code Beautifier and Fixer" as external formatter with using the project Back to your suggestions:
To sum it up
|
This is a follow-up to #766 where the reason for too long lines in comments was basically the line containing an url.
I would like to discuss extending this enhancement to the first line of a multi-line comment, also known as the short description. Assume the following example of a class in Drupal 10:
The short description is 96 characters long (excluding the
<space>*<space>
) and would be broken up into two lines. But that would cause the sniffDrupal.Commenting.DocComment.ShortSingleLine
(Doc comment short description must be on a single line, further text should be a separate paragraph) to trigger an error. In some cases it is just not possible to make the short description of a class or function fitting the maximum line length, if special naming or wording of things (coming from the technology used like Drupal, from the customer's/project's business domain or similar).And in the case of the admin_label line, if the text provided to
@Translation()
should be longer that would exceed the maximum line length as well. As @PortNumber53 mentioned in a comment to #766 breaking the lines inside of annotations does not always work well.The text was updated successfully, but these errors were encountered: