Problem/Motivation

While evaluating and researching core modules, it was noticed that are a few inconsistencies in .info.yml files, specifically, the use of single and double quotes around titles and descriptions.

Analysis:

Modules with one word titles (with no quotes): 41
Modules with one word titles (with single quotes): 2
Modules with multiple word titles (with single quotes): 22
Modules with multiple word titles (with no quotes): 9
Description (with single quotes): 67
Description (with no quotes): 3
Description (with double quotes): 1

Proposed resolution

Update modules to have the following:

Standards proposal for name and description values:

  • The first character in the name value is a letter or underscore.
  • Name and description have to be resolved to strings by Yaml.
  • Single quoting of values is allowed in some cases. (see below)
  • Double quoting of values is not allowed.
  • The value mapping indicator (:) should be followed by a single space.

In the following cases, use single quoting:

  • Value contains a : followed by a <space> or a # preceded by a <space>.
  • Value contains any of the following characters with or without a preceding colon: { } [ ] <comma>
  • Values matches completely with any of these: true false yes no y n on off null ~
  • Value starts with any of these characters: ! & * { } [ ] , # | > @ ` " \ ' <space> %
  • Value starts with a ?, : or - followed by a <space>.

See also https://www.drupal.org/docs/creating-custom-modules/let-drupal-know-abou...

Remaining tasks

Create an issue in the Coding Standards project to decide what the standard format should be.

  1. Create patch
  2. Review patch
  3. Clarify what the standards are.
  4. Write tests to prevent issue from occurring in the future as new or experimental modules are added to core.
  5. Edit Drupal documentation pages to explain standards.

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#88 reroll_diff_82-88.txt5.62 KBravi.shankar
#88 2994928-88.patch251.52 KBravi.shankar
#82 interdiff_80-82.txt1.25 KBravi.shankar
#82 2994928-82.patch251.37 KBravi.shankar
#80 reroll_diff_76-80.txt19.8 KBravi.shankar
#80 2994928-80.patch251.45 KBravi.shankar
#76 interdiff_74-76.txt8.54 KBtvb
#76 2994928-76.patch254.6 KBtvb
#75 2994928-74.patch256.45 KBtvb
#71 interdiff_70-71.txt6.12 KBtvb
#71 2994928-71.patch255.87 KBtvb
#70 interdiff_65-70.txt7.62 KBtvb
#70 2994928-70.patch258.58 KBtvb
#65 2994928-65.patch259.2 KBmartin107
#65 interdiff-2994928-63-65.txt8.08 KBmartin107
#63 interdiff_61-63.txt780 bytesshaktik
#63 2994928-63.patch256.36 KBshaktik
#61 interdiff_60-61.txt1.39 KBtvb
#61 2994928-61.patch255.44 KBtvb
#60 interdiff_58-60.txt33.48 KBtvb
#60 2994928-60.patch253.44 KBtvb
#59 2994928-58.patch222.91 KBtvb
#58 interdiff_52-58.txt130.37 KBtvb
#58 2994928-52-58.txt130.37 KBtvb
#55 2994928-55.patch274.26 KBPooja Ganjage
#52 interdiff_49-52.txt2.05 KBtvb
#52 2994928-52.patch40.07 KBtvb
#50 interdiff_48-49.txt2.56 KBtvb
#49 interdiff_48-49.patch2.56 KBtvb
#49 2994928-49--add-test.patch39.81 KBtvb
#48 interdiff_47-48.txt1.27 KBtvb
#48 2994928-48--add-test.patch39.59 KBtvb
#47 interdiff-36-47.txt35.09 KBs_bhandari
#47 2994928-47.patch37.71 KBs_bhandari
#36 2994928-36.patch38.22 KBhardik_patel_12
#23 drupal-quote-consistency-yml-files-2994928-23.patch35.86 KBvolkswagenchick
#6 interdiff-2994928-3-6.txt466 bytesvolkswagenchick
#6 drupal-quote-consistency-yml-files-2994928-6.patch6.41 KBvolkswagenchick
#3 drupal-quote-consistency-yml-files-2994928-3.patch5.95 KBvolkswagenchick
#2 Audit_quote_consitency _core_modules.txt5.25 KBvolkswagenchick

