Prevent @returns from creeping back into the codebase

Created on 12 October 2023, about 1 year ago
Updated 13 October 2023, about 1 year ago

Problem/Motivation

In πŸ› Use "@return" instead of "@returns" Postponed we fixed invalid use of @returns in comments, but we did not prevent it from happening again.

Steps to reproduce

Proposed resolution

Similar to the ban on @inheritDoc (with capital D) we can add a rule to phpcs.xml.dist to ban @returns.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
DocumentationΒ  β†’

Last updated about 14 hours ago

No maintainer
Created by

πŸ‡¬πŸ‡§United Kingdom longwave UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @longwave
  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    But isn't this covered by another sniff already? If a method has a return value, there should be a sniff already that flags the method if @return isn't specified. And if you misspell @return, then the sniff should catch this.

    Unless of course core has turned off that warning ... in that case the solution is to turn it back on and fix any other problems in core that are revealed by this.

    In contrib, however, PHPCS does tell us if the @return tag is missing, if the @return type is missing, and if the @return parameter is not documented.

    FunctionCommentSniff: "Missing @return tag in function comment"

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    BTW this is the same point I brought up 6 years ago when I opened πŸ› Use "@return" instead of "@returns" Postponed , and at the time @dawehner https://www.drupal.org/project/drupal/issues/2916306#comment-12300987 πŸ› Use "@return" instead of "@returns" Postponed and @alexpott https://www.drupal.org/project/drupal/issues/2916306#comment-12302537 πŸ› Use "@return" instead of "@returns" Postponed said that they though turning the sniff back on for core was the right thing to do in principle.

    Checking for one specific misspelling (@returns) may help a little, but it doesn't fix missing @return documentation and it doesn't fix any other misspellings or casing problems with this tag, so it's only a baby step in the right direction.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    The issue to add the sniff is πŸ“Œ [Meta] Fix Drupal.Commenting.FunctionComment.InvalidNoReturn Active . It was recently RTBC but was pushed back to split into child issues. There are 5 child issues, 2 at RTBC, 1 needs work, 1 is active and the last one is to enable the sniff. I'd much rather put effort into completing those issues instead of making this change. A change that, if made, should be removed when the sniff is enabled.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Of the child issues mentioned above it is now, 3 at RTBC, 1 is active and the last one is to enable the sniff. It was just random failures in one of the issues.

Production build 0.71.5 2024