I've noticed that info.yml files are quite heterogeneous. Sometimes module names have single quotes, sometimes not. Same deal for module descriptions which can have no quote or single/double quotes.

Why wouldn't we unify all this and decide for instance that module names shouldn't have single quotes and descriptions should always have them and end with a full stop? I'm not making this up, just suggesting this based on the most common denominator in the current codebase.

I've thus applied this cleanup for all modules that weren't following this syntax.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review

.

Status: Needs review » Needs work

The last submitted patch, yml-module-cleanup.patch, failed testing.

anavarre’s picture

Status: Needs work » Needs review
FileSize
7.26 KB

Oh that's unfortunate. #2095943: Core modules and themes missing the version attribute in info.yml was committed yesterday and it broke this patch. Here's an updated patch that I applied successfully against HEAD just now.

Status: Needs review » Needs work

The last submitted patch, 3: yml-module-cleanup-VERSION.patch, failed testing.

anavarre’s picture

Issue summary: View changes

Some data:

$ for i in "name: " "name: '" ; do grep "$i" */*.info.yml | wc -l | xargs echo Number of occurences for string "\"$i\"" =\> ; done ; for i in "description: " "description: '" ; do grep "$i" */*.info.yml | wc -l | xargs echo Number of occurences for string "\"$i\"" =\> ; done ;

Number of occurences for string "name: " => 61
Number of occurences for string "name: '" => 16
Number of occurences for string "description: " => 61
Number of occurences for string "description: '" => 57

So it'd seem that in Core we'd prefer the name and description value to be set without single quotes.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

MaskyS’s picture

Version: 8.2.x-dev » 8.3.x-dev
Assigned: Unassigned » MaskyS

I think that this is a good idea, but first we need to set this to 8.3.x dev. I'm going to assign this to myself and start working on it. The data is quite outdated though. Here is a new set:

$ for i in "name: " "name: '" ; do grep "$i" */*.info.yml | wc -l | xargs echo Number of occurences for string "\"$i\"" =\> ; done ; for i in "description: " "description: '" ; do grep "$i" */*.info.yml | wc -l | xargs echo Number of occurences for string "\"$i\"" =\> ; done ;
Number of occurences for string "name: " => 72
Number of occurences for string "name: '" => 23
Number of occurences for string "description: " => 72
Number of occurences for string "description: '" => 68
MaskyS’s picture

Here is the patch for removing quotes from names and for adding them to description as suggested by reporter. If ever its decided to remove quotes for description as well, then I'd be happy to make another patch :)

MaskyS’s picture

Status: Needs work » Needs review
MaskyS’s picture

FileSize
5.09 KB

Here's the interdiff :)

tstoeckler’s picture

I personally do it this way: As soon as a string contains a space then I enclose the string in single quotes. That is what the Symfoner YAML encoder does, so this makes various handcrafted YAMLs nicely consistent with exported configuration.

anavarre’s picture

Makes sense. Also, I found the PECL YAML extension is way stricter than the Symfony YAML parser so it's likely going to help bring consistency and better formatting altogether.

dawehner’s picture

I'm wondering whether we could/should integrate this into a phpcs rule, so for example contrib modules don't have to think about it, but rather just check the rules.

MaskyS’s picture

@dawehner I don't think we should force this on them as it might render some modules unusable. I'd rather that we adopt this as a standard...

gvso’s picture

Status: Needs review » Needs work
+++ b/core/modules/basic_auth/basic_auth.info.yml
@@ -1,6 +1,6 @@
-description: 'Provides the HTTP Basic authentication provider.'
+description: 'Provides the HTTP Basic authentication provider'

+++ a/core/modules/datetime/datetime.info.yml
@@ -1,6 +1,6 @@
+description: Defines datetime form elements and a datetime field type.
-description: 'Defines datetime form elements and a datetime field type.'

+++ a/core/modules/serialization/serialization.info.yml
@@ -1,6 +1,6 @@
+description: Provides a service for (de)serializing data to/from formats such as JSON and XML
-description: 'Provides a service for (de)serializing data to/from formats such as JSON and XML.'
...

There are descriptions which were not enclosed in single quotes. Plus, some of them don't have a period (.) at the end.

it might render some modules unusable

It won't. Adding it into a phpcs rule will only let developers know they are not following the standards if they check their code.

MaskyS’s picture

Status: Needs work » Needs review
FileSize
13.67 KB
3.32 KB

@gvso thanks for the review! Here is a patch and its interdiff for fixing the few decriptions that were not edited. If phpcs won't break anything(forgive my noob knowledge), then sure, somebody please implement it!

gvso’s picture

@Kifah Meeran, I guess we need to decide which convention we are going to follow first before working on a patch.

gvso’s picture

Status: Needs review » Needs work

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Closed (duplicate)
Issue tags: +Bug Smash Initiative
Related issues: +#2994928: Quote consistency in .info.yml files for Core modules

Looks like I forgot to change the status here. I did move credit.