Issue fork drupal-2994928

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

volkswagenchick created an issue. See original summary.

volkswagenchick’s picture

StatusFileSize
new5.25 KB

I have uploaded a file with an audit of all the core modules.

volkswagenchick’s picture

Assigned: volkswagenchick » Unassigned
Status: Active » Needs review
StatusFileSize
new5.95 KB

I have uploaded a patch that standardizes the .info.yml files in core modules to have the following:

1. Modules with one word title should use no quotes around the title.
2. Modules with multiple word title should use single quotes around the title.
3. Module descriptions should use single quotes around the description.

Modules with one word titles (with single quotes) - removed quotes
* Hal
* Workflows

Modules with multiple word titles (with no quotes) - added single quotes
* Place Blocks - block_place
* Internal Dynamic Page Cache - dynamic_page_cache
* Inline Form Errors - inline_form_errors
* Menu UI - menu_ui
* Migrate Drupal - migrate_drupal
* Internal Page Cache - page_cache
* Quick Edit - quick_edit
* Responsive Image - responsive_image
* Activity Tracker - tracker

Description (with no quotes) - added single quotes
* Datetime - datetime
* Serialization - serialization
* Tour - tour

Description (with double quotes) - removed double quotes and added single quotes
* CKEditor

dani3lr0se’s picture

Status: Needs review » Needs work

I have compared the patch to the audit file and all the changes look appropriate.

Two modules that had one word titles now have no quotes: HAL and Workflow, now have no quotes.

Nine modules that had Multiple word titles now have single quotes: Place Blocks, Internal Dynamic Page Cache, Inline Form Errors, Menu UI, Migrate Drupal, Internal Page Cache, Quick Edit, Responsive Image, and Activity Tracker.

Three modules that either had no quotes or double quotes around the description now have single quotes: Serialization, Tour, and CKEditor.

I didn't see Datetime changes in the patch however. Going to set this to needs work.

Thanks for bringing this up and making time for a patch. This is a great initiative that will help with consistency amongst all core modules and will also hopefully provide a standard for other contrib modules to follow.

volkswagenchick’s picture

Assigned: Unassigned » volkswagenchick

Ooops! Good catch! I will work on this later this afternoon, so am assigning it back to myself.

I also welcome any community feedback.

volkswagenchick’s picture

Assigned: volkswagenchick » Unassigned
Status: Needs work » Needs review
StatusFileSize
new6.41 KB
new466 bytes

i uploaded another patch that makes that changes and included an interdiff for easy review. Thanks

volkswagenchick’s picture

I would like to attribute @Kristen Pol for helping with the review and audit process.
And @loopduplicate for initial discovery and roadmap of TODOS.

Thanks!

dani3lr0se’s picture

Status: Needs review » Reviewed & tested by the community

I now see the Datetime changes and the single quotes around the description. Thanks for making the change and interdiff! The patch also applies successfully with Simplytest. Thanks again for doing this. I'm hoping others agree with your findings.

loopduplicate’s picture

Issue summary: View changes

Looking good :)

nerdstein’s picture

I am also confirming the RTBC on this. I went through each change on the "Extend" page to verify the module names and descriptions worked for each change.

I also like this paradigm for use in contrib as well. It would be a welcomed convention to know when to use quotes and when not to. This could be a separate issue to discuss.

volkswagenchick’s picture

Issue summary: View changes
kristen pol’s picture

Good stuff. Thanks!

One comment on the issue summary which has:

"Write tests to prevent issue from occurring in the future as new or experimental modules are added to core."

