Problem: developers just repeat the class name in a doc comment, which is useless:

namespace Drupal\example\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Class Example.
 */
class Example extends ConfigFormBase {

Such a comments does not carry any additional information, the only benefit is the visual separation between the use statements and the beginning of the class.

Solution: create a sniff that checks if the class short comment only consists of 2 words. If one word is the class then throw a warning "The class short comment should describe what the class does and not simply repeat the class name."

Comments

klausi created an issue. See original summary.

arkener’s picture

Status: Active » Needs review
klausi’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, I have a tiny comment where the test case should be but after that you can merge.

  • Arkener authored de37d53 on 8.x-3.x
    feat(ClassComment): Add a sniff to check for "Class Example" doc...
arkener’s picture

Status: Reviewed & tested by the community » Fixed

Fixed and merged, thanks for the review @Klausi!

Status: Fixed » Closed (fixed)

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