Translated strings in annotations are allowed to exceed 80 characters

Created on 19 July 2024, 5 months ago

Problem/Motivation

Annotations are not limited to 80 characters. In practice we are supporting annotations already quite well thanks to earlier work done in #2530920: Over-aggressive line length chokes on annotations , but there is a common case that is not covered: translatable strings.

As a showcase, the example listed in the actual coding standard for annotations currently doesn't pass tests (ref. Coding standard for plugin discovery annotations .

We throw a Line exceeds 80 characters error on the line with the description:

/**
 * @Plugin(
 *   id = "aggregator",
 *   title = @Translation("Default fetcher"),
 *   description = @Translation("Downloads data from a URL using Drupal's HTTP request handler."),
 * )
 */
class DefaultFetcher implements FetcherInterface {

Proposed resolution

Let's use a regex with a narrow scope to minimize false positives. I would propose to exclude lines that contain = @Translation( since this will be almost exclusively found inside annotations.

🐛 Bug report
Status

Closed: works as designed

Version

8.3

Component

Coder Sniffer

Created by

🇧🇬Bulgaria pfrenssen Sofia

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

Comments & Activities

Production build 0.71.5 2024