This is an interesting idea. I don't know if we have any *tests* that check for code formatting. We use Code Sniffer when checking our Drupal code for coding standards, but it would be interesting to write tests to check formats. Curious if anyone knows if this exists anywhere.

quietone’s picture

This is a confusing, these are yml files and quotes are not needed. Why add such a requirement?

volkswagenchick’s picture

While looking at all the .info.yml files in the core modules, I noticed the usage of quotes was inconsistent.

I am chose this route because it seems most core modules aligned to these patterns.

wim leers’s picture

This inconsistency has been triggering my OCD for years :P Thanks @volkswagenchick! :)

volkswagenchick’s picture

Assigned: Unassigned » volkswagenchick
Issue tags: +DrupalCorn2018

Tagging for training session at Drupal Corn 2018

ultimike’s picture

I love this idea of making things consistent. Whatever is decided should probably be documented in our coding standards. A good place to start would be to add a new issue to the Coding Standards issue queue.

Some additional info about strings in .yml files:

tl;dr It seems that the prevailing "best practice" is to not use any quotes unless you need them.

-mike

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 6: drupal-quote-consistency-yml-files-2994928-6.patch, failed testing. View results

volkswagenchick’s picture

Status: Needs work » Reviewed & tested by the community

I reviewed the results of the failed testing. It doesn't look like a true failure. The text reads:

6 Oct 2018 at 06:50 PDT
PHP 7 & MySQL 5.5 Build Successful

I am going to mark this as RTBC again, thanks!

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Let's add a test to ensure this never comes back, could be done with coder (linting) or an actual test.

quietone’s picture

@volkswagenchick, thanks for the response. I understand that going with what people do in practice is very useful information but I still question it when that practice is unnecessary.

It seems that the prevailing "best practice" is to not use any quotes unless you need them.

+1. I agree with ultimike

I can't help but reread the goals in the YAML specification. The first goal of YAML is "YAML is easily readable by humans". For me adding quotes reduces readability by adding clutter and it even looks ugly. I don't say that lightly. Although limited to migration yml files I work with yml every day.

volkswagenchick’s picture

Thanks for the feedback. I will review some more documentation next week, as I am at a conference until then.

volkswagenchick’s picture

Version: 8.6.x-dev » 8.7.x-dev
Status: Needs work » Needs review
StatusFileSize
new35.86 KB

I uploaded a patch that removes ALL quotes from core module's .info.yml file. Set against 8.7.x branch.

volkswagenchick’s picture

Issue summary: View changes

Status: Needs review » Needs work
damienmckenna’s picture

Status: Needs work » Needs review

I've set the tests to run again, this time against the 8.7.x branch.

damienmckenna’s picture

Maybe it'd be worth looking at opening a Coding Standards issue to find a linter that follows the format we want to use, and then getting that set up on the testing infrastructure?

longwave’s picture

quietone’s picture

@volkswagenchick, thanks for reviewing some more documentation (#22).

Wish I had time to do a proper review now :-(

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.

chi’s picture

Modules with one word title should use no quotes around the title.
Modules with multiple word title should use single quotes around the title.

What is the rationale behind such a decision? Strings with multiple words in YML files work fine. This might be a bit confusing because some IDEs (i.e. PhpStorm) highlight quoted strings differently.

Also wonder why this issue is limited to module info files?

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.

kristen pol’s picture

Assigned: volkswagenchick » Unassigned
Issue tags: +Needs reroll

Needs a reroll for 9.1.x. Note that some files no longer existing, e.g. core/modules/block_place/block_place.info.yml.

volkswagenchick’s picture

Status: Needs review » Needs work
hardik_patel_12’s picture

Status: Needs work » Needs review
StatusFileSize
new38.22 KB

Re-rolling a patch against 9.1.x , kindly review a patch.

volkswagenchick’s picture

Patch installed locally on 9.1.x. ALL quotes from core module's .info.yml file have been removed

kristen pol’s picture

@volkswagenchick Did you want to mark RTBC?

volkswagenchick’s picture

Status: Needs review » Reviewed & tested by the community

Shoot. Yes. Thanks Kristen. Marked RTBC

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 36: 2994928-36.patch, failed testing. View results

hardik_patel_12’s picture

Status: Needs work » Reviewed & tested by the community

Random failure , setting back to RTBC.

quietone credited MaskyS.

quietone credited anavarre.

quietone credited gvso.

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update

I am pleased to see the progress here.

I applied that patch and found that not all .info.yml files have been fixed.

$ grep -ri \' core/modules/*/*.info.yml
core/modules/migrate_drupal_multilingual/migrate_drupal_multilingual.info.yml:package: 'Core (Experimental)'

I also noticed that many files have two spaces after the ':', whereas only one character is necessary.

$ grep -ri 'description:  ' core/modules/*/*.info.yml | wc -l
78
$ grep -ri 'name:  ' core/modules/*/*.info.yml | wc -l
29

The tags show that this needs a reroll and that it needs tests. The reroll seems to have happened but not the test. The test was asked for in #20.

The Issue Summary proposed resolution does not match with what is done in the patch.

Setting to NW for the above.

Closed #2116897: Adopt identical YAML formatting for info.yml files as a duplicate, adding credit.

s_bhandari’s picture

Hi, @quietone,

Working on the observations you have shared. Will update as soon as possible.

Thanks.

s_bhandari’s picture

Status: Needs work » Needs review
StatusFileSize
new37.71 KB
new35.09 KB

Hi, @quietone,

I have addressed the observations in this patch that you have shared in #45. Please review the same and let me know for any observation. And, if this looks good we can go ahead for writing the test cases asked in #20. Also, just to highlight the issue summary needs to get updated, as the first two points are strike-through, but we are still working on the patch.

Thanks.

tvb’s picture

Issue tags: -Needs reroll
StatusFileSize
new39.59 KB
new1.27 KB

This is a stab at creating tests.

It is placed under core/tests/Drupal/Tests/Core/Discovery. Not sure whether this is the right location.

Test results after applying the patch from #47:

$ phpunit -c /app/phpunit.xml core/tests/Drupal/Tests/Core/Discovery/YamlConsistencyTest.php
PHPUnit 8.5.8 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\Core\Discovery\YamlConsistencyTest
................................................................. 65 / 80 ( 81%)
............... 80 / 80 (100%)

Time: 280 ms, Memory: 6.00 MB

OK (80 tests, 240 assertions)

tvb’s picture

Issue tags: -Needs tests
StatusFileSize
new39.81 KB
new2.56 KB

Reworked YamlConsistencyTest.

Plus added @group annotation.

tvb’s picture

StatusFileSize
new2.56 KB

Wrong extension for interdiff in #49.

quietone’s picture

Status: Needs review » Needs work

Nice to have a test! Thx,

  1. +++ b/core/tests/Drupal/Tests/Core/Discovery/YamlConsistencyTest.php
    @@ -0,0 +1,56 @@
    +  protected $paths;
    

    Not used

  2. +++ b/core/tests/Drupal/Tests/Core/Discovery/YamlConsistencyTest.php
    @@ -0,0 +1,56 @@
    +  protected function setUp(): void {
    

    Not needed

  3. +++ b/core/tests/Drupal/Tests/Core/Discovery/YamlConsistencyTest.php
    @@ -0,0 +1,56 @@
    +    $paths = glob($this->root . '/core/modules/*/*.info.yml');
    

    What about the info.yml files in test modules in Core modules?

  4. +++ b/core/tests/Drupal/Tests/Core/Discovery/YamlConsistencyTest.php
    @@ -0,0 +1,56 @@
    +      $pattern = '/^[^\']+$/';
    

    Why are double quotes not tested for?

tvb’s picture

StatusFileSize
new40.07 KB
new2.05 KB

#51.1: removed
#51.2: removed
#51.3: see glob($this->root . '/core/modules/*/tests/modules/*/*.info.yml')
#51.4: see additional assertion

Grep results:

$ grep -ri \' core/modules/*/*.info.yml | wc -l
0
$ grep -ri \" core/modules/*/*.info.yml | wc -l
0
$ grep -ri 'name:  ' core/modules/*/*.info.yml | wc -l
0
$ grep -ri 'description:  ' core/modules/*/*.info.yml | wc -l
0
$ grep -ri \' core/modules/*/tests/modules/*/*.info.yml | wc -l
529
$ grep -ri \" core/modules/*/tests/modules/*/*.info.yml | wc -l
9
$ grep -ri 'name:  ' core/modules/*/tests/modules/*/*.info.yml | wc -l
0
$ grep -ri 'description:  ' core/modules/*/tests/modules/*/*.info.yml | wc -l
0
longwave’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 52: 2994928-52.patch, failed testing. View results

Pooja Ganjage’s picture

StatusFileSize
new274.26 KB

Hi,

I have found more info.yml file having inconsistencies quotes and even I have removed quotes from this aggregator_display_configurable_test.info.yml file which makes fail test.

I am creating patch for this.

Please review the patch.

Let me know for any recommendations.

Thanks.

Pooja Ganjage’s picture

Status: Needs work » Needs review
quietone’s picture

Status: Needs review » Needs work

@Pooja Ganjage, thanks for making a patch. The patch in #55 is 274KB which is significantly larger than the previous patch. That may be because you picked up on files that are currently not tested, see comment below, but that is hard to know without an interdiff. An interdiff really makes life easier for a reviewer. If you haven't already seen them instructions are available for creating an interdiff.

+++ b/core/tests/Drupal/Tests/Core/Discovery/YamlConsistencyTest.php
@@ -0,0 +1,55 @@
+    $paths = array_merge($paths, glob($this->root . '/core/modules/*/*.info.yml'));
+    $paths = array_merge($paths, glob($this->root . '/core/modules/*/tests/modules/*/*.info.yml'));

This is still limiting the directories being searched. This returns 369 files but a find, find core/modules -iname \*.info.yml | grep -v themes | nl, returns 419. I think this needs something more generic to recurse the directory tree.

I presume the grep results are after the patch and before the patch. Since the after results return 0 for all the greps but the test fails, I wonder where the error is?

Also, a reminder that the issue summary needs an update.

Cheers

tvb’s picture

Issue summary: View changes
StatusFileSize
new130.37 KB
new130.37 KB

All grep results in #52 are after the patch. They were included to illustrate the 'needs work' status (which remained unchanged in #52).
The test in #52 failed because of an assertion that allows no quotes at all.

Since there is no interdiff in #55, this patch builds on #52.

Modifications in .info files:

  1. Remove single quotes around values for name and for description.
    grep -rl \" core/modules/*/tests/modules/*/*.info.yml | xargs sed -i 's/name: "\(.*\)"/name: \1/'
    grep -rl \" core/modules/*/tests/modules/*/*.info.yml | xargs sed -i 's/description: "\(.*\)"/description: \1/'
  2. Remove double quotes around values for name and for description.
    grep -rl \' core/modules/*/tests/modules/*/*.info.yml | xargs sed -i "s/name: '\(.*\)'/name: \1/"
    grep -rl \' core/modules/*/tests/modules/*/*.info.yml | xargs sed -i "s/description: '\(.*\)'/description: \1/"
  3. Remove single quotes around value for version.
    grep -rl \' core/modules/*/tests/modules/*/*.info.yml | xargs sed -i "s/version: '\(.*\)'/version: \1/"
  4. Manual modifications in these files with special cases:
    core/modules/migrate_drupal/tests/modules/migrate_state_finished_test/migrate_state_finished_test.info.yml
    core/modules/migrate_drupal/tests/modules/migrate_state_not_finished_test/migrate_state_not_finished_test.info.yml
    core/modules/locale/tests/modules/locale_test/locale_test.info.yml
    core/modules/locale/tests/modules/locale_test_translate/locale_test_translate.info.yml
    core/modules/system/tests/modules/requirements1_test/requirements1_test.info.yml
    core/modules/system/tests/modules/requirements2_test/requirements2_test.info.yml
    core/modules/system/tests/modules/system_incompatible_module_version_dependencies_test/system_incompatible_module_version_dependencies_test.info.yml
    core/modules/system/tests/modules/system_incompatible_module_version_test/system_incompatible_module_version_test.info.yml

    Special cases meaning:
    * Quotes around properties. (quotes removed)
    * Quotes inside description. (4 files still have quotes, but not around the value for description)
    * Double single quotes (e.g. ''install'' --> changed to 'install')
    * Quotes around the value for dependencies. (quotes removed)

Modifications in testing:

  1. Reordered the assertions.
  2. New assertion to allow single quotes inside a name value.
    Covers this case:
    description: Tests the 'active' migrate state
  3. Commented out no quotes at all assertion (@todo)
    Is it too strict? Given the case in the preceding bullet and also the comment in #17 "to not use any quotes unless you need them".
  4. Commented out assertion for description and excess whitespace. (@todo)
    The current assertion fails because some .info files do not have a description. Are descriptions required or not?

Clarifying the standards around .info file consistency would benefit further development of the assertions.

Regarding recursing the directory tree: to do

tvb’s picture

StatusFileSize
new222.91 KB

Now with .patch extension.

tvb’s picture

StatusFileSize
new253.44 KB
new33.48 KB

Change of tack for the test:

  • .info files are first parsed with the Symfony Yaml parser.
  • quote requirements are checked via a trait extended from the Symfony Yaml Escaper class.
  • use of regex assertions to check if a value is unquoted, single quoted or double quoted in .info.yml file..
  • checks are limited to values for name and description.

The patch contains another solution to recurse the folders search for .info.yml files. (if finds 419 files, see #57)

tvb’s picture

Status: Needs work » Needs review
StatusFileSize
new255.44 KB
new1.39 KB

Some module names were not properly (un)quoted.

Status: Needs review » Needs work

The last submitted patch, 61: 2994928-61.patch, failed testing. View results

shaktik’s picture

Status: Needs work » Needs review
StatusFileSize
new256.36 KB
new780 bytes

fixed test case kindly check.

Status: Needs review » Needs work

The last submitted patch, 63: 2994928-63.patch, failed testing. View results

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new8.08 KB
new259.2 KB

The test fails with a deprecation notice .. highlighting that relying on Symfony's

Symfony\Component\Yaml\Escaper

class is flawed, because Symfony considers it internal and is subject to change, by them at any time.

I think the best way forward is to copy and modify the Escaper into Drupal's namespace

I don't like that fact that we take on the maintenance of someone else's code but on the good side it is small and self contained

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.

longwave’s picture

Status: Needs review » Needs work

The copied Symfony class doesn't match our coding standards, so work needed to clean that up.

Alternatively should we just use the Symfony class for the double-quoting rules and a custom method on the test itself for the single-quoting rules? That would save us copying the class at all; we only use it in this one place anyway.

Finally, should we have unit tests for the failure cases in the test?

ravi.shankar’s picture

Assigned: Unassigned » ravi.shankar
ravi.shankar’s picture

Assigned: ravi.shankar » Unassigned
tvb’s picture

StatusFileSize
new258.58 KB
new7.62 KB

Fixed coding standards in the copied Symfony class.

tvb’s picture

Status: Needs work » Needs review
StatusFileSize
new255.87 KB
new6.12 KB

The alternative solution suggested in 67.2.

volkswagenchick’s picture

Issue tags: +Novice

Tagging novice

tvb’s picture

Issue summary: View changes
tvb’s picture

Issue summary: View changes
tvb’s picture

Assigned: Unassigned » tvb
Status: Needs review » Needs work
StatusFileSize
new256.45 KB

Rerolled patch.

'Needs work' because it does not comply with the standards proposal.

tvb’s picture

Assigned: tvb » Unassigned
Status: Needs work » Needs review
StatusFileSize
new254.6 KB
new8.54 KB

A reworked patch.

The test no longer uses the Symfony Escaper class.
It follows the standards proposal in the issue summary.

These sample values for description pass the consistency test:

  • can also use " quotes ' and $ a % lot /&?+ of other ~ @ <> stuff
  • no need to escape backslash \
  • this is a link https://www.drupal.org
  • '& starts with a special character, needs quotes'
  • 'to express one single quote inside a quoted string, use '' two of them'

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.

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ressa’s picture

Thanks for working on this, I just created #3278144: Remove quotes from olivero.info.yml.

The suggested guideline in this issue is "Standards proposal for name and description values: The first character in the name value is a letter or underscore." which I agree with, since you don't need to quote a YAML string, as long as the first character is not a special character.

In the Issue Summary, only titles and descriptions are mentioned, but what about other strings, for example under regions in a theme, or alt text? Shouldn't we be consistent, and don't quote any string at all by default, except for special cases? (The rules under "In the following cases, use single quoting").

For more, see:

So I agree with @ultimike's proposal (4 October 2018):

tl;dr It seems that the prevailing "best practice" is to not use any quotes unless you need them.

I also agree with Chi (21 March 2019):

Modules with one word title should use no quotes around the title.
Modules with multiple word title should use single quotes around the title.

What is the rationale behind such a decision? Strings with multiple words in YML files work fine. This might be a bit confusing because some IDEs (i.e. PhpStorm) highlight quoted strings differently.

Also, this comment by @Chi is interesting, and makes sense to me:

Also wonder why this issue is limited to module info files?

... as well as @ultimike's observation:

I love this idea of making things consistent. Whatever is decided should probably be documented in our coding standards. A good place to start would be to add a new issue to the Coding Standards issue queue.

I agree, it would be great to document YAML coding standards, for example for quoting. Perhaps the "Proposed resolution" for quoting as seen in the Issue Summary could be added to YAML Configuration files?

Or should an issue be created under https://www.drupal.org/project/issues/coding_standards for discussion?

ravi.shankar’s picture

StatusFileSize
new251.45 KB
new19.8 KB

Added reroll of path #76 on Drupal 9.4.x.

quietone’s picture

The process for changing coding standards is documented on the project page for the Coding Standards project. It starts with making an issue in that project. My search turned up one issue referring to YAML, #2823463: Devise an extensible way to document extensible data structures.

ravi.shankar’s picture

StatusFileSize
new251.37 KB
new1.25 KB

Fixed Drupal CS issue of patch #80.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Status: Needs review » Needs work

The last submitted patch, 82: 2994928-82.patch, failed testing. View results

bkline’s picture

Was it an intentional sadistic joke that for Boolean values in Drupal YAML files quotes MUST be present in some uses and MUST NOT be present in other uses?

  requirements:
    _access: 'TRUE'
  options:
    no_cache: TRUE
chi’s picture

If I am not mistaken in the value _access: 'TRUE' is actually treated as strings.
Real boolean in YML are never quoted.

bkline’s picture

Am I the only one who thinks this is a confusing and bizarre thing to do (use 'TRUE' as a string)?

ravi.shankar’s picture

StatusFileSize
new251.52 KB
new5.62 KB

Added reroll of patch #82 on Drupal 9.5.x and tried to fix failed test of patch #82 as well.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Issue summary: View changes
Status: Needs work » Active
Issue tags: -Novice +Coding standards

There is no patch here to review. What needs to be done here now is to make a coding standards issue to decide on the style to use.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.